diff --git a/.github/jobs/build_docker_image.sh b/.github/jobs/build_docker_image.sh index 47dc46e20a..f216c0aa0e 100755 --- a/.github/jobs/build_docker_image.sh +++ b/.github/jobs/build_docker_image.sh @@ -15,7 +15,7 @@ time_command docker build -t ${DOCKERHUB_TAG} \ --build-arg MET_CONFIG_OPTS \ -f $DOCKERFILE_PATH ${GITHUB_WORKSPACE} if [ $? != 0 ]; then - cat ${GITHUB_WORKSPACE}/docker_build.log + cat ${CMD_LOGFILE} exit 1 fi diff --git a/.github/jobs/build_sonarqube_image.sh b/.github/jobs/build_sonarqube_image.sh new file mode 100755 index 0000000000..55d558624b --- /dev/null +++ b/.github/jobs/build_sonarqube_image.sh @@ -0,0 +1,45 @@ +#! /bin/bash + +source ${GITHUB_WORKSPACE}/.github/jobs/bash_functions.sh + +DOCKERHUB_TAG=met-sonarqube-gha + +DOCKERFILE_PATH=${GITHUB_WORKSPACE}/internal/scripts/docker/Dockerfile.sonarqube + +CMD_LOGFILE=${GITHUB_WORKSPACE}/sonarqube_build.log + +# +# Define the $SONAR_REFERENCE_BRANCH as the +# - Target of any requests +# - Manual setting for workflow dispatch +# - Source branch for any pushes (e.g. develop) +# +if [ "${GITHUB_EVENT_NAME}" == "pull_request" ]; then + export SONAR_REFERENCE_BRANCH=${GITHUB_BASE_REF} +elif [ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]; then + export SONAR_REFERENCE_BRANCH=${WD_REFERENCE_BRANCH} +else + export SONAR_REFERENCE_BRANCH=${SOURCE_BRANCH} +fi + +echo SONAR_REFERENCE_BRANCH=${SONAR_REFERENCE_BRANCH} + +time_command docker build -t ${DOCKERHUB_TAG} \ + --build-arg MET_BASE_REPO \ + --build-arg MET_BASE_TAG \ + --build-arg SOURCE_BRANCH \ + --build-arg SONAR_SCANNER_VERSION \ + --build-arg SONAR_HOST_URL \ + --build-arg SONAR_TOKEN \ + --build-arg SONAR_REFERENCE_BRANCH \ + -f $DOCKERFILE_PATH ${GITHUB_WORKSPACE} +if [ $? != 0 ]; then + cat ${CMD_LOGFILE} + exit 1 +fi + +# Copy the .scannerwork directory from the image +id=$(docker create ${DOCKERHUB_TAG}) +time_command mkdir -p /tmp/scannerwork +time_command docker cp $id:/met/.scannerwork/report-task.txt /tmp/scannerwork/report-task.txt +docker rm -v $id diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index d3a97c7a05..0ed1004546 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -22,6 +22,9 @@ If **yes**, describe the new output and/or changes to the existing output:
- [ ] Will this PR result in changes to existing METplus Use Cases? **[Yes or No]**
If **yes**, create a new **Update Truth** [METplus issue](https://github.com/dtcenter/METplus/issues/new/choose) to describe them. +- [ ] Do these changes introduce new SonarQube findings? **[Yes or No]**
+If **yes**, please describe: + - [ ] Please complete this pull request review by **[Fill in date]**.
## Pull Request Checklist ## diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml new file mode 100644 index 0000000000..6a6627fb69 --- /dev/null +++ b/.github/workflows/sonarqube.yml @@ -0,0 +1,91 @@ +name: SonarQube Scan + +# Run SonarQube for Pull Requests and changes to the develop and main_vX.Y branches + +on: + + # Trigger analysis for pushes to develop and main_vX.Y branches + push: + branches: + - develop + - 'main_v**' + paths-ignore: + - 'docs/**' + - '.github/pull_request_template.md' + - '.github/ISSUE_TEMPLATE/**' + - '.github/labels/**' + - '**/README.md' + - '**/LICENSE.md' + + # Trigger analysis for pull requests to develop and main_vX.Y branches + pull_request: + types: [opened, synchronize, reopened] + branches: + - develop + - 'main_v**' + paths-ignore: + - 'docs/**' + - '.github/pull_request_template.md' + - '.github/ISSUE_TEMPLATE/**' + - '.github/labels/**' + - '**/README.md' + - '**/LICENSE.md' + + workflow_dispatch: + inputs: + reference_branch: + description: 'Reference Branch' + default: develop + type: string + +jobs: + build: + name: SonarQube Scan + runs-on: ubuntu-latest + + steps: + + - uses: actions/checkout@v4 + with: + # Disable shallow clones for better analysis + fetch-depth: 0 + + - name: Create output directories + run: mkdir -p ${RUNNER_WORKSPACE}/logs + + - name: Get branch name + id: get_branch_name + run: echo branch_name=${GITHUB_REF#refs/heads/} >> $GITHUB_OUTPUT + + - name: SonarQube Scan in Docker + run: .github/jobs/build_sonarqube_image.sh + env: + MET_BASE_REPO: met-base + MET_BASE_TAG: v3.2 + SOURCE_BRANCH: ${{ steps.get_branch_name.outputs.branch_name }} + WD_REFERENCE_BRANCH: ${{ github.event.inputs.reference_branch }} + SONAR_SCANNER_VERSION: 5.0.1.3006 + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + - name: SonarQube Quality Gate check + id: sonarqube-quality-gate-check + uses: sonarsource/sonarqube-quality-gate-action@master + with: + scanMetadataReportFile: /tmp/scannerwork/report-task.txt + timeout-minutes: 5 + env: + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + - name: Copy log files into logs directory + if: always() + run: cp ${GITHUB_WORKSPACE}/*.log ${RUNNER_WORKSPACE}/logs/ + + - name: Upload logs as artifact + if: always() + uses: actions/upload-artifact@v4 + with: + name: logs_sonarqube + path: ${{ runner.workspace }}/logs + if-no-files-found: ignore diff --git a/data/config/TCRMWConfig_default b/data/config/TCRMWConfig_default index dfb18721ac..e27a4b2741 100644 --- a/data/config/TCRMWConfig_default +++ b/data/config/TCRMWConfig_default @@ -98,9 +98,8 @@ regrid = { // n_range = 100; n_azimuth = 180; -max_range_km = 1000.0; delta_range_km = 10.0; -rmw_scale = 0.2; +rmw_scale = NA; // // Optionally convert u/v winds to tangential/radial winds diff --git a/docs/Users_Guide/reformat_point.rst b/docs/Users_Guide/reformat_point.rst index 32695f36b0..ec09fa3f83 100644 --- a/docs/Users_Guide/reformat_point.rst +++ b/docs/Users_Guide/reformat_point.rst @@ -458,6 +458,8 @@ While initial versions of the ASCII2NC tool only supported a simple 11 column AS • `International Soil Moisture Network (ISMN) Data format `_. +• `International Arctic Buoy Programme (IABP) Data format `_. + • `AErosol RObotic NEtwork (AERONET) versions 2 and 3 format `_ • Python embedding of point observations, as described in :numref:`pyembed-point-obs-data`. See example below in :numref:`ascii2nc-pyembed`. @@ -522,6 +524,8 @@ Once the ASCII point observations have been formatted as expected, the ASCII fil netcdf_file [-format ASCII_format] [-config file] + [-valid_beg time] + [-valid_end time] [-mask_grid string] [-mask_poly file] [-mask_sid file|list] @@ -541,21 +545,25 @@ Required Arguments for ascii2nc Optional Arguments for ascii2nc ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -3. The **-format ASCII_format** option may be set to "met_point", "little_r", "surfrad", "wwsis", "airnowhourlyaqobs", "airnowhourly", "airnowdaily_v2", "ndbc_standard", "ismn", "aeronet", "aeronetv2", "aeronetv3", or "python". If passing in ISIS data, use the "surfrad" format flag. +3. The **-format ASCII_format** option may be set to "met_point", "little_r", "surfrad", "wwsis", "airnowhourlyaqobs", "airnowhourly", "airnowdaily_v2", "ndbc_standard", "ismn", "iabp", "aeronet", "aeronetv2", "aeronetv3", or "python". If passing in ISIS data, use the "surfrad" format flag. 4. The **-config file** option is the configuration file for generating time summaries. -5. The **-mask_grid** string option is a named grid or a gridded data file to filter the point observations spatially. +5. The **-valid_beg** time option in YYYYMMDD[_HH[MMSS]] format sets the beginning of the retention time window. -6. The **-mask_poly** file option is a polyline masking file to filter the point observations spatially. +6. The **-valid_end** time option in YYYYMMDD[_HH[MMSS]] format sets the end of the retention time window. -7. The **-mask_sid** file|list option is a station ID masking file or a comma-separated list of station ID's to filter the point observations spatially. See the description of the "sid" entry in :numref:`config_options`. +7. The **-mask_grid** string option is a named grid or a gridded data file to filter the point observations spatially. -8. The **-log file** option directs output and errors to the specified log file. All messages will be written to that file as well as standard out and error. Thus, users can save the messages without having to redirect the output on the command line. The default behavior is no log file. +8. The **-mask_poly** file option is a polyline masking file to filter the point observations spatially. -9. The **-v level** option indicates the desired level of verbosity. The value of "level" will override the default setting of 2. Setting the verbosity to 0 will make the tool run with no log messages, while increasing the verbosity above 1 will increase the amount of logging. +9. The **-mask_sid** file|list option is a station ID masking file or a comma-separated list of station ID's to filter the point observations spatially. See the description of the "sid" entry in :numref:`config_options`. -10. The **-compress level** option indicates the desired level of compression (deflate level) for NetCDF variables. The valid level is between 0 and 9. The value of "level" will override the default setting of 0 from the configuration file or the environment variable MET_NC_COMPRESS. Setting the compression level to 0 will make no compression for the NetCDF output. Lower number is for fast compression and higher number is for better compression. +10. The **-log file** option directs output and errors to the specified log file. All messages will be written to that file as well as standard out and error. Thus, users can save the messages without having to redirect the output on the command line. The default behavior is no log file. + +11. The **-v level** option indicates the desired level of verbosity. The value of "level" will override the default setting of 2. Setting the verbosity to 0 will make the tool run with no log messages, while increasing the verbosity above 1 will increase the amount of logging. + +12. The **-compress level** option indicates the desired level of compression (deflate level) for NetCDF variables. The valid level is between 0 and 9. The value of "level" will override the default setting of 0 from the configuration file or the environment variable MET_NC_COMPRESS. Setting the compression level to 0 will make no compression for the NetCDF output. Lower number is for fast compression and higher number is for better compression. An example of the ascii2nc calling sequence is shown below: @@ -1203,3 +1211,34 @@ For how to use the script, issue the command: .. code-block:: none python3 MET_BASE/python/utility/print_pointnc2ascii.py -h + +IABP retrieval Python Utilities +==================================== + +`International Arctic Buoy Programme (IABP) Data `_ is one of the data types supported by ascii2nc. A utility script that pulls all this data from the web and stores it locally, called get_iabp_from_web.py is included. This script accesses the appropriate webpage and downloads the ascii files for all buoys. It is straightforward, but can be time intensive as the archive of this data is extensive and files are downloaded one at a time. + +The script can be found at: + +.. code-block:: none + + MET_BASE/python/utility/get_iabp_from_web.py + +For how to use the script, issue the command: + +.. code-block:: none + + python3 MET_BASE/python/utility/get_iabp_from_web.py -h + +Another IABP utility script is included for users, to be run after all files have been downloaded using get_iabp_from_web.py. This script examines all the files and lists those files that contain entries that fall within a user specified range of days. It is called find_iabp_in_timerange.py. + +The script can be found at: + +.. code-block:: none + + MET_BASE/python/utility/find_iabp_in_timerange.py + +For how to use the script, issue the command: + +.. code-block:: none + + python3 MET_BASE/python/utility/find_iabp_in_timerange.py -h diff --git a/docs/Users_Guide/tc-rmw.rst b/docs/Users_Guide/tc-rmw.rst index a9e67ffbc1..82628c087c 100644 --- a/docs/Users_Guide/tc-rmw.rst +++ b/docs/Users_Guide/tc-rmw.rst @@ -101,27 +101,19 @@ The **n_azimuth** parameter is the number of equally spaced azimuth intervals in _______________________ -.. code-block:: none - - max_range_km = 100.0; - -The **max_range_km** parameter specifies the maximum range of the range-azimuth grid, in kilometers. If this parameter is specified and not **rmw_scale**, the radial grid spacing will be **max_range_km / n_range**. - -_______________________ - .. code-block:: none delta_range_km = 10.0; -The **delta_range_km** parameter specifies the spacing of the range rings, in kilometers. +The **delta_range_km** parameter specifies the spacing of the range rings, in kilometers. The range values start with 0 km and extend out to **n_range - 1** times this delta spacing. _______________________ .. code-block:: none - rmw_scale = 0.2; + rmw_scale = NA; -The **rmw_scale** parameter overrides the **max_range_km** parameter. When this is set the radial grid spacing will be **rmw_scale** in units of the RMW, which varies along the storm track. +If changed from its default value of **NA**, the **rmw_scale** parameter overrides the **delta_range_km** parameter. The radial grid spacing is defined using **rmw_scale** in units of the RMW, which varies along the storm track. For example, setting **rmw_scale** to 0.2 would define the delta range spacing as 20% of the radius of maximum winds around each point. Note that RMW is defined in nautical miles but is converted to kilometers for this computation. _______________________ diff --git a/internal/scripts/docker/Dockerfile.sonarqube b/internal/scripts/docker/Dockerfile.sonarqube new file mode 100644 index 0000000000..75dc3c952c --- /dev/null +++ b/internal/scripts/docker/Dockerfile.sonarqube @@ -0,0 +1,94 @@ +ARG MET_BASE_REPO=met-base +ARG MET_BASE_TAG=v3.2 + +FROM dtcenter/${MET_BASE_REPO}:${MET_BASE_TAG} +MAINTAINER John Halley Gotway + +# +# This Dockerfile checks out MET from GitHub and runs the +# SonarQube static code analysis on the specified branch or tag. +# https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/ +# +ARG SONAR_SCANNER_VERSION=5.0.1.3006 +ARG SONAR_HOST_URL +ARG SONAR_TOKEN +ARG SOURCE_BRANCH +ARG SONAR_REFERENCE_BRANCH + +# +# SONAR_HOST_URL is required. +# +RUN if [ "x${SONAR_HOST_URL}" = "x" ]; then \ + echo "ERROR: SONAR_HOST_URL undefined! Rebuild with \"--build-arg SONAR_HOST_URL={url}\""; \ + exit 1; \ + fi + +# +# SONAR_TOKEN is required. +# +RUN if [ "x${SONAR_TOKEN}" = "x" ]; then \ + echo "ERROR: SONAR_TOKEN undefined! Rebuild with \"--build-arg SONAR_TOKEN={token}\""; \ + exit 1; \ + fi + +# +# SOURCE_BRANCH is the branch name of the MET source code. +# +RUN if [ "x${SOURCE_BRANCH}" = "x" ]; then \ + echo "ERROR: SOURCE_BRANCH undefined! Rebuild with \"--build-arg SOURCE_BRANCH={branch name}\""; \ + exit 1; \ + else \ + echo "Build Argument SOURCE_BRANCH=${SOURCE_BRANCH}"; \ + fi + +# +# SONAR_REFERENCE_BRANCH defines to the version against which this scan should be compared. +# +RUN if [ "x${SONAR_REFERENCE_BRANCH}" = "x" ]; then \ + echo "ERROR: SONAR_REFERENCE_BRANCH undefined! Rebuild with \"--build-arg SONAR_REFERENCE_BRANCH={branch name}\""; \ + exit 1; \ + else \ + echo "Build Argument SONAR_REFERENCE_BRANCH=${SONAR_REFERENCE_BRANCH}"; \ + fi + +ENV MET_GIT_NAME ${SOURCE_BRANCH} +ENV MET_REPO_DIR /met/MET-${MET_GIT_NAME} +ENV MET_GIT_URL https://github.com/dtcenter/MET + +# +# Download and install the Sonar software. +# +RUN echo "Installing SonarQube into $HOME/.sonar" \ + && mkdir -p $HOME/.sonar \ + && curl -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_VERSION}-linux.zip \ + && unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/ \ + && echo export PATH="$HOME/.sonar/sonar-scanner-${SONAR_SCANNER_VERSION}-linux/bin:\$PATH" >> $HOME/.bashrc \ + && curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip ${SONAR_HOST_URL}/static/cpp/build-wrapper-linux-x86.zip \ + && unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/ \ + && echo export PATH="$HOME/.sonar/build-wrapper-linux-x86:\$PATH" >> $HOME/.bashrc + +# +# Update the OS, as needed. +# +RUN apt update + +# +# Set the working directory. +# +WORKDIR /met + +# +# Copy MET Download and install MET. +# +RUN echo "Copying MET into ${MET_REPO_DIR}" \ + && mkdir -p ${MET_REPO_DIR} + +COPY . ${MET_REPO_DIR} + +RUN if [ ! -e "${MET_REPO_DIR}/configure.ac" ]; then \ + echo "ERROR: docker build must be run from the MET directory: `ls`"; \ + exit 1; \ + fi + +RUN cd ${MET_REPO_DIR} \ + && internal/scripts/docker/build_met_sonarqube.sh diff --git a/internal/scripts/docker/build_met_sonarqube.sh b/internal/scripts/docker/build_met_sonarqube.sh new file mode 100755 index 0000000000..45e1d10fc5 --- /dev/null +++ b/internal/scripts/docker/build_met_sonarqube.sh @@ -0,0 +1,128 @@ +#!/bin/bash +# +# Run SonarQube Source Code Analyzer within a Docker container +#======================================================================= +# +# This build_met_sonarqube.sh script must be run from the top-level +# directory of the MET repository to be analyzed. It runs SonarQube to +# scan the MET source code. +# +# Usage: internal/scripts/docker/build_met_sonarqube.sh +# +# Required Enviornment Variables: +# SONAR_HOST_URL +# SONAR_TOKEN +# MET_GIT_NAME +# SONAR_REFERENCE_BRANCH +# +#======================================================================= + +# Check that this is being run from the top-level MET directory +if [ ! -e internal/scripts/docker/build_met_sonarqube.sh ]; then + echo "ERROR: ${0} -> must be run from the top-level MET directory" + exit 1 +fi + +echo "Running script to scan MET with SonarQube in Docker" + +# Source the docker build environment +source ~/.bashrc +source internal/scripts/environment/development.docker +source .github/jobs/bash_functions.sh + +# Check required environment variables +if [ -z ${SONAR_HOST_URL+x} ]; then + echo "ERROR: ${0} -> \$SONAR_HOST_URL not defined!" + exit 1 +fi +if [ -z ${SONAR_TOKEN+x} ]; then + echo "ERROR: ${0} -> \$SONAR_TOKEN not defined!" + exit 1 +fi +if [ -z ${MET_GIT_NAME+x} ]; then + echo "ERROR: ${0} -> \$MET_GIT_NAME not defined!" + exit 1 +fi +if [ -z ${SONAR_REFERENCE_BRANCH+x} ]; then + echo "ERROR: ${0} -> \$SONAR_REFERENCE_BRANCH not defined!" + exit 1 +fi + +# Locate the wrapper +WRAPPER_NAME=build-wrapper-linux-x86-64 +SONAR_WRAPPER=$(which $WRAPPER_NAME 2> /dev/null) + +if [ ! -e $SONAR_WRAPPER ]; then + echo "ERROR: ${0} -> $WRAPPER_NAME not found in the path" + exit 1 +else + echo "SONAR_WRAPPER=$SONAR_WRAPPER" +fi + +# Locate the scanner +SCANNER_NAME=sonar-scanner +SONAR_SCANNER=$(which $SCANNER_NAME 2> /dev/null) + +if [ ! -e $SONAR_SCANNER ]; then + echo "ERROR: ${0} -> $SCANNER_NAME not found in the path" + exit 1 +else + echo "SONAR_SCANNER=$SONAR_SCANNER" +fi + +# Set output directory name +if [ -z ${SONARQUBE_OUT_DIR} ]; then + export SONARQUBE_OUT_DIR=bw-outputs +fi + +# Define the version string +SONAR_PROJECT_VERSION=$(cat docs/version | cut -d'=' -f2 | tr -d '" ') + +# Store the full path to the scripts directory +SONAR_PROPERTIES_DIR=internal/scripts/sonarqube +SONAR_PROPERTIES=sonar-project.properties + +# Configure the sonar-project.properties +[ -e $SONAR_PROPERTIES ] && rm $SONAR_PROPERTIES +sed -e "s|SONAR_PROJECT_KEY|MET-GHA|" \ + -e "s|SONAR_PROJECT_NAME|MET GHA|" \ + -e "s|SONAR_PROJECT_VERSION|$SONAR_PROJECT_VERSION|" \ + -e "s|SONAR_HOST_URL|$SONAR_HOST_URL|" \ + -e "s|SONAR_TOKEN|$SONAR_TOKEN|" \ + -e "s|SONAR_BRANCH_NAME|$MET_GIT_NAME|" \ + $SONAR_PROPERTIES_DIR/$SONAR_PROPERTIES > $SONAR_PROPERTIES + +# The source and reference branches must differ to define new code +if [ "$MET_GIT_NAME" != "$SONAR_REFERENCE_BRANCH" ]; then + echo "sonar.newCode.referenceBranch=${SONAR_REFERENCE_BRANCH}" >> $SONAR_PROPERTIES +fi + +# Run the MET configure script +time_command ./configure \ + BUFRLIB_NAME=${BUFRLIB_NAME} \ + GRIB2CLIB_NAME=${GRIB2CLIB_NAME} \ + --enable-all \ + CPPFLAGS="-I/usr/local/include -I/usr/local/include/freetype2 -I/usr/local/include/cairo" \ + LIBS="-ltirpc" + +# Run make clean +time_command make clean + +# Run SonarQube make +time_command $SONAR_WRAPPER --out-dir $SONARQUBE_OUT_DIR make + +# Run SonarQube scan +time_command $SONAR_SCANNER +status=$? + +# Check return status +if [[ $status -ne 0 ]]; then + echo "ERROR: ${0} -> the SonarQube scan returned with non-zero status (${status})!" + exit ${status} +fi + +# Copy the scan report-task.txt file +mkdir -p /met/.scannerwork +cp .scannerwork/report-task.txt /met/.scannerwork/report-task.txt + +[ -e $SONAR_PROPERTIES ] && rm $SONAR_PROPERTIES diff --git a/internal/scripts/sonarqube/python.sonar-project.properties b/internal/scripts/sonarqube/python.sonar-project.properties deleted file mode 100644 index f304a07204..0000000000 --- a/internal/scripts/sonarqube/python.sonar-project.properties +++ /dev/null @@ -1,18 +0,0 @@ -sonar.projectKey=MET_python_NB -sonar.projectName=MET python Nightly Build -sonar.projectVersion=1.0 - -sonar.sources=scripts/python,data/wrappers -sonar.python.version=3.6.3 - -# The build-wrapper output dir - -# Encoding of the source files -sonar.sourceEncoding=UTF-8 - -#----- Default SonarQube server -#sonar.host.url=http://localhost:9000 -sonar.host.url=SONAR_SERVER_URL - -sonar.token=SONAR_TOKEN_VALUE -sonar.branch.name=develop diff --git a/internal/scripts/sonarqube/run_sonarqube.sh b/internal/scripts/sonarqube/run_sonarqube.sh index 31264f2f9b..1a57b0b726 100755 --- a/internal/scripts/sonarqube/run_sonarqube.sh +++ b/internal/scripts/sonarqube/run_sonarqube.sh @@ -24,10 +24,10 @@ GIT_REPO="https://github.com/dtcenter/${GIT_REPO_NAME}" function usage { - echo - echo "USAGE: $(basename $0) name" - echo " where \"name\" specifies a branch, tag, or hash." - echo + echo + echo "USAGE: $(basename $0) name" + echo " where \"name\" specifies a branch, tag, or hash." + echo } # Check for arguments @@ -90,7 +90,6 @@ function run_command() { return ${STATUS} } - # Store the full path to the scripts directory SCRIPT_DIR=`dirname $0` if [[ ${0:0:1} != "/" ]]; then SCRIPT_DIR=$(pwd)/${SCRIPT_DIR}; fi @@ -111,46 +110,37 @@ run_command "git checkout ${1}" export MET_DEVELOPMENT=true # Run the configure script -run_command "./configure --prefix=`pwd` \ - --enable-grib2 \ - --enable-modis \ - --enable-mode_graphics \ - --enable-lidar2nc \ - --enable-python \ - --enable-ugrid" +run_command "./configure --prefix=`pwd` --enable-all" -# Set the build id -#BUILD_ID="MET-${1}" +# Define the version string +SONAR_PROJECT_VERSION=$(grep "^version" docs/conf.py | cut -d'=' -f2 | tr -d "\'\" ") SONAR_PROPERTIES=sonar-project.properties -# Copy sonar-project.properties for Python code +# Configure sonar-project.properties [ -e $SONAR_PROPERTIES ] && rm $SONAR_PROPERTIES -[ -z "$SONAR_SERVER_URL" ] && SONAR_SERVER_URL="http://localhost:9000" -if [ -z "$SONAR_TOKEN_VALUE" ]; then - echo " == ERROR == SONAR_TOKEN_VALUE is not defined" +[ -z "$SONAR_HOST_URL" ] && SONAR_HOST_URL="http://localhost:9000" +if [ -z "$SONAR_TOKEN" ]; then + echo " == ERROR == SONAR_TOKEN is not defined" exit 1 else - sed -e "s|SONAR_TOKEN_VALUE|$SONAR_TOKEN_VALUE|" -e "s|SONAR_SERVER_URL|$SONAR_SERVER_URL|" $SCRIPT_DIR/python.sonar-project.properties > $SONAR_PROPERTIES - - # Run SonarQube scan for Python code - run_command "$SONAR_SCANNER" - - # Copy sonar-project.properties for C/C++ code [ -e $SONAR_PROPERTIES ] && rm $SONAR_PROPERTIES - sed -e "s|SONAR_TOKEN_VALUE|$SONAR_TOKEN_VALUE|" -e "s|SONAR_SERVER_URL|$SONAR_SERVER_URL|" $SCRIPT_DIR/sonar-project.properties > $SONAR_PROPERTIES + sed -e "s|SONAR_PROJECT_KEY|MET_NB|" \ + -e "s|SONAR_PROJECT_NAME|MET Nightly Build|" \ + -e "s|SONAR_PROJECT_VERSION|$SONAR_PROJECT_VERSION|" \ + -e "s|SONAR_HOST_URL|$SONAR_HOST_URL|" \ + -e "s|SONAR_TOKEN|$SONAR_TOKEN|" \ + -e "s|SONAR_BRANCH_NAME|${1}|" \ + $SCRIPT_DIR/$SONAR_PROPERTIES > $SONAR_PROPERTIES # Run SonarQube clean run_command "make clean" - # Run SonarQube make + # Run SonarQube build wrapper run_command "$SONAR_WRAPPER --out-dir $SONARQUBE_OUT_DIR make" - # Run SonarQube scan for C/C++ code + # Run SonarQube scan run_command "$SONAR_SCANNER" [ -e $SONAR_PROPERTIES ] && rm $SONAR_PROPERTIES fi - -# Run SonarQube report generator to make a PDF file -#TODAY=`date +%Y%m%d` diff --git a/internal/scripts/sonarqube/sonar-project.properties b/internal/scripts/sonarqube/sonar-project.properties index ec39576c4f..215749e75b 100644 --- a/internal/scripts/sonarqube/sonar-project.properties +++ b/internal/scripts/sonarqube/sonar-project.properties @@ -1,18 +1,15 @@ -sonar.projectKey=MET_develop_NB -sonar.projectName=MET Nightly Build -sonar.projectVersion=1.0 - -sonar.sources=src +# Project and source code settings +sonar.projectKey=SONAR_PROJECT_KEY +sonar.projectName=SONAR_PROJECT_NAME +sonar.projectVersion=SONAR_PROJECT_VERSION +sonar.branch.name=SONAR_BRANCH_NAME +sonar.sources=src,scripts/python,data/wrappers +sonar.python.version=3.6.3 +sonar.sourceEncoding=UTF-8 # The build-wrapper output dir sonar.cfamily.build-wrapper-output=bw-outputs -# Encoding of the source files -sonar.sourceEncoding=UTF-8 - -#----- Default SonarQube server -#sonar.host.url=http://localhost:9000 -sonar.host.url=SONAR_SERVER_URL - -sonar.token=SONAR_TOKEN_VALUE -sonar.branch.name=develop +# SonarQube server +sonar.host.url=SONAR_HOST_URL +sonar.token=SONAR_TOKEN diff --git a/internal/test_unit/config/TCRMWConfig_gonzalo b/internal/test_unit/config/TCRMWConfig_gonzalo index 32a6beb118..d2ff3a1c00 100644 --- a/internal/test_unit/config/TCRMWConfig_gonzalo +++ b/internal/test_unit/config/TCRMWConfig_gonzalo @@ -99,9 +99,8 @@ regrid = { // n_range = 50; n_azimuth = 90; -max_range_km = 1000.0; delta_range_km = 10.0; -rmw_scale = 0.2; +rmw_scale = NA; // // Optionally convert u/v winds to tangential/radial winds diff --git a/internal/test_unit/config/TCRMWConfig_pressure_lev_out b/internal/test_unit/config/TCRMWConfig_pressure_lev_out index 747d9fa9b5..aa8c7a2287 100644 --- a/internal/test_unit/config/TCRMWConfig_pressure_lev_out +++ b/internal/test_unit/config/TCRMWConfig_pressure_lev_out @@ -99,8 +99,7 @@ regrid = { // n_range = 100; n_azimuth = 180; -max_range_km = 1000.0; -delta_range_km = 10.0; +delta_range_km = NA; rmw_scale = 0.2; // diff --git a/internal/test_unit/xml/unit_ascii2nc.xml b/internal/test_unit/xml/unit_ascii2nc.xml index 2dd9df07e7..4424fd0e33 100644 --- a/internal/test_unit/xml/unit_ascii2nc.xml +++ b/internal/test_unit/xml/unit_ascii2nc.xml @@ -211,4 +211,19 @@ + + &MET_BIN;/ascii2nc + \ + -format iabp \ + -valid_beg 20140101 -valid_end 20140201 \ + &DATA_DIR_OBS;/iabp/090629.dat \ + &DATA_DIR_OBS;/iabp/109320.dat \ + &DATA_DIR_OBS;/iabp/109499.dat \ + &OUTPUT_DIR;/ascii2nc/iabp_20140101_20140201.nc + + + &OUTPUT_DIR;/ascii2nc/iabp_20140101_20140201.nc + + + diff --git a/scripts/python/utility/Makefile.am b/scripts/python/utility/Makefile.am index 5efd02b01e..2509cff62b 100644 --- a/scripts/python/utility/Makefile.am +++ b/scripts/python/utility/Makefile.am @@ -26,8 +26,11 @@ pythonutilitydir = $(pkgdatadir)/python/utility pythonutility_DATA = \ + build_ndbc_stations_from_web.py \ + find_iabp_in_timerange.py \ + get_iabp_from_web.py \ print_pointnc2ascii.py \ - build_ndbc_stations_from_web.py + rgb2ctable.py EXTRA_DIST = ${pythonutility_DATA} diff --git a/scripts/python/utility/Makefile.in b/scripts/python/utility/Makefile.in index 4c379b52a6..0b977854db 100644 --- a/scripts/python/utility/Makefile.in +++ b/scripts/python/utility/Makefile.in @@ -311,8 +311,11 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ pythonutilitydir = $(pkgdatadir)/python/utility pythonutility_DATA = \ + build_ndbc_stations_from_web.py \ + find_iabp_in_timerange.py \ + get_iabp_from_web.py \ print_pointnc2ascii.py \ - build_ndbc_stations_from_web.py + rgb2ctable.py EXTRA_DIST = ${pythonutility_DATA} MAINTAINERCLEANFILES = Makefile.in diff --git a/scripts/python/utility/find_iabp_in_timerange.py b/scripts/python/utility/find_iabp_in_timerange.py new file mode 100755 index 0000000000..3aa76d1eff --- /dev/null +++ b/scripts/python/utility/find_iabp_in_timerange.py @@ -0,0 +1,241 @@ + #!/usr/bin/env python3 + +from optparse import OptionParser +import urllib.request +import datetime +from datetime import date +import os +import shutil +import shlex +import errno +from subprocess import Popen, PIPE + + + +#---------------------------------------------- +def usage(): + print("Usage: find_iabp_in_timerange.py -s yyyymmdd -e yyyymmdd [-d PATH]") + +#---------------------------------------------- +def is_date_in_range(input_date, start_date, end_date): + return start_date <= input_date <= end_date + +#---------------------------------------------- +def lookFor(name, inlist, filename, printWarning=False): + rval = -1 + try: + rval = inlist.index(name) + except: + if printWarning: + print(name, " not in header line, file=", filename) + + return rval + +#---------------------------------------------- +def pointToInt(index, tokens, filename): + if index < 0 or index >= len(tokens): + print("ERROR index out of range ", index) + return -1 + return int(tokens[index]) + +#---------------------------------------------- +def pointToFloat(index, tokens, filename): + if index < 0 or index >= len(tokens): + print("ERROR index out of range ", index) + return -99.99 + return float(tokens[index]) + +#---------------------------------------------- +class StationHeader: + def __init__(self, headerLine, filename): + tokens = headerLine.split() + self._ok = True + self._idIndex = lookFor('BuoyID', tokens, filename, True) + self._yearIndex = lookFor('Year', tokens, filename, True) + self._hourIndex = lookFor('Hour', tokens, filename, True) + self._minuteIndex = lookFor('Min', tokens, filename, True) + self._doyIndex = lookFor('DOY', tokens, filename, True) + self._posdoyIndex = lookFor('POS_DOY', tokens, filename, True) + self._latIndex = lookFor('Lat', tokens, filename, True) + self._lonIndex = lookFor('Lon', tokens, filename, True) + self._bpIndex = lookFor('BP', tokens, filename, False) + self._tsIndex = lookFor('Ts', tokens, filename, False) + self._taIndex = lookFor('Ta', tokens, filename, False) + self._ok = self._idIndex != -1 and self._yearIndex != -1 and self._hourIndex != -1 \ + and self._minuteIndex != -1 and self._doyIndex != -1 and self._posdoyIndex != -1 \ + and self._latIndex != -1 and self._lonIndex != -1 + if not self._ok: + print("ERROR badly formed header line") + +#---------------------------------------------- +class Station: + def __init__(self, line, filename, stationHeader): + self._ok = True + tokens = line.split() + self._id = pointToInt(stationHeader._idIndex, tokens, filename) + if self._id < 0: + self._ok = False + self._year = pointToInt(stationHeader._yearIndex, tokens, filename) + if self._year < 0: + self._ok = False + self._hour = pointToInt(stationHeader._hourIndex, tokens, filename) + if self._hour < 0: + self._ok = False + self._minute = pointToInt(stationHeader._minuteIndex, tokens, filename) + if self._minute < 0: + self._ok = False + self._doy = pointToFloat(stationHeader._doyIndex, tokens, filename) + if self._doy < 0: + self._ok = False + if self._doy > 365: + self._ok = False + self._posdoy = pointToFloat(stationHeader._posdoyIndex, tokens, filename) + if self._posdoy < 0: + self._ok = False + if self._posdoy > 365: + self._ok = False + self._lat = pointToFloat(stationHeader._latIndex, tokens, filename) + if self._lat == -99.99: + self._ok = False + self._lon = pointToFloat(stationHeader._lonIndex, tokens, filename) + if self._lon == -99.99: + self._ok = False + if stationHeader._bpIndex >= 0: + self._pressure = pointToFloat(stationHeader._bpIndex, tokens, filename) + else: + self._pressure = -99.99 + if stationHeader._tsIndex >= 0: + self._tempsurface = pointToFloat(stationHeader._tsIndex, tokens, filename) + else: + self._tempsurface = -99.99 + if stationHeader._taIndex >= 0: + self._tempair = pointToFloat(stationHeader._taIndex, tokens, filename) + else: + self._tempair = -99.99 + + if self._ok: + d = datetime.datetime(self._year, 1, 1) + datetime.timedelta(self._doy - 1) + self._month = d.month + self._day = d.day + else: + self._month = -1 + self._day = -1 + def timeInRange(self, start_date, end_date): + if self._ok: + input_date = date(self._year, self._month, self._day) + return is_date_in_range(input_date, start_date, end_date) + else: + return False + +#---------------------------------------------- +class StationTimeSeries: + def __init__(self, stationHeader): + self._stationHeader = stationHeader + self._data = [] + def add(self, line, filename): + s = Station(line, filename, self._stationHeader) + if s._ok: + self._data.append(s) + def print(self): + print("Nothing") + def hasTimesInRange(self, start_date, end_date): + for s in self._data: + if (s.timeInRange(start_date, end_date)): + return True + return False + +#---------------------------------------------- +def doCmd(cmd, debug=False): + #print(cmd) + my_env = os.environ.copy() + args = shlex.split(cmd) + proc = Popen(args, stdout=PIPE, stderr=PIPE, env=my_env) + out, err = proc.communicate() + exitcode = proc.returncode + if exitcode == 0: + return str(out) + else: + if debug: + print("Command failed ", cmd) + return "" + +#---------------------------------------------- +def getdatafilenames(aDir): + if (os.path.exists(aDir)): + allFiles = [name for name in os.listdir(aDir) \ + if not os.path.isdir(os.path.join(aDir, name))] + return [s for s in allFiles if '.dat' in s] + else: + return [] + +#---------------------------------------------- +def run2(data_path, start, end): + + if (data_path[0:2] != "./" and data_path[0] != '/'): + inpath = "./" + data_path + else: + inpath = data_path + + print("data_path = ", inpath) + + # could put testing here to make sure strings will convert + print("start = ", start) + print("end = ", end) + + y0 = int(start[0:4]) + m0 = int(start[4:6]) + d0 = int(start[6:8]) + + y1 = int(end[0:4]) + m1 = int(end[4:6]) + d1 = int(end[6:8]) + + print("Looking for file with data in range ", y0, m0, d0, " to ", y1, m1, d1) + + # read each file that ends in .dat + stationfiles = getdatafilenames(inpath) + stationfiles.sort() + + print("We have ", len(stationfiles), " data files to look at") + start_date = date(y0, m0, d0) + end_date = date(y1, m1, d1) + + for i in range(len(stationfiles)): + + #print("Looking at ", stationfiles[i]) + with open(inpath + "/" + stationfiles[i], 'r') as file: + data_all = file.read() + file.close() + lines = data_all.splitlines() + + # first line is a header, remaining lines are a time series + sh = StationHeader(lines[0], stationfiles[i]) + if sh._ok: + lines = lines[1:] + st = StationTimeSeries(sh) + for l in lines: + st.add(l, stationfiles[i]) + + if (st.hasTimesInRange(start_date, end_date)): + print(stationfiles[i]) + +#---------------------------------------------- +def create_parser_options(parser): + parser.add_option("-d", "--data_path", dest="data_path", + default="./iabp_files", help=" path to the station files (.dat) (default: ./iabp_files)") + parser.add_option("-s", "--start", dest="start", + default="notset", help=" starting yyyymmdd. Must be set") + parser.add_option("-e", "--end", dest="end", + default="notset", help=" ending yyyymmdd. Must be set") + return parser.parse_args() + +#---------------------------------------------- +if __name__ == "__main__": + usage_str = "%prog [options]" + parser = OptionParser(usage = usage_str) + options, args = create_parser_options(parser) + if (options.start == "notset" or options.end == "notset"): + usage() + exit(0) + run2(options.data_path, options.start, options.end) + exit(0) diff --git a/scripts/python/utility/get_iabp_from_web.py b/scripts/python/utility/get_iabp_from_web.py new file mode 100755 index 0000000000..b2a931c8fe --- /dev/null +++ b/scripts/python/utility/get_iabp_from_web.py @@ -0,0 +1,235 @@ + #!/usr/bin/env python3 + +from optparse import OptionParser +import urllib.request +import os +import shutil +import shlex +import errno +from subprocess import Popen, PIPE + +#---------------------------------------------------------------------------- +def makeOrScrub(path, debug=False): + if (debug): + print("Recreating path " + path) + if (os.path.exists(path)): + try: + shutil.rmtree(path) + os.makedirs(path) + except: + print('WARNING: ' + path + ' not completely cleaned out.') + else: + os.makedirs(path) + + +#---------------------------------------------- +def lookFor(name, inlist, filename, printWarning=False): + rval = -1 + try: + rval = inlist.index(name) + except: + if printWarning: + print(name, " not in header line, file=", filename) + + return rval + +#---------------------------------------------- +def pointToInt(index, tokens, filename): + if index < 0 or index >= len(tokens): + print("ERROR index out of range ", index) + return -1 + return int(tokens[index]) + +#---------------------------------------------- +def pointToFloat(index, tokens, filename): + if index < 0 or index >= len(tokens): + print("ERROR index out of range ", index) + return -99.99 + return float(tokens[index]) + +#---------------------------------------------- +class StationHeader: + def __init__(self, headerLine, filename): + tokens = headerLine.split() + self._ok = True + self._idIndex = lookFor('BuoyID', tokens, filename, True) + self._yearIndex = lookFor('Year', tokens, filename, True) + self._hourIndex = lookFor('Hour', tokens, filename, True) + self._minuteIndex = lookFor('Min', tokens, filename, True) + self._doyIndex = lookFor('DOY', tokens, filename, True) + self._posdoyIndex = lookFor('POS_DOY', tokens, filename, True) + self._latIndex = lookFor('Lat', tokens, filename, True) + self._lonIndex = lookFor('Lon', tokens, filename, True) + self._bpIndex = lookFor('Lon', tokens, filename, False) + self._tsIndex = lookFor('Lon', tokens, filename, False) + self._taIndex = lookFor('Lon', tokens, filename, False) + self._ok = self._idIndex != -1 and self._yearIndex != -1 and self._hourIndex != -1 \ + and self._minuteIndex != -1 and self._doyIndex != -1 and self._posdoyIndex != -1 \ + and self._latIndex != -1 and self._lonIndex != -1 + if not self._ok: + print("ERROR badly formed header line") + +#---------------------------------------------- +class Station: + def __init__(self, line, filename, stationHeader): + self._ok = True + tokens = line.split() + self._id = pointToInt(stationHeader._idIndex, tokens, filename) + if self._id < 0: + self._ok = False + self._hour = pointToInt(stationHeader._hourIndex, tokens, filename) + if self._hour < 0: + self._ok = False + self._minute = pointToInt(stationHeader._minuteIndex, tokens, filename) + if self._minute < 0: + self._ok = False + self._doy = pointToFloat(stationHeader._doyIndex, tokens, filename) + if self._doy < 0: + self._ok = False + self._posdoy = pointToFloat(stationHeader._posdoyIndex, tokens, filename) + if self._posdoy < 0: + self._ok = False + self._lat = pointToFloat(stationHeader._latIndex, tokens, filename) + if self._lat == -99.99: + self._ok = False + self._lon = pointToFloat(stationHeader._lonIndex, tokens, filename) + if self._lon == -99.99: + self._ok = False + if stationHeader._bpIndex >= 0: + self._pressure = pointToFloat(stationHeader._bpIndex, tokens, filename) + else: + self._pressure = -99.99 + if stationHeader._tsIndex >= 0: + self._tempsurface = pointToFloat(stationHeader._tsIndex, tokens, filename) + else: + self._tempsurface = -99.99 + if stationHeader._taIndex >= 0: + self._tempair = pointToFloat(stationHeader._taIndex, tokens, filename) + else: + self._tempair = -99.99 + +#---------------------------------------------- +class StationTimeSeries: + def __init__(self, stationHeader): + self._stationHeader = stationHeader + self._data = [] + def add(self, line, filename): + s = Station(line, filename, self._stationHeader) + if s._ok: + self._data.append(s) + def print(self): + print("Nothing") + +#---------------------------------------------- +def doCmd(cmd, debug=False): + #print(cmd) + my_env = os.environ.copy() + args = shlex.split(cmd) + proc = Popen(args, stdout=PIPE, stderr=PIPE, env=my_env) + out, err = proc.communicate() + exitcode = proc.returncode + if exitcode == 0: + return str(out) + else: + if debug: + print("Command failed ", cmd) + return "" + +#---------------------------------------------- +def nextStation(data_all, index_all): + + index_all = data_all.find('.dat', index_all) + data = "" + if index_all == -1: + return -1, data + + #is this the weird (bad) .dat.dat situtation? + teststr = data_all[index_all:index_all+8] + if teststr == ".dat.dat": + indexend = data_all.find('.dat.dat<', index_all+1) + if indexend == -1: + print("Unexpected lack of .dat.dat<") + return -1, data + data = data_all[index_all+10:indexend+8] + else: + indexend = data_all.find('.dat<', index_all+1) + if indexend == -1: + print("UNexpected lack of .dat<") + return -1, data + data = data_all[index_all+6:indexend+4] + return indexend+10, data + +#---------------------------------------------- +def getStation(sfile): + cmd = "wget https://iabp.apl.uw.edu/WebData/" + sfile + print(cmd) + doCmd(cmd, True) + + # parse contents (not used for anything just yet) + with open(sfile, 'r') as file: + data_all = file.read() + file.close() + lines = data_all.splitlines() + + # first line is a header, remaining lines are a time series + sh = StationHeader(lines[0], sfile) + if sh._ok: + lines = lines[1:] + st = StationTimeSeries(sh) + for l in lines: + st.add(l, sfile) + + +#---------------------------------------------- +def run(output_path): + + cwd = os.getcwd() + + if (output_path[0:2] != "./" and output_path[0] != '/'): + outpath = "./" + output_path + else: + outpath = output_path + makeOrScrub(outpath, True) + os.chdir(outpath) + + cmd = "wget https://iabp.apl.uw.edu/WebData" + print(cmd) + s = doCmd(cmd, True) + if not s: + status = False + + stationfiles = [] + with open("WebData", 'r') as file: + data_all = file.read().replace('\n', '') + file.close() + index_all = 0 + while index_all < len(data_all): + index_all, data = nextStation(data_all, index_all) + if (index_all == -1): + break; + stationfiles.append(data) + + print("Parsed out ", len(stationfiles), " individual station files") + + # pull down all the station files + for i in range(len(stationfiles)): + getStation(stationfiles[i]) + + print("created ", len(stationfiles), " station files in ", outpath) + os.chdir(cwd) + +#---------------------------------------------- +def create_parser_options(parser): + parser.add_option("-o", "--output_path", dest="output_path", + default="./iabp_files", help=" create an output path or clear out what is there and put output files to that path (default: ./iabp_files)") + #parser.add_option("-H", "--Help", dest="options", action="store_true", default=False, help = " show usage information (optional, default = False)") + return parser.parse_args() + +#---------------------------------------------- +if __name__ == "__main__": + + usage_str = "%prog [options]" + parser = OptionParser(usage = usage_str) + options, args = create_parser_options(parser) + run(options.output_path) + exit(0) diff --git a/data/colortables/NCL_colortables/rgb2ctable.py b/scripts/python/utility/rgb2ctable.py old mode 100644 new mode 100755 similarity index 100% rename from data/colortables/NCL_colortables/rgb2ctable.py rename to scripts/python/utility/rgb2ctable.py diff --git a/src/basic/vx_config/builtin.cc b/src/basic/vx_config/builtin.cc index ed54d132b0..966db34858 100644 --- a/src/basic/vx_config/builtin.cc +++ b/src/basic/vx_config/builtin.cc @@ -75,54 +75,54 @@ static double my_C_to_F (double); const BuiltinInfo binfo[] = { - { "sin", 1, builtin_sin, nullptr, nullptr, sin, nullptr }, - { "cos", 1, builtin_cos, nullptr, nullptr, cos, nullptr }, - { "tan", 1, builtin_tan, nullptr, nullptr, tan, nullptr }, + { "sin", 1, Builtin::sin, nullptr, nullptr, sin, nullptr }, + { "cos", 1, Builtin::cos, nullptr, nullptr, cos, nullptr }, + { "tan", 1, Builtin::tan, nullptr, nullptr, tan, nullptr }, - { "sind", 1, builtin_sind, nullptr, nullptr, sin_deg, nullptr }, - { "cosd", 1, builtin_cosd, nullptr, nullptr, cos_deg, nullptr }, - { "tand", 1, builtin_tand, nullptr, nullptr, tan_deg, nullptr }, + { "sind", 1, Builtin::sind, nullptr, nullptr, sin_deg, nullptr }, + { "cosd", 1, Builtin::cosd, nullptr, nullptr, cos_deg, nullptr }, + { "tand", 1, Builtin::tand, nullptr, nullptr, tan_deg, nullptr }, - { "asin", 1, builtin_asin, nullptr, nullptr, asin, nullptr }, - { "acos", 1, builtin_acos, nullptr, nullptr, acos, nullptr }, - { "atan", 1, builtin_atan, nullptr, nullptr, atan, nullptr }, + { "asin", 1, Builtin::asin, nullptr, nullptr, asin, nullptr }, + { "acos", 1, Builtin::acos, nullptr, nullptr, acos, nullptr }, + { "atan", 1, Builtin::atan, nullptr, nullptr, atan, nullptr }, - { "asind", 1, builtin_sind, nullptr, nullptr, arc_sin_deg, nullptr }, - { "acosd", 1, builtin_cosd, nullptr, nullptr, arc_cos_deg, nullptr }, - { "atand", 1, builtin_tand, nullptr, nullptr, arc_tan_deg, nullptr }, + { "asind", 1, Builtin::sind, nullptr, nullptr, arc_sin_deg, nullptr }, + { "acosd", 1, Builtin::cosd, nullptr, nullptr, arc_cos_deg, nullptr }, + { "atand", 1, Builtin::tand, nullptr, nullptr, arc_tan_deg, nullptr }, - { "atan2", 2, builtin_atan2, nullptr, nullptr, nullptr, atan2 }, - { "atan2d", 2, builtin_atan2d, nullptr, nullptr, nullptr, atan2_deg }, + { "atan2", 2, Builtin::atan2, nullptr, nullptr, nullptr, atan2 }, + { "atan2d", 2, Builtin::atan2d, nullptr, nullptr, nullptr, atan2_deg }, - { "arg", 2, builtin_arg, nullptr, nullptr, nullptr, my_arg }, - { "argd", 2, builtin_argd, nullptr, nullptr, nullptr, my_arg_deg }, + { "arg", 2, Builtin::arg, nullptr, nullptr, nullptr, my_arg }, + { "argd", 2, Builtin::argd, nullptr, nullptr, nullptr, my_arg_deg }, - { "log", 1, builtin_log, nullptr, nullptr, log, nullptr }, - { "exp", 1, builtin_exp, nullptr, nullptr, exp, nullptr }, + { "log", 1, Builtin::log, nullptr, nullptr, log, nullptr }, + { "exp", 1, Builtin::exp, nullptr, nullptr, exp, nullptr }, - { "log10", 1, builtin_log10, nullptr, nullptr, log10, nullptr }, - { "exp10", 1, builtin_exp10, nullptr, nullptr, my_exp10, nullptr }, + { "log10", 1, Builtin::log10, nullptr, nullptr, log10, nullptr }, + { "exp10", 1, Builtin::exp10, nullptr, nullptr, my_exp10, nullptr }, - { "sqrt", 1, builtin_sqrt, nullptr, nullptr, sqrt, nullptr }, + { "sqrt", 1, Builtin::sqrt, nullptr, nullptr, sqrt, nullptr }, - { "abs", 1, builtin_abs, abs, nullptr, fabs, nullptr }, + { "abs", 1, Builtin::abs, abs, nullptr, fabs, nullptr }, - { "min", 2, builtin_min, nullptr, my_imin, nullptr, my_dmin }, - { "max", 2, builtin_max, nullptr, my_imax, nullptr, my_dmax }, + { "min", 2, Builtin::min, nullptr, my_imin, nullptr, my_dmin }, + { "max", 2, Builtin::max, nullptr, my_imax, nullptr, my_dmax }, - { "mod", 2, builtin_mod, nullptr, my_imod, nullptr, my_dmod }, + { "mod", 2, Builtin::mod, nullptr, my_imod, nullptr, my_dmod }, - { "floor", 1, builtin_floor, nullptr, nullptr, floor, nullptr }, - { "ceil", 1, builtin_ceil, nullptr, nullptr, ceil, nullptr }, + { "floor", 1, Builtin::floor, nullptr, nullptr, floor, nullptr }, + { "ceil", 1, Builtin::ceil, nullptr, nullptr, ceil, nullptr }, - { "step", 1, builtin_step, my_istep, nullptr, my_dstep, nullptr }, + { "step", 1, Builtin::step, my_istep, nullptr, my_dstep, nullptr }, // Functions defined in ConfigConstants - // { "F_to_C", 1, builtin_F_to_C, nullptr, nullptr, my_F_to_C, nullptr }, - // { "C_to_F", 1, builtin_C_to_F, nullptr, nullptr, my_C_to_F, nullptr }, + // { "F_to_C", 1, Builtin::F_to_C, nullptr, nullptr, my_F_to_C, nullptr }, + // { "C_to_F", 1, Builtin::C_to_F, nullptr, nullptr, my_C_to_F, nullptr }, - { "nint", 1, builtin_nint, nullptr, nullptr, nullptr, nullptr }, - { "sign", 1, builtin_sign, nullptr, nullptr, nullptr, nullptr }, + { "nint", 1, Builtin::nint, nullptr, nullptr, nullptr, nullptr }, + { "sign", 1, Builtin::sign, nullptr, nullptr, nullptr, nullptr }, // diff --git a/src/basic/vx_config/builtin.h b/src/basic/vx_config/builtin.h index d729e8a2a6..369ede5d09 100644 --- a/src/basic/vx_config/builtin.h +++ b/src/basic/vx_config/builtin.h @@ -30,69 +30,69 @@ static const int max_builtin_args = 2; //////////////////////////////////////////////////////////////////////// -enum Builtin { +enum class Builtin { // // built-in functions of one variable // - builtin_sin, - builtin_cos, - builtin_tan, + sin, + cos, + tan, - builtin_sind, - builtin_cosd, - builtin_tand, + sind, + cosd, + tand, - builtin_asin, - builtin_acos, - builtin_atan, + asin, + acos, + atan, - builtin_asind, - builtin_acosd, - builtin_atand, + asind, + acosd, + atand, - builtin_log, - builtin_exp, + log, + exp, - builtin_log10, - builtin_exp10, + log10, + exp10, - builtin_sqrt, - builtin_abs, - builtin_floor, - builtin_ceil, - builtin_nint, - builtin_sign, + sqrt, + abs, + floor, + ceil, + nint, + sign, - builtin_step, + step, // Functions defined in ConfigConstants - // builtin_F_to_C, - // builtin_C_to_F, + // F_to_C, + // C_to_F, // // built-in functions of two variables // - builtin_atan2, - builtin_atan2d, + atan2, + atan2d, - builtin_arg, - builtin_argd, + arg, + argd, - builtin_min, - builtin_max, + min, + max, - builtin_mod, + mod, // // built-in functions of three variables // - // builtin_ifte + // ifte // // flag value diff --git a/src/basic/vx_config/calculator.cc b/src/basic/vx_config/calculator.cc index 9b87fbbb74..1dbc427f4e 100644 --- a/src/basic/vx_config/calculator.cc +++ b/src/basic/vx_config/calculator.cc @@ -391,9 +391,9 @@ const BuiltinInfo & info = binfo[which]; // nint and sign are treated differently // -if ( info.id == builtin_nint ) { do_nint(); return; } +if ( info.id == Builtin::nint ) { do_nint(); return; } -if ( info.id == builtin_sign ) { do_sign(); return; } +if ( info.id == Builtin::sign ) { do_sign(); return; } // // diff --git a/src/basic/vx_config/config_constants.h b/src/basic/vx_config/config_constants.h index 56908edd31..deb9a425fe 100644 --- a/src/basic/vx_config/config_constants.h +++ b/src/basic/vx_config/config_constants.h @@ -25,10 +25,10 @@ // Enumeration for output_flag configuration parameter // -enum STATOutputType { - STATOutputType_None, // Do not output this line type - STATOutputType_Stat, // Write output to the .stat file - STATOutputType_Both // Write output to .stat and .txt files +enum class STATOutputType { + None, // Do not output this line type + Stat, // Write output to the .stat file + Both // Write output to .stat and .txt files }; //////////////////////////////////////////////////////////////////////// @@ -37,11 +37,11 @@ enum STATOutputType { // Enumeration for field type configuration parameters // -enum FieldType { - FieldType_None, // Default - FieldType_Fcst, // Apply to forecast field - FieldType_Obs, // Apply to observation field - FieldType_Both // Apply to both forecast and observation field +enum class FieldType { + None, // Default + Fcst, // Apply to forecast field + Obs, // Apply to observation field + Both // Apply to both forecast and observation field }; //////////////////////////////////////////////////////////////////////// @@ -50,11 +50,11 @@ enum FieldType { // Enumeration for set logic // -enum SetLogic { - SetLogic_None, // Default - SetLogic_Union, // Union - SetLogic_Intersection, // Intersection - SetLogic_SymDiff // Symmetric Difference +enum class SetLogic { + None, // Default + Union, // Union + Intersection, // Intersection + SymDiff // Symmetric Difference }; //////////////////////////////////////////////////////////////////////// @@ -77,11 +77,11 @@ static const char setlogic_symbol_symdiff[] = "*"; // Enumeration for track type configuration parameters // -enum TrackType { - TrackType_None, // Default - TrackType_ADeck, // Apply to ADeck tracks - TrackType_BDeck, // Apply to BDeck tracks - TrackType_Both // Apply to both ADeck and BDeck tracks +enum class TrackType { + None, // Default + ADeck, // Apply to ADeck tracks + BDeck, // Apply to BDeck tracks + Both // Apply to both ADeck and BDeck tracks }; //////////////////////////////////////////////////////////////////////// @@ -90,12 +90,12 @@ enum TrackType { // Enumeration for tropical cyclone diagnostic types // -enum DiagType { - DiagType_None, // Default - DiagType_CIRA_RT, // Realtime CIRA Tropical Cyclone Diagnostics - DiagType_CIRA_Dev, // Developmental CIRA Tropical Cyclone Diagnostics - DiagType_SHIPS_RT, // Realtime SHIPS Large Scale Diagnostics - DiagType_SHIPS_Dev // Developmental SHIPS Large Scale Diagnostics +enum class DiagType { + None, // Default + CIRA_RT, // Realtime CIRA Tropical Cyclone Diagnostics + CIRA_Dev, // Developmental CIRA Tropical Cyclone Diagnostics + SHIPS_RT, // Realtime SHIPS Large Scale Diagnostics + SHIPS_Dev // Developmental SHIPS Large Scale Diagnostics }; //////////////////////////////////////////////////////////////////////// @@ -117,10 +117,10 @@ static const char ships_diag_dev_str[] = "SHIPS_DIAG_DEV"; // Enumeration for 12-hour interpolation logic // -enum Interp12Type { - Interp12Type_None, // Do not apply 12-hour interpolation logic - Interp12Type_Fill, // Fill in missing 'I' tracks with '2' tracks - Interp12Type_Replace // Replace all 'I' tracks with '2' tracks +enum class Interp12Type { + None, // Do not apply 12-hour interpolation logic + Fill, // Fill in missing 'I' tracks with '2' tracks + Replace // Replace all 'I' tracks with '2' tracks }; //////////////////////////////////////////////////////////////////////// @@ -129,48 +129,48 @@ enum Interp12Type { // Enumeration for all the possible STAT line types // -enum STATLineType { - - stat_sl1l2, - stat_sal1l2, - stat_vl1l2, - stat_val1l2, - - stat_vcnt, - - stat_fho, - stat_ctc, - stat_cts, - stat_mctc, - stat_mcts, - stat_cnt, - stat_pct, - stat_pstd, - stat_pjc, - stat_prc, - stat_mpr, - stat_seeps, - stat_seeps_mpr, - stat_nbrctc, - stat_nbrcts, - stat_nbrcnt, - stat_isc, - stat_wdir, - stat_ecnt, - stat_rps, - stat_rhist, - stat_phist, - stat_orank, - stat_ssvar, - stat_relp, - stat_eclv, - stat_grad, - stat_dmap, - stat_genmpr, - stat_ssidx, - stat_header, - - no_stat_line_type +enum class STATLineType { + + sl1l2, + sal1l2, + vl1l2, + val1l2, + + vcnt, + + fho, + ctc, + cts, + mctc, + mcts, + cnt, + pct, + pstd, + pjc, + prc, + mpr, + seeps, + seeps_mpr, + nbrctc, + nbrcts, + nbrcnt, + isc, + wdir, + ecnt, + rps, + rhist, + phist, + orank, + ssvar, + relp, + eclv, + grad, + dmap, + genmpr, + ssidx, + header, + + none }; @@ -256,12 +256,14 @@ struct TimeSummaryInfo { // Enumeration for bootstrapping interval configuration parameter // -enum BootIntervalType { - BootIntervalType_None, // Default - BootIntervalType_BCA, // Bias-Corrected and adjusted method - BootIntervalType_Percentile // Percentile method +enum class BootIntervalType { + None, // Default + BCA, // Bias-Corrected and adjusted method + PCTile // Percentile method }; +//////////////////////////////////////////////////////////////////////// + // // Struct to store bootstrapping information // @@ -423,9 +425,9 @@ struct MaskLatLon { // Enumeration for duplicate_flag configuration parameter // -enum DuplicateType { - DuplicateType_None, // Apply no logic for duplicate point obs - DuplicateType_Unique // Filter out duplicate observation values +enum class DuplicateType { + None, // Apply no logic for duplicate point obs + Unique // Filter out duplicate observation values }; //////////////////////////////////////////////////////////////////////// @@ -434,15 +436,15 @@ enum DuplicateType { // Enumeration for obs_summary configuration parameter // -enum ObsSummary { - ObsSummary_None, // Keep all observations, no statistics - ObsSummary_Nearest, // Keep only the observation closest in time - ObsSummary_Min, // Keep only smallest value - ObsSummary_Max, // Keep only largest value - ObsSummary_UW_Mean, // Calculate un-weighted mean - ObsSummary_DW_Mean, // Calculate time weighted mean - ObsSummary_Median, // Calculate median - ObsSummary_Perc // Calculate precentile +enum class ObsSummary { + None, // Keep all observations, no statistics + Nearest, // Keep only the observation closest in time + Min, // Keep only smallest value + Max, // Keep only largest value + UW_Mean, // Calculate un-weighted mean + DW_Mean, // Calculate time weighted mean + Median, // Calculate median + Perc // Calculate precentile }; //////////////////////////////////////////////////////////////////////// @@ -451,10 +453,10 @@ enum ObsSummary { // Enumeration for grid_weight_flag configuration parameter // -enum GridWeightType { - GridWeightType_None, // Apply no grid box weighting - GridWeightType_Cos_Lat, // Apply cosine latitude weighting - GridWeightType_Area // Apply true grid box area weighting +enum class GridWeightType { + None, // Apply no grid box weighting + Cos_Lat, // Apply cosine latitude weighting + Area // Apply true grid box area weighting }; //////////////////////////////////////////////////////////////////////// @@ -463,11 +465,11 @@ enum GridWeightType { // Enumeration for grid_decomp_flag configuration parameter // -enum GridDecompType { - GridDecompType_None, // Default - GridDecompType_Auto, // Automatic tiling - GridDecompType_Tile, // User-specified tile definitions - GridDecompType_Pad // Pad out to next largest tile +enum class GridDecompType { + None, // Default + Auto, // Automatic tiling + Tile, // User-specified tile definitions + Pad // Pad out to next largest tile }; //////////////////////////////////////////////////////////////////////// @@ -476,14 +478,14 @@ enum GridDecompType { // Enumeration for wavelet.type configuration parameter // -enum WaveletType { - WaveletType_None, // Default - WaveletType_Haar, // Haar wavelet - WaveletType_Haar_Cntr, // Centered Haar wavelet - WaveletType_Daub, // Daubechies wavelet - WaveletType_Daub_Cntr, // Centered Daubechies wavelet - WaveletType_BSpline, // BSpline wavelet - WaveletType_BSpline_Cntr // Centered BSpline wavelet +enum class WaveletType { + None, // Default + Haar, // Haar wavelet + Haar_Cntr, // Centered Haar wavelet + Daub, // Daubechies wavelet + Daub_Cntr, // Centered Daubechies wavelet + BSpline, // BSpline wavelet + BSpline_Cntr // Centered BSpline wavelet }; //////////////////////////////////////////////////////////////////////// @@ -492,11 +494,11 @@ enum WaveletType { // Enumeration for MODE merging options // -enum MergeType { - MergeType_None, // No additional merging - MergeType_Both, // Double-threshold and fuzzy engine - MergeType_Thresh, // Double-threshold only - MergeType_Engine // Fuzzy engine only +enum class MergeType { + None, // No additional merging + Both, // Double-threshold and fuzzy engine + Thresh, // Double-threshold only + Engine // Fuzzy engine only }; //////////////////////////////////////////////////////////////////////// @@ -505,11 +507,11 @@ enum MergeType { // Enumeration for MODE matching options // -enum MatchType { - MatchType_None, // No matching - MatchType_MergeBoth, // Match with merging in both fcst and obs - MatchType_MergeFcst, // Match with merging in fcst only - MatchType_NoMerge // Match with no additional merging +enum class MatchType { + None, // No matching + MergeBoth, // Match with merging in both fcst and obs + MergeFcst, // Match with merging in fcst only + NoMerge // Match with no additional merging }; //////////////////////////////////////////////////////////////////////// @@ -1213,7 +1215,6 @@ static const char conf_key_nc_pairs_grid[] = "nc_pairs_grid"; static const char conf_key_n_range[] = "n_range"; static const char conf_key_n_azimuth[] = "n_azimuth"; -static const char conf_key_max_range[] = "max_range_km"; static const char conf_key_delta_range[] = "delta_range_km"; static const char conf_key_rmw_scale[] = "rmw_scale"; static const char conf_key_compute_tangential_and_radial_winds[] = "compute_tangential_and_radial_winds"; diff --git a/src/basic/vx_config/config_util.cc b/src/basic/vx_config/config_util.cc index a39bff6c39..344f997bea 100644 --- a/src/basic/vx_config/config_util.cc +++ b/src/basic/vx_config/config_util.cc @@ -13,6 +13,7 @@ #include #include "config_util.h" +#include "enum_as_int.hpp" #include "vx_math.h" #include "vx_util.h" @@ -121,13 +122,13 @@ void GaussianInfo::validate() { void RegridInfo::clear() { enable = false; - field = FieldType_None; + field = FieldType::None; vld_thresh = bad_data_double; name.clear(); - method = InterpMthd_None; + method = InterpMthd::None; width = bad_data_int; gaussian.clear(); - shape = GridTemplateFactory::GridTemplate_None; + shape = GridTemplateFactory::GridTemplates::None; convert_fx.clear(); censor_thresh.clear(); censor_val.clear(); @@ -144,10 +145,10 @@ RegridInfo::RegridInfo() { void RegridInfo::validate() { // Check for unsupported regridding options - if(method == InterpMthd_Best || - method == InterpMthd_Geog_Match || - method == InterpMthd_Gaussian || - method == InterpMthd_HiRA) { + if(method == InterpMthd::Best || + method == InterpMthd::Geog_Match || + method == InterpMthd::Gaussian || + method == InterpMthd::HiRA) { mlog << Error << "\nRegridInfo::validate() -> " << "\"" << interpmthd_to_string(method) << "\" not valid for regridding, only interpolating.\n\n"; @@ -156,31 +157,31 @@ void RegridInfo::validate() { // Check the nearest neighbor special case if(width == 1 && - method != InterpMthd_None && - method != InterpMthd_Nearest && - method != InterpMthd_Force && - method != InterpMthd_Upper_Left && - method != InterpMthd_Upper_Right && - method != InterpMthd_Lower_Right && - method != InterpMthd_Lower_Left && - method != InterpMthd_AW_Mean && - method != InterpMthd_MaxGauss) { + method != InterpMthd::None && + method != InterpMthd::Nearest && + method != InterpMthd::Force && + method != InterpMthd::Upper_Left && + method != InterpMthd::Upper_Right && + method != InterpMthd::Lower_Right && + method != InterpMthd::Lower_Left && + method != InterpMthd::AW_Mean && + method != InterpMthd::MaxGauss) { mlog << Warning << "\nRegridInfo::validate() -> " << "Resetting the regridding method from \"" << interpmthd_to_string(method) << "\" to \"" << interpmthd_nearest_str << "\" since the regridding width is 1.\n\n"; - method = InterpMthd_Nearest; + method = InterpMthd::Nearest; } // Check for some methods, that width is 1 - if((method == InterpMthd_Nearest || - method == InterpMthd_Force || - method == InterpMthd_Upper_Left || - method == InterpMthd_Upper_Right || - method == InterpMthd_Lower_Right || - method == InterpMthd_Lower_Left || - method == InterpMthd_AW_Mean) && + if((method == InterpMthd::Nearest || + method == InterpMthd::Force || + method == InterpMthd::Upper_Left || + method == InterpMthd::Upper_Right || + method == InterpMthd::Lower_Right || + method == InterpMthd::Lower_Left || + method == InterpMthd::AW_Mean) && width != 1) { mlog << Warning << "\nRegridInfo::validate() -> " << "Resetting regridding width from " @@ -190,8 +191,8 @@ void RegridInfo::validate() { } // Check the bilinear and budget special cases - if((method == InterpMthd_Bilin || - method == InterpMthd_Budget) && + if((method == InterpMthd::Bilin || + method == InterpMthd::Budget) && width != 2) { mlog << Warning << "\nRegridInfo::validate() -> " << "Resetting the regridding width from " @@ -201,7 +202,7 @@ void RegridInfo::validate() { } // Check the Gaussian filter - if(method == InterpMthd_MaxGauss && gaussian.radius < gaussian.dx) { + if(method == InterpMthd::MaxGauss && gaussian.radius < gaussian.dx) { mlog << Error << "\nRegridInfo::validate() -> " << "The radius of influence (" << gaussian.radius << ") is less than the delta distance (" << gaussian.dx @@ -226,20 +227,20 @@ void RegridInfo::validate() { void RegridInfo::validate_point() { // Check for unsupported regridding options - if(method != InterpMthd_Max && - method != InterpMthd_Min && - method != InterpMthd_Median && - method != InterpMthd_UW_Mean) { + if(method != InterpMthd::Max && + method != InterpMthd::Min && + method != InterpMthd::Median && + method != InterpMthd::UW_Mean) { mlog << Warning << "\nRegridInfo::validate_point() -> " << "Resetting the regridding method from \"" << interpmthd_to_string(method) << "\" to \"" << interpmthd_uw_mean_str << ".\n" << "\tAvailable methods: " - << interpmthd_to_string(InterpMthd_UW_Mean) << ", " - << interpmthd_to_string(InterpMthd_Max) << ", " - << interpmthd_to_string(InterpMthd_Min) << ", " - << interpmthd_to_string(InterpMthd_Median) << ".\n\n"; - method = InterpMthd_UW_Mean; + << interpmthd_to_string(InterpMthd::UW_Mean) << ", " + << interpmthd_to_string(InterpMthd::Max) << ", " + << interpmthd_to_string(InterpMthd::Min) << ", " + << interpmthd_to_string(InterpMthd::Median) << ".\n\n"; + method = InterpMthd::UW_Mean; } } @@ -264,6 +265,7 @@ RegridInfo &RegridInfo::operator=(const RegridInfo &a) noexcept { return *this; } + /////////////////////////////////////////////////////////////////////////////// ConcatString parse_conf_version(Dictionary *dict) { @@ -375,7 +377,7 @@ GrdFileType parse_conf_file_type(Dictionary *dict) { map parse_conf_output_flag(Dictionary *dict, const STATLineType *line_type, int n_lty) { map output_map; - STATOutputType t = STATOutputType_None; + STATOutputType t = STATOutputType::None; ConcatString cs; int v; @@ -397,9 +399,9 @@ map parse_conf_output_flag(Dictionary *dict, v = dict->lookup_int(cs.c_str()); // Convert integer to enumerated STATOutputType - if(v == conf_const.lookup_int(conf_val_none)) t = STATOutputType_None; - else if(v == conf_const.lookup_int(conf_val_stat)) t = STATOutputType_Stat; - else if(v == conf_const.lookup_int(conf_val_both)) t = STATOutputType_Both; + if(v == conf_const.lookup_int(conf_val_none)) t = STATOutputType::None; + else if(v == conf_const.lookup_int(conf_val_stat)) t = STATOutputType::Stat; + else if(v == conf_const.lookup_int(conf_val_both)) t = STATOutputType::Both; else { mlog << Error << "\nparse_conf_output_flag() -> " << "Unexpected config file value of " << v << " for \"" @@ -1259,7 +1261,7 @@ BootInfo & BootInfo::operator=(const BootInfo &a) noexcept { /////////////////////////////////////////////////////////////////////////////// void BootInfo::clear() { - interval = BootIntervalType_None; + interval = BootIntervalType::None; rep_prop = bad_data_double; n_rep = 0; rng.clear(); @@ -1283,8 +1285,12 @@ BootInfo parse_conf_boot(Dictionary *dict) { v = dict->lookup_int(conf_key_boot_interval); // Convert integer to enumerated BootIntervalType - if(v == conf_const.lookup_int(conf_val_bca)) info.interval = BootIntervalType_BCA; - else if(v == conf_const.lookup_int(conf_val_pctile)) info.interval = BootIntervalType_Percentile; + if(v == conf_const.lookup_int(conf_val_bca)) { + info.interval = BootIntervalType::BCA; + } + else if(v == conf_const.lookup_int(conf_val_pctile)) { + info.interval = BootIntervalType::PCTile; + } else { mlog << Error << "\nparse_conf_boot() -> " << "Unexpected config file value of " << v << " for \"" @@ -1360,8 +1366,8 @@ RegridInfo parse_conf_regrid(Dictionary *dict, bool error_out) { // If integer lookup successful, convert to FieldType. if(regrid_dict->last_lookup_status()) { info.field = int_to_fieldtype(v); - info.enable = (info.field == FieldType_Fcst || - info.field == FieldType_Obs); + info.enable = (info.field == FieldType::Fcst || + info.field == FieldType::Obs); } // If integer lookup unsuccessful, parse vx_grid as a string. // Do not error out since to_grid isn't specified for climo.regrid. @@ -1385,7 +1391,7 @@ RegridInfo parse_conf_regrid(Dictionary *dict, bool error_out) { } else { // If not specified, use the default square shape - info.shape = GridTemplateFactory::GridTemplate_Square; + info.shape = GridTemplateFactory::GridTemplates::Square; } // Conf: gaussian dx and radius @@ -1395,7 +1401,7 @@ RegridInfo parse_conf_regrid(Dictionary *dict, bool error_out) { info.gaussian.radius = (is_bad_data(conf_value) ? default_gaussian_radius : conf_value); conf_value = regrid_dict->lookup_double(conf_key_trunc_factor, false); info.gaussian.trunc_factor = (is_bad_data(conf_value) ? default_trunc_factor : conf_value); - if (info.method == InterpMthd_Gaussian || info.method == InterpMthd_MaxGauss) info.gaussian.compute(); + if (info.method == InterpMthd::Gaussian || info.method == InterpMthd::MaxGauss) info.gaussian.compute(); // MET#2437 Do not search the higher levels of config file context for convert, // censor_thresh, and censor_val. They must be specified within the @@ -1419,13 +1425,13 @@ RegridInfo parse_conf_regrid(Dictionary *dict, bool error_out) { /////////////////////////////////////////////////////////////////////////////// void InterpInfo::clear() { - field = FieldType_None; + field = FieldType::None; vld_thresh = bad_data_double; n_interp = 0; method.clear(); width.clear(); gaussian.clear(); - shape = GridTemplateFactory::GridTemplate_None; + shape = GridTemplateFactory::GridTemplates::None; } /////////////////////////////////////////////////////////////////////////////// @@ -1438,15 +1444,15 @@ void InterpInfo::validate() { // Check the nearest neighbor special case if(width[i] == 1 && - methodi != InterpMthd_None && - methodi != InterpMthd_Nearest && - methodi != InterpMthd_Force && - methodi != InterpMthd_Upper_Left && - methodi != InterpMthd_Upper_Right && - methodi != InterpMthd_Lower_Right && - methodi != InterpMthd_Lower_Left && - methodi != InterpMthd_Gaussian && - methodi != InterpMthd_MaxGauss) { + methodi != InterpMthd::None && + methodi != InterpMthd::Nearest && + methodi != InterpMthd::Force && + methodi != InterpMthd::Upper_Left && + methodi != InterpMthd::Upper_Right && + methodi != InterpMthd::Lower_Right && + methodi != InterpMthd::Lower_Left && + methodi != InterpMthd::Gaussian && + methodi != InterpMthd::MaxGauss) { mlog << Warning << "\nInterpInfo::validate() -> " << "Resetting interpolation method " << (int) i << " from \"" << method[i] << "\" to \"" @@ -1456,11 +1462,11 @@ void InterpInfo::validate() { } // Check for some methods, that width is 1 - if((methodi == InterpMthd_Nearest || - methodi == InterpMthd_Upper_Left || - methodi == InterpMthd_Upper_Right || - methodi == InterpMthd_Lower_Right || - methodi == InterpMthd_Lower_Left) && + if((methodi == InterpMthd::Nearest || + methodi == InterpMthd::Upper_Left || + methodi == InterpMthd::Upper_Right || + methodi == InterpMthd::Lower_Right || + methodi == InterpMthd::Lower_Left) && width[i] != 1) { mlog << Warning << "\nInterpInfo::validate() -> " << "Resetting interpolation width " << (int) i << " from " @@ -1470,8 +1476,8 @@ void InterpInfo::validate() { } // Check the bilinear and budget special cases - if((methodi == InterpMthd_Bilin || - methodi == InterpMthd_Budget) && + if((methodi == InterpMthd::Bilin || + methodi == InterpMthd::Budget) && width[i] != 2) { mlog << Warning << "\nInterpInfo::validate() -> " << "Resetting interpolation width " << (int) i << " from " @@ -1481,8 +1487,8 @@ void InterpInfo::validate() { } // Check the Gaussian filter - if(methodi == InterpMthd_Gaussian || - methodi == InterpMthd_MaxGauss) { + if(methodi == InterpMthd::Gaussian || + methodi == InterpMthd::MaxGauss) { if (gaussian.radius < gaussian.dx) { mlog << Error << "\n" << "The radius of influence (" << gaussian.radius @@ -1556,7 +1562,7 @@ InterpInfo parse_conf_interp(Dictionary *dict, const char *conf_key) { // If found, interpret value. Otherwise, set to a default value. if(interp_dict->last_lookup_status()) info.field = int_to_fieldtype(v); - else info.field = FieldType_None; + else info.field = FieldType::None; // Conf: vld_thresh double thr = interp_dict->lookup_double(conf_key_vld_thresh, false); @@ -1578,7 +1584,7 @@ InterpInfo parse_conf_interp(Dictionary *dict, const char *conf_key) { } else { // If not specified, use the default square shape - info.shape = GridTemplateFactory::GridTemplate_Square; + info.shape = GridTemplateFactory::GridTemplates::Square; } // Conf: gaussian dx and radius @@ -1632,8 +1638,8 @@ InterpInfo parse_conf_interp(Dictionary *dict, const char *conf_key) { method = int_to_interpmthd(mthd_na[j]); // Check for unsupported interpolation options - if(method == InterpMthd_Budget || - method == InterpMthd_Force) { + if(method == InterpMthd::Budget || + method == InterpMthd::Force) { mlog << Error << "\nparse_conf_interp() -> " << "\"" << interpmthd_to_string(method) << "\" not valid for interpolating, only regridding.\n\n"; @@ -1653,7 +1659,7 @@ InterpInfo parse_conf_interp(Dictionary *dict, const char *conf_key) { } // end for k - if(method == InterpMthd_Gaussian || method == InterpMthd_MaxGauss) { + if(method == InterpMthd::Gaussian || method == InterpMthd::MaxGauss) { info.gaussian.compute(); } } // end for j @@ -1844,11 +1850,11 @@ ClimoCDFInfo parse_conf_climo_cdf(Dictionary *dict) { void NbrhdInfo::clear() { - field = FieldType_None; + field = FieldType::None; vld_thresh = bad_data_double; width.clear(); cov_ta.clear(); - shape = GridTemplateFactory::GridTemplate_None; + shape = GridTemplateFactory::GridTemplates::None; } /////////////////////////////////////////////////////////////////////////////// @@ -1885,7 +1891,7 @@ NbrhdInfo parse_conf_nbrhd(Dictionary *dict, const char *conf_key) { // Conf: field - may be missing // Default info.field to BOTH - info.field = FieldType_Both; + info.field = FieldType::Both; // Skip lookup for conf_key_nbrhd_prob if(strncmp(conf_key, conf_key_nbrhd_prob, strlen(conf_key_nbrhd_prob)) != 0) { @@ -1936,7 +1942,7 @@ NbrhdInfo parse_conf_nbrhd(Dictionary *dict, const char *conf_key) { } else { // If not specified, use the default square shape - info.shape = GridTemplateFactory::GridTemplate_Square; + info.shape = GridTemplateFactory::GridTemplates::Square; } // Conf: cov_thresh @@ -1966,7 +1972,7 @@ void HiRAInfo::clear() { vld_thresh = bad_data_double; cov_ta.clear(); prob_cat_ta.clear(); - shape = GridTemplateFactory::GridTemplate_None; + shape = GridTemplateFactory::GridTemplates::None; } /////////////////////////////////////////////////////////////////////////////// @@ -2052,7 +2058,7 @@ HiRAInfo parse_conf_hira(Dictionary *dict) { } else { // If not specified, use the default square shape - info.shape = GridTemplateFactory::GridTemplate_Square; + info.shape = GridTemplateFactory::GridTemplates::Square; } // Conf: cov_thresh @@ -2073,7 +2079,7 @@ HiRAInfo parse_conf_hira(Dictionary *dict) { /////////////////////////////////////////////////////////////////////////////// GridWeightType parse_conf_grid_weight_flag(Dictionary *dict) { - GridWeightType t = GridWeightType_None; + GridWeightType t = GridWeightType::None; int v; if(!dict) { @@ -2086,9 +2092,9 @@ GridWeightType parse_conf_grid_weight_flag(Dictionary *dict) { v = dict->lookup_int(conf_key_grid_weight_flag); // Convert integer to enumerated GridWeightType - if(v == conf_const.lookup_int(conf_val_none)) t = GridWeightType_None; - else if(v == conf_const.lookup_int(conf_val_cos_lat)) t = GridWeightType_Cos_Lat; - else if(v == conf_const.lookup_int(conf_val_area)) t = GridWeightType_Area; + if(v == conf_const.lookup_int(conf_val_none)) t = GridWeightType::None; + else if(v == conf_const.lookup_int(conf_val_cos_lat)) t = GridWeightType::Cos_Lat; + else if(v == conf_const.lookup_int(conf_val_area)) t = GridWeightType::Area; else { mlog << Error << "\nparse_conf_grid_weight_flag() -> " << "Unexpected config file value of " << v << " for \"" @@ -2102,7 +2108,7 @@ GridWeightType parse_conf_grid_weight_flag(Dictionary *dict) { /////////////////////////////////////////////////////////////////////////////// DuplicateType parse_conf_duplicate_flag(Dictionary *dict) { - DuplicateType t = DuplicateType_None; + DuplicateType t = DuplicateType::None; int v; if(!dict) { @@ -2115,8 +2121,8 @@ DuplicateType parse_conf_duplicate_flag(Dictionary *dict) { v = dict->lookup_int(conf_key_duplicate_flag); // Convert integer to enumerated DuplicateType - if(v == conf_const.lookup_int(conf_val_none)) t = DuplicateType_None; - else if(v == conf_const.lookup_int(conf_val_unique)) t = DuplicateType_Unique; + if(v == conf_const.lookup_int(conf_val_none)) t = DuplicateType::None; + else if(v == conf_const.lookup_int(conf_val_unique)) t = DuplicateType::Unique; else if(v == conf_const.lookup_int(conf_val_single)) { mlog << Error << "\nparse_conf_duplicate_flag() -> " << "duplicate_flag = SINGLE has been deprecated\n" @@ -2136,7 +2142,7 @@ DuplicateType parse_conf_duplicate_flag(Dictionary *dict) { /////////////////////////////////////////////////////////////////////////////// ObsSummary parse_conf_obs_summary(Dictionary *dict) { - ObsSummary t = ObsSummary_None; + ObsSummary t = ObsSummary::None; int v; if(!dict) { @@ -2149,14 +2155,14 @@ ObsSummary parse_conf_obs_summary(Dictionary *dict) { v = dict->lookup_int(conf_key_obs_summary); // Convert integer to enumerated ObsSummary - if(v == conf_const.lookup_int(conf_val_none)) t = ObsSummary_None; - else if(v == conf_const.lookup_int(conf_val_nearest)) t = ObsSummary_Nearest; - else if(v == conf_const.lookup_int(conf_val_min)) t = ObsSummary_Min; - else if(v == conf_const.lookup_int(conf_val_max)) t = ObsSummary_Max; - else if(v == conf_const.lookup_int(conf_val_uw_mean)) t = ObsSummary_UW_Mean; - else if(v == conf_const.lookup_int(conf_val_dw_mean)) t = ObsSummary_DW_Mean; - else if(v == conf_const.lookup_int(conf_val_median)) t = ObsSummary_Median; - else if(v == conf_const.lookup_int(conf_val_perc)) t = ObsSummary_Perc; + if(v == conf_const.lookup_int(conf_val_none)) t = ObsSummary::None; + else if(v == conf_const.lookup_int(conf_val_nearest)) t = ObsSummary::Nearest; + else if(v == conf_const.lookup_int(conf_val_min)) t = ObsSummary::Min; + else if(v == conf_const.lookup_int(conf_val_max)) t = ObsSummary::Max; + else if(v == conf_const.lookup_int(conf_val_uw_mean)) t = ObsSummary::UW_Mean; + else if(v == conf_const.lookup_int(conf_val_dw_mean)) t = ObsSummary::DW_Mean; + else if(v == conf_const.lookup_int(conf_val_median)) t = ObsSummary::Median; + else if(v == conf_const.lookup_int(conf_val_perc)) t = ObsSummary::Perc; else { mlog << Error << "\nparse_conf_obs_summary() -> " << "Unexpected config file value of " << v << " for \"" @@ -2225,7 +2231,7 @@ ConcatString parse_conf_tmp_dir(Dictionary *dict) { /////////////////////////////////////////////////////////////////////////////// GridDecompType parse_conf_grid_decomp_flag(Dictionary *dict) { - GridDecompType t = GridDecompType_None; + GridDecompType t = GridDecompType::None; int v; if(!dict) { @@ -2238,10 +2244,10 @@ GridDecompType parse_conf_grid_decomp_flag(Dictionary *dict) { v = dict->lookup_int(conf_key_grid_decomp_flag); // Convert integer to enumerated GridDecompType - if(v == conf_const.lookup_int(conf_val_none)) t = GridDecompType_None; - else if(v == conf_const.lookup_int(conf_val_auto)) t = GridDecompType_Auto; - else if(v == conf_const.lookup_int(conf_val_tile)) t = GridDecompType_Tile; - else if(v == conf_const.lookup_int(conf_val_pad)) t = GridDecompType_Pad; + if(v == conf_const.lookup_int(conf_val_none)) t = GridDecompType::None; + else if(v == conf_const.lookup_int(conf_val_auto)) t = GridDecompType::Auto; + else if(v == conf_const.lookup_int(conf_val_tile)) t = GridDecompType::Tile; + else if(v == conf_const.lookup_int(conf_val_pad)) t = GridDecompType::Pad; else { mlog << Error << "\nparse_conf_grid_decomp_flag() -> " << "Unexpected config file value of " << v << " for \"" @@ -2255,7 +2261,7 @@ GridDecompType parse_conf_grid_decomp_flag(Dictionary *dict) { /////////////////////////////////////////////////////////////////////////////// WaveletType parse_conf_wavelet_type(Dictionary *dict) { - WaveletType t = WaveletType_None; + WaveletType t = WaveletType::None; int v; if(!dict) { @@ -2268,13 +2274,13 @@ WaveletType parse_conf_wavelet_type(Dictionary *dict) { v = dict->lookup_int(conf_key_wavelet_type); // Convert integer to enumerated WaveletType - if(v == conf_const.lookup_int(conf_val_none)) t = WaveletType_None; - else if(v == conf_const.lookup_int(conf_val_haar)) t = WaveletType_Haar; - else if(v == conf_const.lookup_int(conf_val_haar_cntr)) t = WaveletType_Haar_Cntr; - else if(v == conf_const.lookup_int(conf_val_daub)) t = WaveletType_Daub; - else if(v == conf_const.lookup_int(conf_val_daub_cntr)) t = WaveletType_Daub_Cntr; - else if(v == conf_const.lookup_int(conf_val_bspline)) t = WaveletType_BSpline; - else if(v == conf_const.lookup_int(conf_val_bspline_cntr)) t = WaveletType_BSpline_Cntr; + if(v == conf_const.lookup_int(conf_val_none)) t = WaveletType::None; + else if(v == conf_const.lookup_int(conf_val_haar)) t = WaveletType::Haar; + else if(v == conf_const.lookup_int(conf_val_haar_cntr)) t = WaveletType::Haar_Cntr; + else if(v == conf_const.lookup_int(conf_val_daub)) t = WaveletType::Daub; + else if(v == conf_const.lookup_int(conf_val_daub_cntr)) t = WaveletType::Daub_Cntr; + else if(v == conf_const.lookup_int(conf_val_bspline)) t = WaveletType::BSpline; + else if(v == conf_const.lookup_int(conf_val_bspline_cntr)) t = WaveletType::BSpline_Cntr; else { mlog << Error << "\nparse_conf_wavelet_type() -> " << "Unexpected config file value of " << v << " for \"" @@ -2539,30 +2545,30 @@ void check_climo_n_vx(Dictionary *dict, const int n_vx) { /////////////////////////////////////////////////////////////////////////////// InterpMthd int_to_interpmthd(int i) { - InterpMthd m = InterpMthd_None; - - if(i == conf_const.lookup_int(interpmthd_none_str)) m = InterpMthd_None; - else if(i == conf_const.lookup_int(interpmthd_min_str)) m = InterpMthd_Min; - else if(i == conf_const.lookup_int(interpmthd_max_str)) m = InterpMthd_Max; - else if(i == conf_const.lookup_int(interpmthd_median_str)) m = InterpMthd_Median; - else if(i == conf_const.lookup_int(interpmthd_uw_mean_str)) m = InterpMthd_UW_Mean; - else if(i == conf_const.lookup_int(interpmthd_dw_mean_str)) m = InterpMthd_DW_Mean; - else if(i == conf_const.lookup_int(interpmthd_aw_mean_str)) m = InterpMthd_AW_Mean; - else if(i == conf_const.lookup_int(interpmthd_ls_fit_str)) m = InterpMthd_LS_Fit; - else if(i == conf_const.lookup_int(interpmthd_bilin_str)) m = InterpMthd_Bilin; - else if(i == conf_const.lookup_int(interpmthd_nbrhd_str)) m = InterpMthd_Nbrhd; - else if(i == conf_const.lookup_int(interpmthd_nearest_str)) m = InterpMthd_Nearest; - else if(i == conf_const.lookup_int(interpmthd_budget_str)) m = InterpMthd_Budget; - else if(i == conf_const.lookup_int(interpmthd_force_str)) m = InterpMthd_Force; - else if(i == conf_const.lookup_int(interpmthd_best_str)) m = InterpMthd_Best; - else if(i == conf_const.lookup_int(interpmthd_upper_left_str)) m = InterpMthd_Upper_Left; - else if(i == conf_const.lookup_int(interpmthd_upper_right_str)) m = InterpMthd_Upper_Right; - else if(i == conf_const.lookup_int(interpmthd_lower_right_str)) m = InterpMthd_Lower_Right; - else if(i == conf_const.lookup_int(interpmthd_lower_left_str)) m = InterpMthd_Lower_Left; - else if(i == conf_const.lookup_int(interpmthd_gaussian_str)) m = InterpMthd_Gaussian; - else if(i == conf_const.lookup_int(interpmthd_maxgauss_str)) m = InterpMthd_MaxGauss; - else if(i == conf_const.lookup_int(interpmthd_geog_match_str)) m = InterpMthd_Geog_Match; - else if(i == conf_const.lookup_int(interpmthd_hira_str)) m = InterpMthd_HiRA; + InterpMthd m = InterpMthd::None; + + if(i == conf_const.lookup_int(interpmthd_none_str)) m = InterpMthd::None; + else if(i == conf_const.lookup_int(interpmthd_min_str)) m = InterpMthd::Min; + else if(i == conf_const.lookup_int(interpmthd_max_str)) m = InterpMthd::Max; + else if(i == conf_const.lookup_int(interpmthd_median_str)) m = InterpMthd::Median; + else if(i == conf_const.lookup_int(interpmthd_uw_mean_str)) m = InterpMthd::UW_Mean; + else if(i == conf_const.lookup_int(interpmthd_dw_mean_str)) m = InterpMthd::DW_Mean; + else if(i == conf_const.lookup_int(interpmthd_aw_mean_str)) m = InterpMthd::AW_Mean; + else if(i == conf_const.lookup_int(interpmthd_ls_fit_str)) m = InterpMthd::LS_Fit; + else if(i == conf_const.lookup_int(interpmthd_bilin_str)) m = InterpMthd::Bilin; + else if(i == conf_const.lookup_int(interpmthd_nbrhd_str)) m = InterpMthd::Nbrhd; + else if(i == conf_const.lookup_int(interpmthd_nearest_str)) m = InterpMthd::Nearest; + else if(i == conf_const.lookup_int(interpmthd_budget_str)) m = InterpMthd::Budget; + else if(i == conf_const.lookup_int(interpmthd_force_str)) m = InterpMthd::Force; + else if(i == conf_const.lookup_int(interpmthd_best_str)) m = InterpMthd::Best; + else if(i == conf_const.lookup_int(interpmthd_upper_left_str)) m = InterpMthd::Upper_Left; + else if(i == conf_const.lookup_int(interpmthd_upper_right_str)) m = InterpMthd::Upper_Right; + else if(i == conf_const.lookup_int(interpmthd_lower_right_str)) m = InterpMthd::Lower_Right; + else if(i == conf_const.lookup_int(interpmthd_lower_left_str)) m = InterpMthd::Lower_Left; + else if(i == conf_const.lookup_int(interpmthd_gaussian_str)) m = InterpMthd::Gaussian; + else if(i == conf_const.lookup_int(interpmthd_maxgauss_str)) m = InterpMthd::MaxGauss; + else if(i == conf_const.lookup_int(interpmthd_geog_match_str)) m = InterpMthd::Geog_Match; + else if(i == conf_const.lookup_int(interpmthd_hira_str)) m = InterpMthd::HiRA; else { mlog << Error << "\nconf_int_to_interpmthd() -> " << "Unexpected value of " << i @@ -2605,52 +2611,52 @@ const char * statlinetype_to_string(const STATLineType t) { const char *s = (const char *) nullptr; switch(t) { - case(stat_sl1l2): s = stat_sl1l2_str; break; - case(stat_sal1l2): s = stat_sal1l2_str; break; - case(stat_vl1l2): s = stat_vl1l2_str; break; - case(stat_val1l2): s = stat_val1l2_str; break; - case(stat_vcnt): s = stat_vcnt_str; break; - - case(stat_fho): s = stat_fho_str; break; - case(stat_ctc): s = stat_ctc_str; break; - case(stat_cts): s = stat_cts_str; break; - case(stat_mctc): s = stat_mctc_str; break; - case(stat_mcts): s = stat_mcts_str; break; - - case(stat_cnt): s = stat_cnt_str; break; - case(stat_pct): s = stat_pct_str; break; - case(stat_pstd): s = stat_pstd_str; break; - case(stat_pjc): s = stat_pjc_str; break; - case(stat_prc): s = stat_prc_str; break; - - case(stat_eclv): s = stat_eclv_str; break; - case(stat_mpr): s = stat_mpr_str; break; - case(stat_seeps): s = stat_seeps_str; break; - case(stat_seeps_mpr): s = stat_seeps_mpr_str; break; - case(stat_nbrctc): s = stat_nbrctc_str; break; - - case(stat_nbrcts): s = stat_nbrcts_str; break; - case(stat_nbrcnt): s = stat_nbrcnt_str; break; - case(stat_grad): s = stat_grad_str; break; - case(stat_dmap): s = stat_dmap_str; break; - case(stat_isc): s = stat_isc_str; break; - - case(stat_wdir): s = stat_wdir_str; break; - case(stat_ecnt): s = stat_ecnt_str; break; - case(stat_rps): s = stat_rps_str; break; - case(stat_rhist): s = stat_rhist_str; break; - case(stat_phist): s = stat_phist_str; break; - - case(stat_orank): s = stat_orank_str; break; - case(stat_ssvar): s = stat_ssvar_str; break; - case(stat_relp): s = stat_relp_str; break; - case(stat_genmpr): s = stat_genmpr_str; break; - case(stat_ssidx): s = stat_ssidx_str; break; + case STATLineType::sl1l2: s = stat_sl1l2_str; break; + case STATLineType::sal1l2: s = stat_sal1l2_str; break; + case STATLineType::vl1l2: s = stat_vl1l2_str; break; + case STATLineType::val1l2: s = stat_val1l2_str; break; + case STATLineType::vcnt: s = stat_vcnt_str; break; + + case STATLineType::fho: s = stat_fho_str; break; + case STATLineType::ctc: s = stat_ctc_str; break; + case STATLineType::cts: s = stat_cts_str; break; + case STATLineType::mctc: s = stat_mctc_str; break; + case STATLineType::mcts: s = stat_mcts_str; break; + + case STATLineType::cnt: s = stat_cnt_str; break; + case STATLineType::pct: s = stat_pct_str; break; + case STATLineType::pstd: s = stat_pstd_str; break; + case STATLineType::pjc: s = stat_pjc_str; break; + case STATLineType::prc: s = stat_prc_str; break; + + case STATLineType::eclv: s = stat_eclv_str; break; + case STATLineType::mpr: s = stat_mpr_str; break; + case STATLineType::seeps: s = stat_seeps_str; break; + case STATLineType::seeps_mpr: s = stat_seeps_mpr_str; break; + case STATLineType::nbrctc: s = stat_nbrctc_str; break; + + case STATLineType::nbrcts: s = stat_nbrcts_str; break; + case STATLineType::nbrcnt: s = stat_nbrcnt_str; break; + case STATLineType::grad: s = stat_grad_str; break; + case STATLineType::dmap: s = stat_dmap_str; break; + case STATLineType::isc: s = stat_isc_str; break; + + case STATLineType::wdir: s = stat_wdir_str; break; + case STATLineType::ecnt: s = stat_ecnt_str; break; + case STATLineType::rps: s = stat_rps_str; break; + case STATLineType::rhist: s = stat_rhist_str; break; + case STATLineType::phist: s = stat_phist_str; break; + + case STATLineType::orank: s = stat_orank_str; break; + case STATLineType::ssvar: s = stat_ssvar_str; break; + case STATLineType::relp: s = stat_relp_str; break; + case STATLineType::genmpr: s = stat_genmpr_str; break; + case STATLineType::ssidx: s = stat_ssidx_str; break; - case(stat_header): s = stat_header_str; break; + case STATLineType::header: s = stat_header_str; break; - case(no_stat_line_type): - default: s = stat_na_str; break; + /*case STATLineType::none:*/ + default: s = stat_na_str; break; } return s; @@ -2671,51 +2677,77 @@ void statlinetype_to_string(const STATLineType t, char *out) { STATLineType string_to_statlinetype(const char *s) { STATLineType t; - if(strcasecmp(s, stat_sl1l2_str) == 0) t = stat_sl1l2; - else if(strcasecmp(s, stat_sal1l2_str) == 0) t = stat_sal1l2; - else if(strcasecmp(s, stat_vl1l2_str) == 0) t = stat_vl1l2; - else if(strcasecmp(s, stat_val1l2_str) == 0) t = stat_val1l2; - else if(strcasecmp(s, stat_vcnt_str) == 0) t = stat_vcnt; - - else if(strcasecmp(s, stat_fho_str) == 0) t = stat_fho; - else if(strcasecmp(s, stat_ctc_str) == 0) t = stat_ctc; - else if(strcasecmp(s, stat_cts_str) == 0) t = stat_cts; - else if(strcasecmp(s, stat_mctc_str) == 0) t = stat_mctc; - else if(strcasecmp(s, stat_mcts_str) == 0) t = stat_mcts; - - else if(strcasecmp(s, stat_cnt_str) == 0) t = stat_cnt; - else if(strcasecmp(s, stat_pct_str) == 0) t = stat_pct; - else if(strcasecmp(s, stat_pstd_str) == 0) t = stat_pstd; - else if(strcasecmp(s, stat_pjc_str) == 0) t = stat_pjc; - else if(strcasecmp(s, stat_prc_str) == 0) t = stat_prc; - - else if(strcasecmp(s, stat_eclv_str) == 0) t = stat_eclv; - else if(strcasecmp(s, stat_mpr_str) == 0) t = stat_mpr; - else if(strcasecmp(s, stat_seeps_str) == 0) t = stat_seeps; - else if(strcasecmp(s, stat_seeps_mpr_str) == 0) t = stat_seeps_mpr; - else if(strcasecmp(s, stat_nbrctc_str) == 0) t = stat_nbrctc; - - else if(strcasecmp(s, stat_nbrcts_str) == 0) t = stat_nbrcts; - else if(strcasecmp(s, stat_nbrcnt_str) == 0) t = stat_nbrcnt; - else if(strcasecmp(s, stat_grad_str) == 0) t = stat_grad; - else if(strcasecmp(s, stat_dmap_str) == 0) t = stat_dmap; - else if(strcasecmp(s, stat_isc_str) == 0) t = stat_isc; - - else if(strcasecmp(s, stat_wdir_str) == 0) t = stat_wdir; - else if(strcasecmp(s, stat_ecnt_str) == 0) t = stat_ecnt; - else if(strcasecmp(s, stat_rps_str) == 0) t = stat_rps; - else if(strcasecmp(s, stat_rhist_str) == 0) t = stat_rhist; - else if(strcasecmp(s, stat_phist_str) == 0) t = stat_phist; - - else if(strcasecmp(s, stat_orank_str) == 0) t = stat_orank; - else if(strcasecmp(s, stat_ssvar_str) == 0) t = stat_ssvar; - else if(strcasecmp(s, stat_relp_str) == 0) t = stat_relp; - else if(strcasecmp(s, stat_genmpr_str) == 0) t = stat_genmpr; - else if(strcasecmp(s, stat_ssidx_str) == 0) t = stat_ssidx; - - else if(strcasecmp(s, stat_header_str) == 0) t = stat_header; - - else t = no_stat_line_type; + if(strcasecmp(s, stat_sl1l2_str) == 0) t = STATLineType::sl1l2; + else if(strcasecmp(s, stat_sal1l2_str) == 0) t = STATLineType::sal1l2; + else if(strcasecmp(s, stat_vl1l2_str) == 0) t = STATLineType::vl1l2; + else if(strcasecmp(s, stat_val1l2_str) == 0) t = STATLineType::val1l2; + else if(strcasecmp(s, stat_vcnt_str) == 0) t = STATLineType::vcnt; + + else if(strcasecmp(s, stat_fho_str) == 0) t = STATLineType::fho; + else if(strcasecmp(s, stat_ctc_str) == 0) t = STATLineType::ctc; + else if(strcasecmp(s, stat_cts_str) == 0) t = STATLineType::cts; + else if(strcasecmp(s, stat_mctc_str) == 0) t = STATLineType::mctc; + else if(strcasecmp(s, stat_mcts_str) == 0) t = STATLineType::mcts; + + else if(strcasecmp(s, stat_cnt_str) == 0) t = STATLineType::cnt; + else if(strcasecmp(s, stat_pct_str) == 0) t = STATLineType::pct; + else if(strcasecmp(s, stat_pstd_str) == 0) t = STATLineType::pstd; + else if(strcasecmp(s, stat_pjc_str) == 0) t = STATLineType::pjc; + else if(strcasecmp(s, stat_prc_str) == 0) t = STATLineType::prc; + + else if(strcasecmp(s, stat_eclv_str) == 0) t = STATLineType::eclv; + else if(strcasecmp(s, stat_mpr_str) == 0) t = STATLineType::mpr; + else if(strcasecmp(s, stat_seeps_str) == 0) t = STATLineType::seeps; + else if(strcasecmp(s, stat_seeps_mpr_str) == 0) t = STATLineType::seeps_mpr; + else if(strcasecmp(s, stat_nbrctc_str) == 0) t = STATLineType::nbrctc; + + else if(strcasecmp(s, stat_nbrcts_str) == 0) t = STATLineType::nbrcts; + else if(strcasecmp(s, stat_nbrcnt_str) == 0) t = STATLineType::nbrcnt; + else if(strcasecmp(s, stat_grad_str) == 0) t = STATLineType::grad; + else if(strcasecmp(s, stat_dmap_str) == 0) t = STATLineType::dmap; + else if(strcasecmp(s, stat_isc_str) == 0) t = STATLineType::isc; + + else if(strcasecmp(s, stat_wdir_str) == 0) t = STATLineType::wdir; + else if(strcasecmp(s, stat_ecnt_str) == 0) t = STATLineType::ecnt; + else if(strcasecmp(s, stat_rps_str) == 0) t = STATLineType::rps; + else if(strcasecmp(s, stat_rhist_str) == 0) t = STATLineType::rhist; + else if(strcasecmp(s, stat_phist_str) == 0) t = STATLineType::phist; + + else if(strcasecmp(s, stat_orank_str) == 0) t = STATLineType::orank; + else if(strcasecmp(s, stat_ssvar_str) == 0) t = STATLineType::ssvar; + else if(strcasecmp(s, stat_relp_str) == 0) t = STATLineType::relp; + else if(strcasecmp(s, stat_genmpr_str) == 0) t = STATLineType::genmpr; + else if(strcasecmp(s, stat_ssidx_str) == 0) t = STATLineType::ssidx; + + else if(strcasecmp(s, stat_header_str) == 0) t = STATLineType::header; + + else t = STATLineType::none; + + return t; +} + +/////////////////////////////////////////////////////////////////////////////// + +const char * bootintervaltype_to_string(const BootIntervalType t) { + auto s = (const char *) nullptr; + + switch(t) { + case BootIntervalType::BCA: s = conf_val_bca; break; + case BootIntervalType::PCTile: s = conf_val_pctile; break; + default: s = conf_val_none; break; + } + + return s; +} + +/////////////////////////////////////////////////////////////////////////////// + +BootIntervalType string_to_bootintervaltype(const char *s) { + BootIntervalType t; + + if(strcasecmp(s, conf_val_bca) == 0) t = BootIntervalType::BCA; + else if(strcasecmp(s, conf_val_pctile) == 0) t = BootIntervalType::PCTile; + else t = BootIntervalType::None; return t; } @@ -2723,13 +2755,13 @@ STATLineType string_to_statlinetype(const char *s) { /////////////////////////////////////////////////////////////////////////////// FieldType int_to_fieldtype(int v) { - FieldType t = FieldType_None; + FieldType t = FieldType::None; // Convert integer to enumerated FieldType - if(v == conf_const.lookup_int(conf_val_none)) t = FieldType_None; - else if(v == conf_const.lookup_int(conf_val_both)) t = FieldType_Both; - else if(v == conf_const.lookup_int(conf_val_fcst)) t = FieldType_Fcst; - else if(v == conf_const.lookup_int(conf_val_obs)) t = FieldType_Obs; + if(v == conf_const.lookup_int(conf_val_none)) t = FieldType::None; + else if(v == conf_const.lookup_int(conf_val_both)) t = FieldType::Both; + else if(v == conf_const.lookup_int(conf_val_fcst)) t = FieldType::Fcst; + else if(v == conf_const.lookup_int(conf_val_obs)) t = FieldType::Obs; else { mlog << Error << "\nint_to_fieldtype() -> " << "Unexpected value of " << v << ".\n\n"; @@ -2742,14 +2774,14 @@ FieldType int_to_fieldtype(int v) { /////////////////////////////////////////////////////////////////////////////// GridTemplateFactory::GridTemplates int_to_gridtemplate(int v) { - GridTemplateFactory::GridTemplates t = GridTemplateFactory::GridTemplate_Square; + GridTemplateFactory::GridTemplates t = GridTemplateFactory::GridTemplates::Square; // Convert integer to enumerated FieldType if(v == conf_const.lookup_int(conf_val_square)) { - t = GridTemplateFactory::GridTemplate_Square; + t = GridTemplateFactory::GridTemplates::Square; } else if(v == conf_const.lookup_int(conf_val_circle)) { - t = GridTemplateFactory::GridTemplate_Circle; + t = GridTemplateFactory::GridTemplates::Circle; } else { mlog << Error << "\nint_to_gridtemplate() -> " @@ -2767,13 +2799,13 @@ ConcatString fieldtype_to_string(FieldType type) { // Convert enumerated FieldType to string switch(type) { - case(FieldType_None): s = conf_val_none; break; - case(FieldType_Both): s = conf_val_both; break; - case(FieldType_Fcst): s = conf_val_fcst; break; - case(FieldType_Obs): s = conf_val_obs; break; + case FieldType::None: s = conf_val_none; break; + case FieldType::Both: s = conf_val_both; break; + case FieldType::Fcst: s = conf_val_fcst; break; + case FieldType::Obs: s = conf_val_obs; break; default: mlog << Error << "\nfieldtype_to_string() -> " - << "Unexpected FieldType value of " << type << ".\n\n"; + << "Unexpected FieldType value of " << enum_class_as_int(type) << ".\n\n"; exit(1); } @@ -2783,13 +2815,13 @@ ConcatString fieldtype_to_string(FieldType type) { /////////////////////////////////////////////////////////////////////////////// SetLogic int_to_setlogic(int v) { - SetLogic t = SetLogic_None; + SetLogic t = SetLogic::None; // Convert integer to enumerated SetLogic - if(v == conf_const.lookup_int(conf_val_none)) t = SetLogic_None; - else if(v == conf_const.lookup_int(conf_val_union)) t = SetLogic_Union; - else if(v == conf_const.lookup_int(conf_val_intersection)) t = SetLogic_Intersection; - else if(v == conf_const.lookup_int(conf_val_symdiff)) t = SetLogic_SymDiff; + if(v == conf_const.lookup_int(conf_val_none)) t = SetLogic::None; + else if(v == conf_const.lookup_int(conf_val_union)) t = SetLogic::Union; + else if(v == conf_const.lookup_int(conf_val_intersection)) t = SetLogic::Intersection; + else if(v == conf_const.lookup_int(conf_val_symdiff)) t = SetLogic::SymDiff; else { mlog << Error << "\nint_to_setlogic() -> " << "Unexpected value of " << v << ".\n\n"; @@ -2802,22 +2834,22 @@ SetLogic int_to_setlogic(int v) { /////////////////////////////////////////////////////////////////////////////// SetLogic string_to_setlogic(const char *s) { - SetLogic t = SetLogic_None; + SetLogic t = SetLogic::None; // Convert string to enumerated SetLogic - if(strcasecmp(s, conf_val_none) == 0) t = SetLogic_None; + if(strcasecmp(s, conf_val_none) == 0) t = SetLogic::None; else if(strcasecmp(s, conf_val_union) == 0 || strcasecmp(s, setlogic_abbr_union) == 0 || - strcasecmp(s, setlogic_symbol_union) == 0) t = SetLogic_Union; + strcasecmp(s, setlogic_symbol_union) == 0) t = SetLogic::Union; else if(strcasecmp(s, conf_val_intersection) == 0 || strcasecmp(s, setlogic_abbr_intersection) == 0 || - strcasecmp(s, setlogic_symbol_intersection) == 0) t = SetLogic_Intersection; + strcasecmp(s, setlogic_symbol_intersection) == 0) t = SetLogic::Intersection; else if(strcasecmp(s, conf_val_symdiff) == 0 || strcasecmp(s, setlogic_abbr_symdiff) == 0 || - strcasecmp(s, setlogic_symbol_symdiff) == 0) t = SetLogic_SymDiff; + strcasecmp(s, setlogic_symbol_symdiff) == 0) t = SetLogic::SymDiff; else { mlog << Error << "\nstring_to_setlogic() -> " @@ -2836,13 +2868,13 @@ ConcatString setlogic_to_string(SetLogic type) { // Convert enumerated SetLogic to string switch(type) { - case(SetLogic_None): s = conf_val_none; break; - case(SetLogic_Union): s = conf_val_union; break; - case(SetLogic_Intersection): s = conf_val_intersection; break; - case(SetLogic_SymDiff): s = conf_val_symdiff; break; + case SetLogic::None: s = conf_val_none; break; + case SetLogic::Union: s = conf_val_union; break; + case SetLogic::Intersection: s = conf_val_intersection; break; + case SetLogic::SymDiff: s = conf_val_symdiff; break; default: mlog << Error << "\nsetlogic_to_string() -> " - << "Unexpected SetLogic value of " << type << ".\n\n"; + << "Unexpected SetLogic value of " << enum_class_as_int(type) << ".\n\n"; exit(1); } @@ -2856,13 +2888,13 @@ ConcatString setlogic_to_abbr(SetLogic type) { // Convert enumerated SetLogic to an abbreviation switch(type) { - case(SetLogic_None): s = na_str; break; - case(SetLogic_Union): s = setlogic_abbr_union; break; - case(SetLogic_Intersection): s = setlogic_abbr_intersection; break; - case(SetLogic_SymDiff): s = setlogic_abbr_symdiff; break; + case SetLogic::None: s = na_str; break; + case SetLogic::Union: s = setlogic_abbr_union; break; + case SetLogic::Intersection: s = setlogic_abbr_intersection; break; + case SetLogic::SymDiff: s = setlogic_abbr_symdiff; break; default: mlog << Error << "\nsetlogic_to_abbr() -> " - << "Unexpected SetLogic value of " << type << ".\n\n"; + << "Unexpected SetLogic value of " << enum_class_as_int(type) << ".\n\n"; exit(1); } @@ -2876,13 +2908,13 @@ ConcatString setlogic_to_symbol(SetLogic type) { // Convert enumerated SetLogic to a symbol switch(type) { - case(SetLogic_None): s = na_str; break; - case(SetLogic_Union): s = setlogic_symbol_union; break; - case(SetLogic_Intersection): s = setlogic_symbol_intersection; break; - case(SetLogic_SymDiff): s = setlogic_symbol_symdiff; break; + case SetLogic::None: s = na_str; break; + case SetLogic::Union: s = setlogic_symbol_union; break; + case SetLogic::Intersection: s = setlogic_symbol_intersection; break; + case SetLogic::SymDiff: s = setlogic_symbol_symdiff; break; default: mlog << Error << "\nsetlogic_to_symbol() -> " - << "Unexpected SetLogic value of " << type << ".\n\n"; + << "Unexpected SetLogic value of " << enum_class_as_int(type) << ".\n\n"; exit(1); } @@ -2892,12 +2924,12 @@ ConcatString setlogic_to_symbol(SetLogic type) { /////////////////////////////////////////////////////////////////////////////// SetLogic check_setlogic(SetLogic t1, SetLogic t2) { - SetLogic t = SetLogic_None; + SetLogic t = SetLogic::None; // If not equal, select the non-default logic type if(t1 == t2) t = t1; - else if(t1 == SetLogic_None) t = t2; - else if(t2 == SetLogic_None) t = t1; + else if(t1 == SetLogic::None) t = t2; + else if(t2 == SetLogic::None) t = t1; // If not equal and both non-default, error out else { mlog << Error << "\ncheck_setlogic() -> " @@ -2913,13 +2945,13 @@ SetLogic check_setlogic(SetLogic t1, SetLogic t2) { /////////////////////////////////////////////////////////////////////////////// TrackType int_to_tracktype(int v) { - TrackType t = TrackType_None; + TrackType t = TrackType::None; // Convert integer to enumerated TrackType - if(v == conf_const.lookup_int(conf_val_none)) t = TrackType_None; - else if(v == conf_const.lookup_int(conf_val_both)) t = TrackType_Both; - else if(v == conf_const.lookup_int(conf_val_adeck)) t = TrackType_ADeck; - else if(v == conf_const.lookup_int(conf_val_bdeck)) t = TrackType_BDeck; + if(v == conf_const.lookup_int(conf_val_none)) t = TrackType::None; + else if(v == conf_const.lookup_int(conf_val_both)) t = TrackType::Both; + else if(v == conf_const.lookup_int(conf_val_adeck)) t = TrackType::ADeck; + else if(v == conf_const.lookup_int(conf_val_bdeck)) t = TrackType::BDeck; else { mlog << Error << "\nint_to_tracktype() -> " << "Unexpected value of " << v << ".\n\n"; @@ -2932,13 +2964,13 @@ TrackType int_to_tracktype(int v) { /////////////////////////////////////////////////////////////////////////////// TrackType string_to_tracktype(const char *s) { - TrackType t = TrackType_None; + TrackType t = TrackType::None; // Convert string to enumerated TrackType - if(strcasecmp(s, conf_val_none) == 0) t = TrackType_None; - else if(strcasecmp(s, conf_val_both) == 0) t = TrackType_Both; - else if(strcasecmp(s, conf_val_adeck) == 0) t = TrackType_ADeck; - else if(strcasecmp(s, conf_val_bdeck) == 0) t = TrackType_BDeck; + if(strcasecmp(s, conf_val_none) == 0) t = TrackType::None; + else if(strcasecmp(s, conf_val_both) == 0) t = TrackType::Both; + else if(strcasecmp(s, conf_val_adeck) == 0) t = TrackType::ADeck; + else if(strcasecmp(s, conf_val_bdeck) == 0) t = TrackType::BDeck; else { mlog << Error << "\nstring_to_tracktype() -> " << "Unexpected TrackType string \"" << s << "\".\n\n"; @@ -2955,13 +2987,13 @@ ConcatString tracktype_to_string(TrackType type) { // Convert enumerated TrackType to string switch(type) { - case(TrackType_None): s = conf_val_none; break; - case(TrackType_Both): s = conf_val_both; break; - case(TrackType_ADeck): s = conf_val_adeck; break; - case(TrackType_BDeck): s = conf_val_bdeck; break; + case TrackType::None: s = conf_val_none; break; + case TrackType::Both: s = conf_val_both; break; + case TrackType::ADeck: s = conf_val_adeck; break; + case TrackType::BDeck: s = conf_val_bdeck; break; default: mlog << Error << "\ntracktype_to_string() -> " - << "Unexpected TrackType value of " << type << ".\n\n"; + << "Unexpected TrackType value of " << enum_class_as_int(type) << ".\n\n"; exit(1); } @@ -2971,15 +3003,15 @@ ConcatString tracktype_to_string(TrackType type) { /////////////////////////////////////////////////////////////////////////////// DiagType string_to_diagtype(const char *s) { - DiagType t = DiagType_None; + DiagType t = DiagType::None; // Convert string to enumerated DiagType, storing unknown strings // as the default type - if(strcasecmp(s, cira_diag_rt_str) == 0) t = DiagType_CIRA_RT; - else if(strcasecmp(s, cira_diag_dev_str) == 0) t = DiagType_CIRA_Dev; - else if(strcasecmp(s, ships_diag_rt_str) == 0) t = DiagType_SHIPS_RT; - else if(strcasecmp(s, ships_diag_dev_str) == 0) t = DiagType_SHIPS_Dev; - else t = DiagType_None; + if(strcasecmp(s, cira_diag_rt_str) == 0) t = DiagType::CIRA_RT; + else if(strcasecmp(s, cira_diag_dev_str) == 0) t = DiagType::CIRA_Dev; + else if(strcasecmp(s, ships_diag_rt_str) == 0) t = DiagType::SHIPS_RT; + else if(strcasecmp(s, ships_diag_dev_str) == 0) t = DiagType::SHIPS_Dev; + else t = DiagType::None; return t; } @@ -2991,14 +3023,14 @@ ConcatString diagtype_to_string(DiagType type) { // Convert enumerated DiagType to string switch(type) { - case(DiagType_None): s = conf_val_none; break; - case(DiagType_CIRA_RT): s = cira_diag_rt_str; break; - case(DiagType_CIRA_Dev): s = cira_diag_dev_str; break; - case(DiagType_SHIPS_RT): s = ships_diag_rt_str; break; - case(DiagType_SHIPS_Dev): s = ships_diag_dev_str; break; + case DiagType::None: s = conf_val_none; break; + case DiagType::CIRA_RT: s = cira_diag_rt_str; break; + case DiagType::CIRA_Dev: s = cira_diag_dev_str; break; + case DiagType::SHIPS_RT: s = ships_diag_rt_str; break; + case DiagType::SHIPS_Dev: s = ships_diag_dev_str; break; default: mlog << Error << "\ndiagtype_to_string() -> " - << "Unexpected DiagType value of " << type << ".\n\n"; + << "Unexpected DiagType value of " << enum_class_as_int(type) << ".\n\n"; exit(1); } @@ -3008,12 +3040,12 @@ ConcatString diagtype_to_string(DiagType type) { /////////////////////////////////////////////////////////////////////////////// Interp12Type int_to_interp12type(int v) { - Interp12Type t = Interp12Type_None; + Interp12Type t = Interp12Type::None; // Convert integer to enumerated Interp12Type - if(v == conf_const.lookup_int(conf_val_none)) t = Interp12Type_None; - else if(v == conf_const.lookup_int(conf_val_fill)) t = Interp12Type_Fill; - else if(v == conf_const.lookup_int(conf_val_replace)) t = Interp12Type_Replace; + if(v == conf_const.lookup_int(conf_val_none)) t = Interp12Type::None; + else if(v == conf_const.lookup_int(conf_val_fill)) t = Interp12Type::Fill; + else if(v == conf_const.lookup_int(conf_val_replace)) t = Interp12Type::Replace; else { mlog << Error << "\nint_to_interp12type() -> " << "Unexpected value of " << v << ".\n\n"; @@ -3026,12 +3058,12 @@ Interp12Type int_to_interp12type(int v) { /////////////////////////////////////////////////////////////////////////////// Interp12Type string_to_interp12type(const char *s) { - Interp12Type t = Interp12Type_None; + Interp12Type t = Interp12Type::None; // Convert string to enumerated Interp12Type - if(strcasecmp(s, conf_val_none) == 0) t = Interp12Type_None; - else if(strcasecmp(s, conf_val_fill) == 0) t = Interp12Type_Fill; - else if(strcasecmp(s, conf_val_replace) == 0) t = Interp12Type_Replace; + if(strcasecmp(s, conf_val_none) == 0) t = Interp12Type::None; + else if(strcasecmp(s, conf_val_fill) == 0) t = Interp12Type::Fill; + else if(strcasecmp(s, conf_val_replace) == 0) t = Interp12Type::Replace; else { mlog << Error << "\nstring_to_interp12type() -> " << "Unexpected Interp12Type string \"" << s << "\".\n\n"; @@ -3048,12 +3080,12 @@ ConcatString interp12type_to_string(Interp12Type type) { // Convert enumerated Interp12Type to string switch(type) { - case(Interp12Type_None): s = conf_val_none; break; - case(Interp12Type_Fill): s = conf_val_fill; break; - case(Interp12Type_Replace): s = conf_val_replace; break; + case Interp12Type::None: s = conf_val_none; break; + case Interp12Type::Fill: s = conf_val_fill; break; + case Interp12Type::Replace: s = conf_val_replace; break; default: mlog << Error << "\ninterp12type_to_string() -> " - << "Unexpected Interp12Type value of " << type << ".\n\n"; + << "Unexpected Interp12Type value of " << enum_class_as_int(type) << ".\n\n"; exit(1); } @@ -3063,13 +3095,13 @@ ConcatString interp12type_to_string(Interp12Type type) { /////////////////////////////////////////////////////////////////////////////// MergeType int_to_mergetype(int v) { - MergeType t = MergeType_None; + MergeType t = MergeType::None; // Convert integer to enumerated MergeType - if(v == conf_const.lookup_int(conf_val_none)) t = MergeType_None; - else if(v == conf_const.lookup_int(conf_val_both)) t = MergeType_Both; - else if(v == conf_const.lookup_int(conf_val_thresh)) t = MergeType_Thresh; - else if(v == conf_const.lookup_int(conf_val_engine)) t = MergeType_Engine; + if(v == conf_const.lookup_int(conf_val_none)) t = MergeType::None; + else if(v == conf_const.lookup_int(conf_val_both)) t = MergeType::Both; + else if(v == conf_const.lookup_int(conf_val_thresh)) t = MergeType::Thresh; + else if(v == conf_const.lookup_int(conf_val_engine)) t = MergeType::Engine; else { mlog << Error << "\nint_to_mergetype() -> " << "Unexpected value of " << v << ".\n\n"; @@ -3086,13 +3118,13 @@ ConcatString mergetype_to_string(MergeType type) { // Convert enumerated MergeType to string switch(type) { - case(MergeType_None): s = conf_val_none; break; - case(MergeType_Both): s = conf_val_both; break; - case(MergeType_Thresh): s = conf_val_thresh; break; - case(MergeType_Engine): s = conf_val_engine; break; + case MergeType::None: s = conf_val_none; break; + case MergeType::Both: s = conf_val_both; break; + case MergeType::Thresh: s = conf_val_thresh; break; + case MergeType::Engine: s = conf_val_engine; break; default: mlog << Error << "\nmergetype_to_string() -> " - << "Unexpected MergeType value of " << type << ".\n\n"; + << "Unexpected MergeType value of " << enum_class_as_int(type) << ".\n\n"; exit(1); } @@ -3106,19 +3138,19 @@ ConcatString obssummary_to_string(ObsSummary type, int perc_val) { // Convert enumerated ObsSummary to string switch(type) { - case(ObsSummary_None): s = conf_val_none; break; - case(ObsSummary_Nearest): s = conf_val_nearest; break; - case(ObsSummary_Min): s = conf_val_min; break; - case(ObsSummary_Max): s = conf_val_max; break; - case(ObsSummary_UW_Mean): s = conf_val_uw_mean; break; - case(ObsSummary_DW_Mean): s = conf_val_dw_mean; break; - case(ObsSummary_Median): s = conf_val_median; break; - case(ObsSummary_Perc): + case ObsSummary::None: s = conf_val_none; break; + case ObsSummary::Nearest: s = conf_val_nearest; break; + case ObsSummary::Min: s = conf_val_min; break; + case ObsSummary::Max: s = conf_val_max; break; + case ObsSummary::UW_Mean: s = conf_val_uw_mean; break; + case ObsSummary::DW_Mean: s = conf_val_dw_mean; break; + case ObsSummary::Median: s = conf_val_median; break; + case ObsSummary::Perc: s << conf_val_perc << "(" << perc_val << ")"; break; default: mlog << Error << "\nobssummary_to_string() -> " - << "Unexpected ObsSummary value of " << type << ".\n\n"; + << "Unexpected ObsSummary value of " << enum_class_as_int(type) << ".\n\n"; exit(1); } @@ -3128,13 +3160,13 @@ ConcatString obssummary_to_string(ObsSummary type, int perc_val) { /////////////////////////////////////////////////////////////////////////////// MatchType int_to_matchtype(int v) { - MatchType t = MatchType_None; + MatchType t = MatchType::None; // Convert integer to enumerated MatchType - if(v == conf_const.lookup_int(conf_val_none)) t = MatchType_None; - else if(v == conf_const.lookup_int(conf_val_merge_both)) t = MatchType_MergeBoth; - else if(v == conf_const.lookup_int(conf_val_merge_fcst)) t = MatchType_MergeFcst; - else if(v == conf_const.lookup_int(conf_val_no_merge)) t = MatchType_NoMerge; + if(v == conf_const.lookup_int(conf_val_none)) t = MatchType::None; + else if(v == conf_const.lookup_int(conf_val_merge_both)) t = MatchType::MergeBoth; + else if(v == conf_const.lookup_int(conf_val_merge_fcst)) t = MatchType::MergeFcst; + else if(v == conf_const.lookup_int(conf_val_no_merge)) t = MatchType::NoMerge; else { mlog << Error << "\nint_to_matchtype() -> " << "Unexpected value of " << v << ".\n\n"; @@ -3151,13 +3183,13 @@ ConcatString matchtype_to_string(MatchType type) { // Convert enumerated MatchType to string switch(type) { - case(MatchType_None): s = conf_val_none; break; - case(MatchType_MergeBoth): s = conf_val_merge_both; break; - case(MatchType_MergeFcst): s = conf_val_merge_fcst; break; - case(MatchType_NoMerge): s = conf_val_no_merge; break; + case MatchType::None: s = conf_val_none; break; + case MatchType::MergeBoth: s = conf_val_merge_both; break; + case MatchType::MergeFcst: s = conf_val_merge_fcst; break; + case MatchType::NoMerge: s = conf_val_no_merge; break; default: mlog << Error << "\nmatchtype_to_string() -> " - << "Unexpected MatchType value of " << type << ".\n\n"; + << "Unexpected MatchType value of " << enum_class_as_int(type) << ".\n\n"; exit(1); } @@ -3167,16 +3199,16 @@ ConcatString matchtype_to_string(MatchType type) { /////////////////////////////////////////////////////////////////////////////// DistType int_to_disttype(int v) { - DistType t = DistType_None; + DistType t = DistType::None; // Convert integer to enumerated DistType - if(v == conf_const.lookup_int(conf_val_none)) t = DistType_None; - else if(v == conf_const.lookup_int(conf_val_normal)) t = DistType_Normal; - else if(v == conf_const.lookup_int(conf_val_exponential)) t = DistType_Exponential; - else if(v == conf_const.lookup_int(conf_val_chisquared)) t = DistType_ChiSquared; - else if(v == conf_const.lookup_int(conf_val_gamma)) t = DistType_Gamma; - else if(v == conf_const.lookup_int(conf_val_uniform)) t = DistType_Uniform; - else if(v == conf_const.lookup_int(conf_val_beta)) t = DistType_Beta; + if(v == conf_const.lookup_int(conf_val_none)) t = DistType::None; + else if(v == conf_const.lookup_int(conf_val_normal)) t = DistType::Normal; + else if(v == conf_const.lookup_int(conf_val_exponential)) t = DistType::Exponential; + else if(v == conf_const.lookup_int(conf_val_chisquared)) t = DistType::ChiSquared; + else if(v == conf_const.lookup_int(conf_val_gamma)) t = DistType::Gamma; + else if(v == conf_const.lookup_int(conf_val_uniform)) t = DistType::Uniform; + else if(v == conf_const.lookup_int(conf_val_beta)) t = DistType::Beta; else { mlog << Error << "\nint_to_disttype() -> " << "Unexpected value of " << v << ".\n\n"; @@ -3189,16 +3221,16 @@ DistType int_to_disttype(int v) { /////////////////////////////////////////////////////////////////////////////// DistType string_to_disttype(const char *s) { - DistType t = DistType_None; + DistType t = DistType::None; // Convert string to enumerated DistType - if(strcasecmp(s, conf_val_none) == 0) t = DistType_None; - else if(strcasecmp(s, conf_val_normal) == 0) t = DistType_Normal; - else if(strcasecmp(s, conf_val_exponential) == 0) t = DistType_Exponential; - else if(strcasecmp(s, conf_val_chisquared) == 0) t = DistType_ChiSquared; - else if(strcasecmp(s, conf_val_gamma) == 0) t = DistType_Gamma; - else if(strcasecmp(s, conf_val_uniform) == 0) t = DistType_Uniform; - else if(strcasecmp(s, conf_val_beta) == 0) t = DistType_Beta; + if(strcasecmp(s, conf_val_none) == 0) t = DistType::None; + else if(strcasecmp(s, conf_val_normal) == 0) t = DistType::Normal; + else if(strcasecmp(s, conf_val_exponential) == 0) t = DistType::Exponential; + else if(strcasecmp(s, conf_val_chisquared) == 0) t = DistType::ChiSquared; + else if(strcasecmp(s, conf_val_gamma) == 0) t = DistType::Gamma; + else if(strcasecmp(s, conf_val_uniform) == 0) t = DistType::Uniform; + else if(strcasecmp(s, conf_val_beta) == 0) t = DistType::Beta; else { mlog << Error << "\nstring_to_disttype() -> " << "Unexpected DistType string \"" << s << "\".\n\n"; @@ -3215,16 +3247,16 @@ ConcatString disttype_to_string(DistType type) { // Convert enumerated DistType to string switch(type) { - case(DistType_None): s = conf_val_none; break; - case(DistType_Normal): s = conf_val_normal; break; - case(DistType_Exponential): s = conf_val_exponential; break; - case(DistType_ChiSquared): s = conf_val_chisquared; break; - case(DistType_Gamma): s = conf_val_gamma; break; - case(DistType_Uniform): s = conf_val_uniform; break; - case(DistType_Beta): s = conf_val_beta; break; + case DistType::None: s = conf_val_none; break; + case DistType::Normal: s = conf_val_normal; break; + case DistType::Exponential: s = conf_val_exponential; break; + case DistType::ChiSquared: s = conf_val_chisquared; break; + case DistType::Gamma: s = conf_val_gamma; break; + case DistType::Uniform: s = conf_val_uniform; break; + case DistType::Beta: s = conf_val_beta; break; default: mlog << Error << "\ndisttype_to_string() -> " - << "Unexpected DistType value of " << type << ".\n\n"; + << "Unexpected DistType value of " << enum_class_as_int(type) << ".\n\n"; exit(1); } @@ -3239,11 +3271,11 @@ ConcatString dist_to_string(DistType type, const NumArray &parm) { s = disttype_to_string(type); // Append distribution parameters - if(type != DistType_None && parm.n() == 2) { + if(type != DistType::None && parm.n() == 2) { s << "(" << parm[0]; - if(type == DistType_Gamma || - type == DistType_Uniform || - type == DistType_Beta) { + if(type == DistType::Gamma || + type == DistType::Uniform || + type == DistType::Beta) { s << ", " << parm[1]; } s << ")"; @@ -3259,13 +3291,13 @@ ConcatString griddecomptype_to_string(GridDecompType type) { // Convert enumerated GridDecompType to string switch(type) { - case(GridDecompType_None): s = conf_val_none; break; - case(GridDecompType_Auto): s = conf_val_auto; break; - case(GridDecompType_Tile): s = conf_val_tile; break; - case(GridDecompType_Pad): s = conf_val_pad; break; + case GridDecompType::None: s = conf_val_none; break; + case GridDecompType::Auto: s = conf_val_auto; break; + case GridDecompType::Tile: s = conf_val_tile; break; + case GridDecompType::Pad: s = conf_val_pad; break; default: mlog << Error << "\ngriddecomptype_to_string() -> " - << "Unexpected GridDecompType value of " << type << ".\n\n"; + << "Unexpected GridDecompType value of " << enum_class_as_int(type) << ".\n\n"; exit(1); } @@ -3279,16 +3311,16 @@ ConcatString wavelettype_to_string(WaveletType type) { // Convert enumerated WaveletType to string switch(type) { - case(WaveletType_None): s = conf_val_none; break; - case(WaveletType_Haar): s = conf_val_haar; break; - case(WaveletType_Haar_Cntr): s = conf_val_haar_cntr; break; - case(WaveletType_Daub): s = conf_val_daub; break; - case(WaveletType_Daub_Cntr): s = conf_val_daub_cntr; break; - case(WaveletType_BSpline): s = conf_val_bspline; break; - case(WaveletType_BSpline_Cntr): s = conf_val_bspline_cntr; break; + case WaveletType::None: s = conf_val_none; break; + case WaveletType::Haar: s = conf_val_haar; break; + case WaveletType::Haar_Cntr: s = conf_val_haar_cntr; break; + case WaveletType::Daub: s = conf_val_daub; break; + case WaveletType::Daub_Cntr: s = conf_val_daub_cntr; break; + case WaveletType::BSpline: s = conf_val_bspline; break; + case WaveletType::BSpline_Cntr: s = conf_val_bspline_cntr; break; default: mlog << Error << "\nwavlettype_to_string() -> " - << "Unexpected WaveletType value of " << type << ".\n\n"; + << "Unexpected WaveletType value of " << enum_class_as_int(type) << ".\n\n"; exit(1); } @@ -3314,7 +3346,7 @@ StringArray parse_conf_ens_member_ids(Dictionary *dict) { /////////////////////////////////////////////////////////////////////////////// NormalizeType parse_conf_normalize(Dictionary *dict) { - NormalizeType t = NormalizeType_None; + NormalizeType t = NormalizeType::None; int v; if(!dict) { @@ -3327,11 +3359,11 @@ NormalizeType parse_conf_normalize(Dictionary *dict) { v = dict->lookup_int(conf_key_normalize); // Convert integer to enumerated NormalizeType - if(v == conf_const.lookup_int(normalizetype_none_str)) t = NormalizeType_None; - else if(v == conf_const.lookup_int(normalizetype_climo_anom_str)) t = NormalizeType_ClimoAnom; - else if(v == conf_const.lookup_int(normalizetype_climo_std_anom_str)) t = NormalizeType_ClimoStdAnom; - else if(v == conf_const.lookup_int(normalizetype_fcst_anom_str)) t = NormalizeType_FcstAnom; - else if(v == conf_const.lookup_int(normalizetype_fcst_std_anom_str)) t = NormalizeType_FcstStdAnom; + if(v == conf_const.lookup_int(normalizetype_none_str)) t = NormalizeType::None; + else if(v == conf_const.lookup_int(normalizetype_climo_anom_str)) t = NormalizeType::ClimoAnom; + else if(v == conf_const.lookup_int(normalizetype_climo_std_anom_str)) t = NormalizeType::ClimoStdAnom; + else if(v == conf_const.lookup_int(normalizetype_fcst_anom_str)) t = NormalizeType::FcstAnom; + else if(v == conf_const.lookup_int(normalizetype_fcst_std_anom_str)) t = NormalizeType::FcstStdAnom; else { mlog << Error << "\nparse_conf_normalize() -> " << "Unexpected value of " << v << ".\n\n"; diff --git a/src/basic/vx_config/config_util.h b/src/basic/vx_config/config_util.h index d8137919cb..3dae869b2b 100644 --- a/src/basic/vx_config/config_util.h +++ b/src/basic/vx_config/config_util.h @@ -105,6 +105,9 @@ extern const char * statlinetype_to_string(const STATLineType); extern void statlinetype_to_string(const STATLineType, char *); extern STATLineType string_to_statlinetype(const char *); +extern const char * bootintervaltype_to_string(const BootIntervalType); +extern BootIntervalType string_to_bootintervaltype(const char *); + extern FieldType int_to_fieldtype(int); extern ConcatString fieldtype_to_string(FieldType); @@ -150,7 +153,7 @@ extern int parse_conf_percentile(Dictionary *dict); extern void python_compile_error(const char *caller=nullptr); extern void ugrid_compile_error(const char *caller=nullptr); -//////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// #endif /* __CONFIG_UTIL_H__ */ diff --git a/src/basic/vx_config/configobjecttype_to_string.cc b/src/basic/vx_config/configobjecttype_to_string.cc index d8088d406c..8bb9f296b8 100644 --- a/src/basic/vx_config/configobjecttype_to_string.cc +++ b/src/basic/vx_config/configobjecttype_to_string.cc @@ -62,7 +62,7 @@ switch ( t ) { } // switch -return ConcatString (s); +return ConcatString(s); } diff --git a/src/basic/vx_config/grdfiletype_to_string.cc b/src/basic/vx_config/grdfiletype_to_string.cc index b5d2d4b6be..c9e89451c3 100644 --- a/src/basic/vx_config/grdfiletype_to_string.cc +++ b/src/basic/vx_config/grdfiletype_to_string.cc @@ -28,7 +28,6 @@ #include "grdfiletype_to_string.h" - using namespace std; diff --git a/src/basic/vx_log/Makefile.am b/src/basic/vx_log/Makefile.am index 9e4ba32cf2..49f7f988ff 100644 --- a/src/basic/vx_log/Makefile.am +++ b/src/basic/vx_log/Makefile.am @@ -17,7 +17,7 @@ libvx_log_a_SOURCES = concat_string.cc concat_string.h \ logger.cc logger.h \ string_array.cc string_array.h \ str_wrappers.cc str_wrappers.h \ - vx_log.h + enum_as_int.hpp vx_log.h # Build the library when making a distribution so that # we can make enum_to_string and chk4copyright. diff --git a/src/basic/vx_log/Makefile.in b/src/basic/vx_log/Makefile.in index bfbfb1c4b6..272dddb3ca 100644 --- a/src/basic/vx_log/Makefile.in +++ b/src/basic/vx_log/Makefile.in @@ -350,7 +350,7 @@ libvx_log_a_SOURCES = concat_string.cc concat_string.h \ logger.cc logger.h \ string_array.cc string_array.h \ str_wrappers.cc str_wrappers.h \ - vx_log.h + enum_as_int.hpp vx_log.h all: all-am diff --git a/src/basic/vx_log/enum_as_int.hpp b/src/basic/vx_log/enum_as_int.hpp new file mode 100644 index 0000000000..ded32a2a09 --- /dev/null +++ b/src/basic/vx_log/enum_as_int.hpp @@ -0,0 +1,34 @@ +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +// ** Copyright UCAR (c) 1992 - 2024 +// ** University Corporation for Atmospheric Research (UCAR) +// ** National Center for Atmospheric Research (NCAR) +// ** Research Applications Lab (RAL) +// ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* + + +////////////////////////////////////////////////////////////////// + + +#ifndef __ENUM_CLASS_AS_INT_HPP__ +#define __ENUM_CLASS_AS_INT_HPP__ + + +////////////////////////////////////////////////////////////////// + +template +auto enum_class_as_int(Enumeration const value) + -> typename std::underlying_type::type +{ + return static_cast::type>(value); +} + +////////////////////////////////////////////////////////////////// + + +#endif // __ENUM_CLASS_AS_INT_HPP__ + + +////////////////////////////////////////////////////////////////// + + diff --git a/src/basic/vx_log/logger.h b/src/basic/vx_log/logger.h index 7f0e2ca95a..d88333e98b 100644 --- a/src/basic/vx_log/logger.h +++ b/src/basic/vx_log/logger.h @@ -79,9 +79,9 @@ class MsgLevel ////////////////////////////////////////////////////////////////// -inline int MsgLevel::value() const { return (Value); } +inline int MsgLevel::value() const { return Value; } -inline MsgLevel::operator const int & () const { return (Value); } +inline MsgLevel::operator const int & () const { return Value; } ////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_math/viewgravity_to_string.cc b/src/basic/vx_math/viewgravity_to_string.cc index 63e499533b..78e4e5aad4 100644 --- a/src/basic/vx_math/viewgravity_to_string.cc +++ b/src/basic/vx_math/viewgravity_to_string.cc @@ -28,7 +28,6 @@ #include "viewgravity_to_string.h" - using namespace std; diff --git a/src/basic/vx_util/GridTemplate.cc b/src/basic/vx_util/GridTemplate.cc index 9534c81015..c2c21bf038 100644 --- a/src/basic/vx_util/GridTemplate.cc +++ b/src/basic/vx_util/GridTemplate.cc @@ -29,6 +29,7 @@ #include "vx_log.h" #include "nint.h" +#include "enum_as_int.hpp" #include "GridTemplate.h" #include "GridOffset.h" @@ -591,11 +592,11 @@ void GridTemplate::_setEdgeOffsets() { /////////////////////////////////////////////////////////////////////////////// GridTemplateFactory::GridTemplateFactory() { - enum_to_string.resize(GridTemplate_NUM_TEMPLATES); + enum_to_string.resize(enum_class_as_int(GridTemplates::NUM_TEMPLATES)); - enum_to_string[GridTemplate_None] = ""; - enum_to_string[GridTemplate_Square] = "SQUARE"; - enum_to_string[GridTemplate_Circle] = "CIRCLE"; + enum_to_string[enum_class_as_int(GridTemplates::None)] = ""; + enum_to_string[enum_class_as_int(GridTemplates::Square)] = "SQUARE"; + enum_to_string[enum_class_as_int(GridTemplates::Circle)] = "CIRCLE"; } /////////////////////////////////////////////////////////////////////////////// @@ -612,7 +613,7 @@ GridTemplateFactory::~GridTemplateFactory() { GridTemplateFactory::GridTemplates GridTemplateFactory::string2Enum(string target) { - for(unsigned int ix = 0; ix < GridTemplate_NUM_TEMPLATES; ix++) { + for(unsigned int ix = 0; ix < enum_class_as_int(GridTemplates::NUM_TEMPLATES); ix++) { if(enum_to_string[ix] == target) { return static_cast(ix); } @@ -632,7 +633,7 @@ string GridTemplateFactory::enum2String(GridTemplates target) { if(static_cast(target) > enum_to_string.size() - 1) { mlog << Error << "\nGridTemplateFactory::enum2String() -> " - << "target out of range " << target << " > " + << "target out of range " << enum_class_as_int(target) << " > " << (static_cast(enum_to_string.size()) - 1) << ".\n\n"; exit(1); @@ -659,15 +660,15 @@ GridTemplate* GridTemplateFactory::buildGT(string gt, int width, bool wrap_lon) GridTemplate* GridTemplateFactory::buildGT(GridTemplates gt, int width, bool wrap_lon) { switch (gt) { - case(GridTemplate_Square): + case GridTemplates::Square: return new RectangularTemplate(width, width, wrap_lon); - case(GridTemplate_Circle): + case GridTemplates::Circle: return new CircularTemplate(width, wrap_lon); default: mlog << Error << "\nbuildGT() -> " - << "Unexpected GridTemplates value (" << gt << ").\n\n"; + << "Unexpected GridTemplates value (" << enum_class_as_int(gt) << ").\n\n"; exit(1); } } diff --git a/src/basic/vx_util/GridTemplate.h b/src/basic/vx_util/GridTemplate.h index 6682cc10af..ed58165f4d 100644 --- a/src/basic/vx_util/GridTemplate.h +++ b/src/basic/vx_util/GridTemplate.h @@ -158,12 +158,12 @@ class GridTemplateFactory { // do not assign specific values to these enumes. // other code requires them to start at zero and increase by 1 - // make sure GridTemplate_NUM_TEMPLATES is always last. - enum GridTemplates { - GridTemplate_None, - GridTemplate_Square, - GridTemplate_Circle, - GridTemplate_NUM_TEMPLATES + // make sure GridTemplate::NUM_TEMPLATES is always last. + enum class GridTemplates { + None, + Square, + Circle, + NUM_TEMPLATES }; // String corresponding to the enumerated values above diff --git a/src/basic/vx_util/asciitablejust_to_string.cc b/src/basic/vx_util/asciitablejust_to_string.cc index fa89d3958e..6bdf630114 100644 --- a/src/basic/vx_util/asciitablejust_to_string.cc +++ b/src/basic/vx_util/asciitablejust_to_string.cc @@ -6,6 +6,7 @@ // ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA // *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* + //////////////////////////////////////////////////////////////////////// @@ -27,7 +28,6 @@ #include "asciitablejust_to_string.h" - using namespace std; diff --git a/src/basic/vx_util/data_plane_util.cc b/src/basic/vx_util/data_plane_util.cc index 233b3b6293..f07da09913 100644 --- a/src/basic/vx_util/data_plane_util.cc +++ b/src/basic/vx_util/data_plane_util.cc @@ -18,6 +18,7 @@ #include "omp.h" #endif +#include "config_util.h" #include "data_plane_util.h" #include "interp_util.h" #include "two_to_one.h" @@ -25,6 +26,7 @@ #include "vx_gsl_prob.h" #include "vx_math.h" #include "vx_log.h" +#include "enum_as_int.hpp" #include "GridTemplate.h" @@ -36,6 +38,7 @@ using namespace std; // //////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////// // // Check the range of probability values and make sure it's either @@ -106,7 +109,7 @@ void smooth_field(const DataPlane &dp, DataPlane &smooth_dp, smooth_dp = dp; // For nearest neighbor, no work to do. - if(width == 1 && mthd == InterpMthd_Nearest) return; + if(width == 1 && mthd == InterpMthd::Nearest) return; // build the grid template GridTemplateFactory gtf; @@ -125,27 +128,27 @@ void smooth_field(const DataPlane &dp, DataPlane &smooth_dp, // Compute the smoothed value based on the interpolation method switch(mthd) { - case(InterpMthd_Min): // Minimum + case InterpMthd::Min: // Minimum v = interp_min(dp, *gt, x, y, t); break; - case(InterpMthd_Max): // Maximum + case InterpMthd::Max: // Maximum v = interp_max(dp, *gt, x, y, t); break; - case(InterpMthd_Median): // Median + case InterpMthd::Median: // Median v = interp_median(dp, *gt, x, y, t); break; - case(InterpMthd_UW_Mean): // Unweighted Mean + case InterpMthd::UW_Mean: // Unweighted Mean v = interp_uw_mean(dp, *gt, x, y, t); break; - case(InterpMthd_Gaussian): // For Gaussian, pass the data through + case InterpMthd::Gaussian: // For Gaussian, pass the data through v = dp.get(x, y); break; - case(InterpMthd_MaxGauss): // For Max Gaussian, compute the max + case InterpMthd::MaxGauss: // For Max Gaussian, compute the max v = interp_max(dp, *gt, x, y, 0); break; @@ -156,7 +159,7 @@ void smooth_field(const DataPlane &dp, DataPlane &smooth_dp, default: mlog << Error << "\nsmooth_field() -> " << "unsupported interpolation method encountered: " - << interpmthd_to_string(mthd) << "(" << mthd + << interpmthd_to_string(mthd) << "(" << enum_class_as_int(mthd) << ")\n\n"; exit(1); } @@ -168,8 +171,8 @@ void smooth_field(const DataPlane &dp, DataPlane &smooth_dp, } // end for x // Apply the Gaussian smoother - if(mthd == InterpMthd_Gaussian || - mthd == InterpMthd_MaxGauss) { + if(mthd == InterpMthd::Gaussian || + mthd == InterpMthd::MaxGauss) { interp_gaussian_dp(smooth_dp, gaussian, t); } @@ -265,7 +268,7 @@ void fractional_coverage(const DataPlane &dp, DataPlane &frac_dp, mlog << Debug(3) << "Computing fractional coverage field using the " << t.get_str() << " threshold and the " - << interpmthd_to_string(InterpMthd_Nbrhd) << "(" << gt->size() + << interpmthd_to_string(InterpMthd::Nbrhd) << "(" << gt->size() << ") " << gt->getClassName() << " interpolation method.\n"; // Initialize the fractional coverage field diff --git a/src/basic/vx_util/interp_mthd.cc b/src/basic/vx_util/interp_mthd.cc index ba55b07da3..afb04be803 100644 --- a/src/basic/vx_util/interp_mthd.cc +++ b/src/basic/vx_util/interp_mthd.cc @@ -24,29 +24,29 @@ ConcatString interpmthd_to_string(const InterpMthd m) { ConcatString out; switch(m) { - case(InterpMthd_Min): out = interpmthd_min_str; break; - case(InterpMthd_Max): out = interpmthd_max_str; break; - case(InterpMthd_Median): out = interpmthd_median_str; break; - case(InterpMthd_UW_Mean): out = interpmthd_uw_mean_str; break; - case(InterpMthd_DW_Mean): out = interpmthd_dw_mean_str; break; - case(InterpMthd_AW_Mean): out = interpmthd_aw_mean_str; break; - case(InterpMthd_LS_Fit): out = interpmthd_ls_fit_str; break; - case(InterpMthd_Nbrhd): out = interpmthd_nbrhd_str; break; - case(InterpMthd_Bilin): out = interpmthd_bilin_str; break; - case(InterpMthd_Nearest): out = interpmthd_nearest_str; break; - case(InterpMthd_Budget): out = interpmthd_budget_str; break; - case(InterpMthd_Force): out = interpmthd_force_str; break; - case(InterpMthd_Best): out = interpmthd_best_str; break; - case(InterpMthd_Upper_Left): out = interpmthd_upper_left_str; break; - case(InterpMthd_Upper_Right): out = interpmthd_upper_right_str; break; - case(InterpMthd_Lower_Right): out = interpmthd_lower_right_str; break; - case(InterpMthd_Lower_Left): out = interpmthd_lower_left_str; break; - case(InterpMthd_Gaussian): out = interpmthd_gaussian_str; break; - case(InterpMthd_MaxGauss): out = interpmthd_maxgauss_str; break; - case(InterpMthd_Geog_Match): out = interpmthd_geog_match_str; break; - case(InterpMthd_HiRA): out = interpmthd_hira_str; break; + case InterpMthd::Min: out = interpmthd_min_str; break; + case InterpMthd::Max: out = interpmthd_max_str; break; + case InterpMthd::Median: out = interpmthd_median_str; break; + case InterpMthd::UW_Mean: out = interpmthd_uw_mean_str; break; + case InterpMthd::DW_Mean: out = interpmthd_dw_mean_str; break; + case InterpMthd::AW_Mean: out = interpmthd_aw_mean_str; break; + case InterpMthd::LS_Fit: out = interpmthd_ls_fit_str; break; + case InterpMthd::Nbrhd: out = interpmthd_nbrhd_str; break; + case InterpMthd::Bilin: out = interpmthd_bilin_str; break; + case InterpMthd::Nearest: out = interpmthd_nearest_str; break; + case InterpMthd::Budget: out = interpmthd_budget_str; break; + case InterpMthd::Force: out = interpmthd_force_str; break; + case InterpMthd::Best: out = interpmthd_best_str; break; + case InterpMthd::Upper_Left: out = interpmthd_upper_left_str; break; + case InterpMthd::Upper_Right: out = interpmthd_upper_right_str; break; + case InterpMthd::Lower_Right: out = interpmthd_lower_right_str; break; + case InterpMthd::Lower_Left: out = interpmthd_lower_left_str; break; + case InterpMthd::Gaussian: out = interpmthd_gaussian_str; break; + case InterpMthd::MaxGauss: out = interpmthd_maxgauss_str; break; + case InterpMthd::Geog_Match: out = interpmthd_geog_match_str; break; + case InterpMthd::HiRA: out = interpmthd_hira_str; break; - case(InterpMthd_None): + case InterpMthd::None: default: out = interpmthd_none_str; break; } // switch @@ -58,28 +58,28 @@ ConcatString interpmthd_to_string(const InterpMthd m) { InterpMthd string_to_interpmthd(const char *mthd_str) { InterpMthd m; - if(strcmp(mthd_str, interpmthd_min_str) == 0) m = InterpMthd_Min; - else if(strcmp(mthd_str, interpmthd_max_str) == 0) m = InterpMthd_Max; - else if(strcmp(mthd_str, interpmthd_median_str) == 0) m = InterpMthd_Median; - else if(strcmp(mthd_str, interpmthd_uw_mean_str) == 0) m = InterpMthd_UW_Mean; - else if(strcmp(mthd_str, interpmthd_dw_mean_str) == 0) m = InterpMthd_DW_Mean; - else if(strcmp(mthd_str, interpmthd_aw_mean_str) == 0) m = InterpMthd_AW_Mean; - else if(strcmp(mthd_str, interpmthd_ls_fit_str) == 0) m = InterpMthd_LS_Fit; - else if(strcmp(mthd_str, interpmthd_nbrhd_str) == 0) m = InterpMthd_Nbrhd; - else if(strcmp(mthd_str, interpmthd_bilin_str) == 0) m = InterpMthd_Bilin; - else if(strcmp(mthd_str, interpmthd_nearest_str) == 0) m = InterpMthd_Nearest; - else if(strcmp(mthd_str, interpmthd_budget_str) == 0) m = InterpMthd_Budget; - else if(strcmp(mthd_str, interpmthd_force_str) == 0) m = InterpMthd_Force; - else if(strcmp(mthd_str, interpmthd_best_str) == 0) m = InterpMthd_Best; - else if(strcmp(mthd_str, interpmthd_upper_left_str) == 0) m = InterpMthd_Upper_Left; - else if(strcmp(mthd_str, interpmthd_upper_right_str) == 0) m = InterpMthd_Upper_Right; - else if(strcmp(mthd_str, interpmthd_lower_right_str) == 0) m = InterpMthd_Lower_Right; - else if(strcmp(mthd_str, interpmthd_lower_left_str) == 0) m = InterpMthd_Lower_Left; - else if(strcmp(mthd_str, interpmthd_gaussian_str ) == 0) m = InterpMthd_Gaussian; - else if(strcmp(mthd_str, interpmthd_maxgauss_str ) == 0) m = InterpMthd_MaxGauss; - else if(strcmp(mthd_str, interpmthd_geog_match_str) == 0) m = InterpMthd_Geog_Match; - else if(strcmp(mthd_str, interpmthd_hira_str) == 0) m = InterpMthd_HiRA; - else m = InterpMthd_None; + if(strcmp(mthd_str, interpmthd_min_str) == 0) m = InterpMthd::Min; + else if(strcmp(mthd_str, interpmthd_max_str) == 0) m = InterpMthd::Max; + else if(strcmp(mthd_str, interpmthd_median_str) == 0) m = InterpMthd::Median; + else if(strcmp(mthd_str, interpmthd_uw_mean_str) == 0) m = InterpMthd::UW_Mean; + else if(strcmp(mthd_str, interpmthd_dw_mean_str) == 0) m = InterpMthd::DW_Mean; + else if(strcmp(mthd_str, interpmthd_aw_mean_str) == 0) m = InterpMthd::AW_Mean; + else if(strcmp(mthd_str, interpmthd_ls_fit_str) == 0) m = InterpMthd::LS_Fit; + else if(strcmp(mthd_str, interpmthd_nbrhd_str) == 0) m = InterpMthd::Nbrhd; + else if(strcmp(mthd_str, interpmthd_bilin_str) == 0) m = InterpMthd::Bilin; + else if(strcmp(mthd_str, interpmthd_nearest_str) == 0) m = InterpMthd::Nearest; + else if(strcmp(mthd_str, interpmthd_budget_str) == 0) m = InterpMthd::Budget; + else if(strcmp(mthd_str, interpmthd_force_str) == 0) m = InterpMthd::Force; + else if(strcmp(mthd_str, interpmthd_best_str) == 0) m = InterpMthd::Best; + else if(strcmp(mthd_str, interpmthd_upper_left_str) == 0) m = InterpMthd::Upper_Left; + else if(strcmp(mthd_str, interpmthd_upper_right_str) == 0) m = InterpMthd::Upper_Right; + else if(strcmp(mthd_str, interpmthd_lower_right_str) == 0) m = InterpMthd::Lower_Right; + else if(strcmp(mthd_str, interpmthd_lower_left_str) == 0) m = InterpMthd::Lower_Left; + else if(strcmp(mthd_str, interpmthd_gaussian_str ) == 0) m = InterpMthd::Gaussian; + else if(strcmp(mthd_str, interpmthd_maxgauss_str ) == 0) m = InterpMthd::MaxGauss; + else if(strcmp(mthd_str, interpmthd_geog_match_str) == 0) m = InterpMthd::Geog_Match; + else if(strcmp(mthd_str, interpmthd_hira_str) == 0) m = InterpMthd::HiRA; + else m = InterpMthd::None; return m; } diff --git a/src/basic/vx_util/interp_mthd.h b/src/basic/vx_util/interp_mthd.h index 0f061241e1..b5468168ed 100644 --- a/src/basic/vx_util/interp_mthd.h +++ b/src/basic/vx_util/interp_mthd.h @@ -21,29 +21,29 @@ // // Enumeration for interpolation methods // -enum InterpMthd { - InterpMthd_None, - InterpMthd_Min, - InterpMthd_Max, - InterpMthd_Median, - InterpMthd_UW_Mean, - InterpMthd_DW_Mean, - InterpMthd_AW_Mean, - InterpMthd_LS_Fit, - InterpMthd_Nbrhd, - InterpMthd_Bilin, - InterpMthd_Nearest, - InterpMthd_Budget, - InterpMthd_Force, - InterpMthd_Best, - InterpMthd_Upper_Left, - InterpMthd_Upper_Right, - InterpMthd_Lower_Right, - InterpMthd_Lower_Left, - InterpMthd_Gaussian, - InterpMthd_MaxGauss, - InterpMthd_Geog_Match, - InterpMthd_HiRA +enum class InterpMthd { + None, + Min, + Max, + Median, + UW_Mean, + DW_Mean, + AW_Mean, + LS_Fit, + Nbrhd, + Bilin, + Nearest, + Budget, + Force, + Best, + Upper_Left, + Upper_Right, + Lower_Right, + Lower_Left, + Gaussian, + MaxGauss, + Geog_Match, + HiRA }; // diff --git a/src/basic/vx_util/interp_util.cc b/src/basic/vx_util/interp_util.cc index 826c396e1e..b5cb88c412 100644 --- a/src/basic/vx_util/interp_util.cc +++ b/src/basic/vx_util/interp_util.cc @@ -16,12 +16,14 @@ #include #include +#include "config_util.h" #include "interp_util.h" #include "GridTemplate.h" #include "RectangularTemplate.h" #include "vx_math.h" #include "vx_log.h" +#include "enum_as_int.hpp" using namespace std; @@ -958,68 +960,68 @@ double compute_sfc_interp(const DataPlane &dp, // Compute the interpolated value for the fields above and below switch(mthd) { - case(InterpMthd_Min): // Minimum + case InterpMthd::Min: // Minimum v = interp_min(dp, *gt, x, y, interp_thresh, &sfc_mask); break; - case(InterpMthd_Max): // Maximum + case InterpMthd::Max: // Maximum v = interp_max(dp, *gt, x, y, interp_thresh, &sfc_mask); break; - case(InterpMthd_Median): // Median + case InterpMthd::Median: // Median v = interp_median(dp, *gt, x, y, interp_thresh, &sfc_mask); break; - case(InterpMthd_UW_Mean): // Unweighted Mean + case InterpMthd::UW_Mean: // Unweighted Mean v = interp_uw_mean(dp, *gt, x, y, interp_thresh, &sfc_mask); break; - case(InterpMthd_DW_Mean): // Distance-Weighted Mean + case InterpMthd::DW_Mean: // Distance-Weighted Mean v = interp_dw_mean(dp, *gt, obs_x, obs_y, dw_mean_pow, interp_thresh, &sfc_mask); break; - case(InterpMthd_LS_Fit): // Least-squares fit + case InterpMthd::LS_Fit: // Least-squares fit v = interp_ls_fit(dp, *gt, obs_x, obs_y, interp_thresh, &sfc_mask); break; - case(InterpMthd_Bilin): // Bilinear interpolation + case InterpMthd::Bilin: // Bilinear interpolation v = interp_bilin(dp, wrap_lon, obs_x, obs_y, &sfc_mask); break; - case(InterpMthd_Nearest): // Nearest Neighbor + case InterpMthd::Nearest: // Nearest Neighbor v = interp_xy(dp, wrap_lon, x, y, &sfc_mask); break; - case(InterpMthd_Best): // Best Match + case InterpMthd::Best: // Best Match v = interp_best(dp, *gt, x, y, obs_v, interp_thresh, &sfc_mask); break; - case(InterpMthd_Upper_Left): // Upper Left corner of the grid box + case InterpMthd::Upper_Left: // Upper Left corner of the grid box v = interp_xy(dp, wrap_lon, floor(obs_x), ceil(obs_y), &sfc_mask); break; - case(InterpMthd_Upper_Right): // Upper Right corner of the grid box + case InterpMthd::Upper_Right: // Upper Right corner of the grid box v = interp_xy(dp, wrap_lon, ceil(obs_x), ceil(obs_y), &sfc_mask); break; - case(InterpMthd_Lower_Right): // Lower Right corner of the grid box + case InterpMthd::Lower_Right: // Lower Right corner of the grid box v = interp_xy(dp, wrap_lon, ceil(obs_x), floor(obs_y), &sfc_mask); break; - case(InterpMthd_Lower_Left): // Lower Left corner of the grid box + case InterpMthd::Lower_Left: // Lower Left corner of the grid box v = interp_xy(dp, wrap_lon, floor(obs_x), floor(obs_y), &sfc_mask); break; - case(InterpMthd_Geog_Match): // Geography Match for surface point verification + case InterpMthd::Geog_Match: // Geography Match for surface point verification v = interp_geog_match(dp, *gt, obs_x, obs_y, obs_v, &sfc_mask); break; default: mlog << Error << "\ncompute_sfc_interp() -> " << "unsupported interpolation method encountered: " - << interpmthd_to_string(mthd) << "(" << mthd << ")\n\n"; + << interpmthd_to_string(mthd) << "(" << enum_class_as_int(mthd) << ")\n\n"; exit(1); } @@ -1127,73 +1129,73 @@ double compute_horz_interp(const DataPlane &dp, // Compute the interpolated value for the fields above and below switch(mthd) { - case(InterpMthd_Min): // Minimum + case InterpMthd::Min: // Minimum v = interp_min(dp, *gt, x, y, interp_thresh); break; - case(InterpMthd_Max): // Maximum + case InterpMthd::Max: // Maximum v = interp_max(dp, *gt, x, y, interp_thresh); break; - case(InterpMthd_Median): // Median + case InterpMthd::Median: // Median v = interp_median(dp, *gt, x, y, interp_thresh); break; - case(InterpMthd_UW_Mean): // Unweighted Mean + case InterpMthd::UW_Mean: // Unweighted Mean v = interp_uw_mean(dp, *gt, x, y, interp_thresh); break; - case(InterpMthd_DW_Mean): // Distance-Weighted Mean + case InterpMthd::DW_Mean: // Distance-Weighted Mean v = interp_dw_mean(dp, *gt, obs_x, obs_y, dw_mean_pow, interp_thresh); break; - case(InterpMthd_LS_Fit): // Least-squares fit + case InterpMthd::LS_Fit: // Least-squares fit v = interp_ls_fit(dp, *gt, obs_x, obs_y, interp_thresh); break; - case(InterpMthd_Nbrhd): // Neighborhood fractional coverage + case InterpMthd::Nbrhd: // Neighborhood fractional coverage v = interp_nbrhd(dp, *gt, x, y, interp_thresh, cat_thresh, cmn, csd); break; - case(InterpMthd_Bilin): // Bilinear interpolation + case InterpMthd::Bilin: // Bilinear interpolation v = interp_bilin(dp, wrap_lon, obs_x, obs_y); break; - case(InterpMthd_Nearest): // Nearest Neighbor + case InterpMthd::Nearest: // Nearest Neighbor v = interp_xy(dp, wrap_lon, x, y); break; - case(InterpMthd_Best): // Best Match + case InterpMthd::Best: // Best Match v = interp_best(dp, *gt, x, y, obs_v, interp_thresh); break; - case(InterpMthd_Upper_Left): // Upper Left corner of the grid box + case InterpMthd::Upper_Left: // Upper Left corner of the grid box v = interp_xy(dp, wrap_lon, floor(obs_x), ceil(obs_y)); break; - case(InterpMthd_Upper_Right): // Upper Right corner of the grid box + case InterpMthd::Upper_Right: // Upper Right corner of the grid box v = interp_xy(dp, wrap_lon, ceil(obs_x), ceil(obs_y)); break; - case(InterpMthd_Lower_Right): // Lower Right corner of the grid box + case InterpMthd::Lower_Right: // Lower Right corner of the grid box v = interp_xy(dp, wrap_lon, ceil(obs_x), floor(obs_y)); break; - case(InterpMthd_Lower_Left): // Lower Left corner of the grid box + case InterpMthd::Lower_Left: // Lower Left corner of the grid box v = interp_xy(dp, wrap_lon, floor(obs_x), floor(obs_y)); break; - case(InterpMthd_Geog_Match): // Geography Match for surface point verification + case InterpMthd::Geog_Match: // Geography Match for surface point verification v = interp_geog_match(dp, *gt, obs_x, obs_y, obs_v); break; default: mlog << Error << "\ncompute_horz_interp() -> " << "unsupported interpolation method encountered: " - << interpmthd_to_string(mthd) << "(" << mthd << ")\n\n"; + << interpmthd_to_string(mthd) << "(" << enum_class_as_int(mthd) << ")\n\n"; exit(1); } @@ -1308,37 +1310,37 @@ DataPlane valid_time_interp(const DataPlane &in1, const DataPlane &in2, // Compute interpolation weights switch(mthd) { - case(InterpMthd_Min): // Minimum - case(InterpMthd_Max): // Maximum + case InterpMthd::Min: // Minimum + case InterpMthd::Max: // Maximum w1 = w2 = bad_data_double; break; - case(InterpMthd_UW_Mean): // Unweighted Mean + case InterpMthd::UW_Mean: // Unweighted Mean w1 = w2 = 0.5; break; - case(InterpMthd_DW_Mean): // Distance-Weighted Mean + case InterpMthd::DW_Mean: // Distance-Weighted Mean w1 = (double) (dp2.valid() - to_ut) / (dp2.valid() - dp1.valid()); w2 = (double) (to_ut - dp1.valid()) / (dp2.valid() - dp1.valid()); break; - case(InterpMthd_Nearest): // Nearest Neighbor + case InterpMthd::Nearest: // Nearest Neighbor use_min = ((to_ut - dp1.valid()) <= (dp2.valid() - to_ut)); w1 = (use_min ? 1.0 : 0.0); w2 = (use_min ? 0.0 : 1.0); break; - case(InterpMthd_AW_Mean): // Area-Weighted Mean - case(InterpMthd_Median): // Median - case(InterpMthd_LS_Fit): // Least-squares fit - case(InterpMthd_Bilin): // Bilinear interpolation + case InterpMthd::AW_Mean: // Area-Weighted Mean + case InterpMthd::Median: // Median + case InterpMthd::LS_Fit: // Least-squares fit + case InterpMthd::Bilin: // Bilinear interpolation default: mlog << Error << "\nvalid_time_interp() -> " << "unsupported interpolation method encountered: " - << interpmthd_to_string(mthd) << "(" << mthd << ")\n\n"; + << interpmthd_to_string(mthd) << "(" << enum_class_as_int(mthd) << ")\n\n"; exit(1); } @@ -1360,11 +1362,11 @@ DataPlane valid_time_interp(const DataPlane &in1, const DataPlane &in2, if(!is_bad_data(v1) && !is_bad_data(v2)) { // Minimum - if(mthd == InterpMthd_Min) v = min(v1, v2); + if(mthd == InterpMthd::Min) v = min(v1, v2); // Maximum - else if(mthd == InterpMthd_Max) v = max(v1, v2); + else if(mthd == InterpMthd::Max) v = max(v1, v2); // Apply weights - else v = w1*v1 + w2*v2; + else v = w1*v1 + w2*v2; } // Store interpolated value diff --git a/src/basic/vx_util/normalize.cc b/src/basic/vx_util/normalize.cc index 11e8e9a7d2..ab9669e0b8 100644 --- a/src/basic/vx_util/normalize.cc +++ b/src/basic/vx_util/normalize.cc @@ -14,7 +14,9 @@ #include #include +#include "config_util.h" #include "normalize.h" +#include "enum_as_int.hpp" using namespace std; @@ -26,29 +28,29 @@ ConcatString normalizetype_to_string(const NormalizeType type) { // Convert enumerated NormalizeType to string switch(type) { - case NormalizeType_None: + case NormalizeType::None: s = normalizetype_none_str; break; - case NormalizeType_ClimoAnom: + case NormalizeType::ClimoAnom: s = normalizetype_climo_anom_str; break; - case NormalizeType_ClimoStdAnom: + case NormalizeType::ClimoStdAnom: s = normalizetype_climo_std_anom_str; break; - case NormalizeType_FcstAnom: + case NormalizeType::FcstAnom: s = normalizetype_fcst_anom_str; break; - case NormalizeType_FcstStdAnom: + case NormalizeType::FcstStdAnom: s = normalizetype_fcst_std_anom_str; break; default: mlog << Error << "\nnormalizetype_to_string() -> " - << "Unexpected NormalizeType value of " << type << ".\n\n"; + << "Unexpected NormalizeType value of " << enum_class_as_int(type) << ".\n\n"; exit(1); } @@ -67,10 +69,10 @@ void normalize_data(DataPlane &dp, const NormalizeType type, // Supported types switch(type) { - case NormalizeType_None: + case NormalizeType::None: break; - case NormalizeType_ClimoAnom: + case NormalizeType::ClimoAnom: if(!cmn_ptr || dp.nxy() != cmn_ptr->nxy()) { mlog << Error << "\nnormalize_data() -> " << "the climatology mean is required for " @@ -80,7 +82,7 @@ void normalize_data(DataPlane &dp, const NormalizeType type, dp.anomaly(*cmn_ptr); break; - case NormalizeType_ClimoStdAnom: + case NormalizeType::ClimoStdAnom: if(!cmn_ptr || dp.nxy() != cmn_ptr->nxy() || !csd_ptr || dp.nxy() != csd_ptr->nxy()) { mlog << Error << "\nnormalize_data() -> " @@ -91,7 +93,7 @@ void normalize_data(DataPlane &dp, const NormalizeType type, dp.standard_anomaly(*cmn_ptr, *csd_ptr); break; - case NormalizeType_FcstAnom: + case NormalizeType::FcstAnom: if(!fmn_ptr || dp.nxy() != fmn_ptr->nxy()) { mlog << Error << "\nnormalize_data() -> " << "the forecast mean is required for " @@ -101,7 +103,7 @@ void normalize_data(DataPlane &dp, const NormalizeType type, dp.anomaly(*fmn_ptr); break; - case NormalizeType_FcstStdAnom: + case NormalizeType::FcstStdAnom: if(!fmn_ptr || dp.nxy() != fmn_ptr->nxy() || !fsd_ptr || dp.nxy() != fsd_ptr->nxy()) { mlog << Error << "\nnormalize_data() -> " @@ -115,7 +117,7 @@ void normalize_data(DataPlane &dp, const NormalizeType type, default: mlog << Error << "\nnormalize_data() -> " << "unexpected NormalizeType value (" - << type << ")\n\n"; + << enum_class_as_int(type) << ")\n\n"; exit(1); } // end switch diff --git a/src/basic/vx_util/normalize.h b/src/basic/vx_util/normalize.h index b91fa45476..96fc32bc03 100644 --- a/src/basic/vx_util/normalize.h +++ b/src/basic/vx_util/normalize.h @@ -22,12 +22,12 @@ // Enumeration for normalization types // -enum NormalizeType { - NormalizeType_None, // No normalization - NormalizeType_ClimoAnom, // Subtract climo mean - NormalizeType_ClimoStdAnom, // Subtract climo mean and divide stdev - NormalizeType_FcstAnom, // Subtract fcst mean - NormalizeType_FcstStdAnom // Subtract fcst mean and divide stdev +enum class NormalizeType { + None, // No normalization + ClimoAnom, // Subtract climo mean + ClimoStdAnom, // Subtract climo mean and divide stdev + FcstAnom, // Subtract fcst mean + FcstStdAnom // Subtract fcst mean and divide stdev }; /////////////////////////////////////////////////////////////////////////////// diff --git a/src/basic/vx_util/util_constants.h b/src/basic/vx_util/util_constants.h index f80be6f21c..e2520efd18 100644 --- a/src/basic/vx_util/util_constants.h +++ b/src/basic/vx_util/util_constants.h @@ -95,10 +95,6 @@ static const char ws_reg_exp[] = "[ \t\r\n]"; static const char ws_line_reg_exp[] = "^[ \t\r\n]*$"; static const char sep_str[] = "--------------------------------------------------------------------------------"; -// Bootstrap methods -static const int boot_bca_flag = 0; -static const int boot_perc_flag = 1; - //////////////////////////////////////////////////////////////////////// static const int max_line_len = 2048; diff --git a/src/libcode/vx_afm/afmtokentype_to_string.cc b/src/libcode/vx_afm/afmtokentype_to_string.cc index 03ee5c72d4..5d04baffd9 100644 --- a/src/libcode/vx_afm/afmtokentype_to_string.cc +++ b/src/libcode/vx_afm/afmtokentype_to_string.cc @@ -28,7 +28,6 @@ #include "afmtokentype_to_string.h" - using namespace std; diff --git a/src/libcode/vx_analysis_util/stat_job.cc b/src/libcode/vx_analysis_util/stat_job.cc index f5ead39e40..573c0f43d6 100644 --- a/src/libcode/vx_analysis_util/stat_job.cc +++ b/src/libcode/vx_analysis_util/stat_job.cc @@ -22,6 +22,7 @@ #include "vx_statistics.h" #include "vx_math.h" #include "vx_log.h" +#include "enum_as_int.hpp" using namespace std; @@ -110,7 +111,7 @@ void STATAnalysisJob::clear() { precision = default_precision; - job_type = no_stat_job_type; + job_type = STATJobType::None; model.clear(); desc.clear(); @@ -158,7 +159,7 @@ void STATAnalysisJob::clear() { obs_thresh.clear(); cov_thresh.clear(); - thresh_logic = SetLogic_None; + thresh_logic = SetLogic::None; alpha.clear(); @@ -192,14 +193,14 @@ void STATAnalysisJob::clear() { out_fcst_thresh.clear(); out_obs_thresh.clear(); - out_cnt_logic = SetLogic_Union; + out_cnt_logic = SetLogic::Union; out_fcst_wind_thresh.clear(); out_obs_wind_thresh.clear(); - out_wind_logic = SetLogic_Union; + out_wind_logic = SetLogic::Union; out_alpha = bad_data_double; - boot_interval = bad_data_int; + boot_interval = BootIntervalType::None; boot_rep_prop = bad_data_double; n_boot_rep = bad_data_int; @@ -621,7 +622,7 @@ void STATAnalysisJob::dump(ostream & out, int depth) const { << swing_width << "\n"; out << prefix << "boot_interval = " - << boot_interval << "\n"; + << bootintervaltype_to_string(boot_interval) << "\n"; out << prefix << "boot_rep_prop = " << boot_rep_prop << "\n"; @@ -942,7 +943,7 @@ int STATAnalysisJob::is_keeper(const STATLine & L) const { // // thresh_logic // - if(thresh_logic != SetLogic_None && + if(thresh_logic != SetLogic::None && thresh_logic != L.thresh_logic()) return 0; // @@ -1003,7 +1004,7 @@ int STATAnalysisJob::is_keeper(const STATLine & L) const { // // For MPR lines, check mask_grid, mask_poly, and mask_sid // - if(string_to_statlinetype(L.line_type()) == stat_mpr) { + if(string_to_statlinetype(L.line_type()) == STATLineType::mpr) { double lat = atof(L.get_item("OBS_LAT")); double lon = atof(L.get_item("OBS_LON")); @@ -1592,7 +1593,7 @@ void STATAnalysisJob::parse_job_command(const char *jobstring) { i++; } else if(jc_array[i] == "-boot_interval") { - boot_interval = atoi(jc_array[i+1].c_str()); + boot_interval = string_to_bootintervaltype(jc_array[i+1].c_str()); i++; } else if(jc_array[i] == "-boot_rep_prop") { @@ -1704,8 +1705,8 @@ int STATAnalysisJob::set_job_type(const char *c) { job_type = string_to_statjobtype(c); - if(job_type == no_stat_job_type) return 1; - else return 0; + if(job_type == STATJobType::None) return 1; + else return 0; } //////////////////////////////////////////////////////////////////////// @@ -1964,7 +1965,7 @@ void STATAnalysisJob::setup_stat_file(int n_row, int n) { out_sa = (out_line_type.n() > 0 ? out_line_type : line_type); out_lt = (out_sa.n() == 1 ? - string_to_statlinetype(out_sa[0].c_str()) : no_stat_line_type); + string_to_statlinetype(out_sa[0].c_str()) : STATLineType::none); // // Loop through the output line types and determine the number of @@ -1973,38 +1974,38 @@ void STATAnalysisJob::setup_stat_file(int n_row, int n) { for(i=0, c=0, n_col=0; i " << "unexpected stat line type \"" << statlinetype_to_string(cur_lt) @@ -2044,44 +2045,44 @@ void STATAnalysisJob::setup_stat_file(int n_row, int n) { // Write the STAT header row // switch(out_lt) { - case stat_sl1l2: write_header_row (sl1l2_columns, n_sl1l2_columns, 1, stat_at, 0, 0); break; - case stat_sal1l2: write_header_row (sal1l2_columns, n_sal1l2_columns, 1, stat_at, 0, 0); break; - case stat_vl1l2: write_header_row (vl1l2_columns, n_vl1l2_columns, 1, stat_at, 0, 0); break; - case stat_val1l2: write_header_row (val1l2_columns, n_val1l2_columns, 1, stat_at, 0, 0); break; - case stat_fho: write_header_row (fho_columns, n_fho_columns, 1, stat_at, 0, 0); break; - case stat_ctc: write_header_row (ctc_columns, n_ctc_columns, 1, stat_at, 0, 0); break; - case stat_cts: write_header_row (cts_columns, n_cts_columns, 1, stat_at, 0, 0); break; - case stat_mctc: write_mctc_header_row (1, n, stat_at, 0, 0); break; - case stat_mcts: write_header_row (mcts_columns, n_mcts_columns, 1, stat_at, 0, 0); break; - case stat_cnt: write_header_row (cnt_columns, n_cnt_columns, 1, stat_at, 0, 0); break; - case stat_vcnt: write_header_row (vcnt_columns, n_vcnt_columns, 1, stat_at, 0, 0); break; - case stat_pct: write_pct_header_row (1, n, stat_at, 0, 0); break; - case stat_pstd: write_pstd_header_row (1, n, stat_at, 0, 0); break; - case stat_pjc: write_pjc_header_row (1, n, stat_at, 0, 0); break; - case stat_prc: write_prc_header_row (1, n, stat_at, 0, 0); break; - case stat_eclv: write_eclv_header_row (1, n, stat_at, 0, 0); break; - case stat_mpr: write_header_row (mpr_columns, n_mpr_columns, 1, stat_at, 0, 0); break; - case stat_nbrctc: write_header_row (nbrctc_columns, n_nbrctc_columns, 1, stat_at, 0, 0); break; - case stat_nbrcts: write_header_row (nbrcts_columns, n_nbrcts_columns, 1, stat_at, 0, 0); break; - case stat_nbrcnt: write_header_row (nbrcnt_columns, n_nbrcnt_columns, 1, stat_at, 0, 0); break; - case stat_grad: write_header_row (grad_columns, n_grad_columns, 1, stat_at, 0, 0); break; - case stat_isc: write_header_row (isc_columns, n_isc_columns, 1, stat_at, 0, 0); break; - case stat_wdir: write_header_row (job_wdir_columns, n_job_wdir_columns, 1, stat_at, 0, 0); break; - case stat_ecnt: write_header_row (ecnt_columns, n_ecnt_columns, 1, stat_at, 0, 0); break; - case stat_rps: write_header_row (rps_columns, n_rps_columns, 1, stat_at, 0, 0); break; - case stat_rhist: write_rhist_header_row (1, n, stat_at, 0, 0); break; - case stat_phist: write_phist_header_row (1, n, stat_at, 0, 0); break; - case stat_relp: write_relp_header_row (1, n, stat_at, 0, 0); break; - case stat_orank: write_header_row (orank_columns, n_orank_columns, 1, stat_at, 0, 0); break; - case stat_ssvar: write_header_row (ssvar_columns, n_ssvar_columns, 1, stat_at, 0, 0); break; - case stat_genmpr: write_header_row (genmpr_columns, n_genmpr_columns, 1, stat_at, 0, 0); break; - case stat_ssidx: write_header_row (ssidx_columns, n_ssidx_columns, 1, stat_at, 0, 0); break; + case STATLineType::sl1l2: write_header_row (sl1l2_columns, n_sl1l2_columns, 1, stat_at, 0, 0); break; + case STATLineType::sal1l2: write_header_row (sal1l2_columns, n_sal1l2_columns, 1, stat_at, 0, 0); break; + case STATLineType::vl1l2: write_header_row (vl1l2_columns, n_vl1l2_columns, 1, stat_at, 0, 0); break; + case STATLineType::val1l2: write_header_row (val1l2_columns, n_val1l2_columns, 1, stat_at, 0, 0); break; + case STATLineType::fho: write_header_row (fho_columns, n_fho_columns, 1, stat_at, 0, 0); break; + case STATLineType::ctc: write_header_row (ctc_columns, n_ctc_columns, 1, stat_at, 0, 0); break; + case STATLineType::cts: write_header_row (cts_columns, n_cts_columns, 1, stat_at, 0, 0); break; + case STATLineType::mctc: write_mctc_header_row (1, n, stat_at, 0, 0); break; + case STATLineType::mcts: write_header_row (mcts_columns, n_mcts_columns, 1, stat_at, 0, 0); break; + case STATLineType::cnt: write_header_row (cnt_columns, n_cnt_columns, 1, stat_at, 0, 0); break; + case STATLineType::vcnt: write_header_row (vcnt_columns, n_vcnt_columns, 1, stat_at, 0, 0); break; + case STATLineType::pct: write_pct_header_row (1, n, stat_at, 0, 0); break; + case STATLineType::pstd: write_pstd_header_row (1, n, stat_at, 0, 0); break; + case STATLineType::pjc: write_pjc_header_row (1, n, stat_at, 0, 0); break; + 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::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; + case STATLineType::grad: write_header_row (grad_columns, n_grad_columns, 1, stat_at, 0, 0); break; + case STATLineType::isc: write_header_row (isc_columns, n_isc_columns, 1, stat_at, 0, 0); break; + case STATLineType::wdir: write_header_row (job_wdir_columns, n_job_wdir_columns, 1, stat_at, 0, 0); break; + case STATLineType::ecnt: write_header_row (ecnt_columns, n_ecnt_columns, 1, stat_at, 0, 0); break; + case STATLineType::rps: write_header_row (rps_columns, n_rps_columns, 1, stat_at, 0, 0); break; + case STATLineType::rhist: write_rhist_header_row (1, n, stat_at, 0, 0); break; + case STATLineType::phist: write_phist_header_row (1, n, stat_at, 0, 0); break; + case STATLineType::relp: write_relp_header_row (1, n, stat_at, 0, 0); break; + case STATLineType::orank: write_header_row (orank_columns, n_orank_columns, 1, stat_at, 0, 0); break; + case STATLineType::ssvar: write_header_row (ssvar_columns, n_ssvar_columns, 1, stat_at, 0, 0); break; + case STATLineType::genmpr: write_header_row (genmpr_columns, n_genmpr_columns, 1, stat_at, 0, 0); break; + case STATLineType::ssidx: write_header_row (ssidx_columns, n_ssidx_columns, 1, stat_at, 0, 0); break; // // Write only header columns for unspecified line type // - case no_stat_line_type: - write_header_row ((const char **) 0, 0, 1, stat_at, 0, 0); break; + case STATLineType::none: + write_header_row ((const char **) 0, 0, 1, stat_at, 0, 0); break; default: mlog << Error << "\nSTATAnalysisJob::setup_stat_file() -> " @@ -2175,91 +2176,91 @@ void STATAnalysisJob::dump_stat_line(const STATLine &line, if(line_type.n() == 1) { switch(string_to_statlinetype(line_type[0].c_str())) { - case(stat_fho): + case STATLineType::fho: write_header_row(fho_columns, n_fho_columns, 1, dump_at, 0, 0); break; - case(stat_ctc): + case STATLineType::ctc: write_header_row(ctc_columns, n_ctc_columns, 1, dump_at, 0, 0); break; - case(stat_cts): + case STATLineType::cts: write_header_row(cts_columns, n_cts_columns, 1, dump_at, 0, 0); break; - case(stat_cnt): + case STATLineType::cnt: write_header_row(cnt_columns, n_cnt_columns, 1, dump_at, 0, 0); break; - case(stat_sl1l2): + case STATLineType::sl1l2: write_header_row(sl1l2_columns, n_sl1l2_columns, 1, dump_at, 0, 0); break; - case(stat_sal1l2): + case STATLineType::sal1l2: write_header_row(sal1l2_columns, n_sal1l2_columns, 1, dump_at, 0, 0); break; - case(stat_vl1l2): + case STATLineType::vl1l2: write_header_row(vl1l2_columns, n_vl1l2_columns, 1, dump_at, 0, 0); break; - case(stat_val1l2): + case STATLineType::val1l2: write_header_row(val1l2_columns, n_val1l2_columns, 1, dump_at, 0, 0); break; - case(stat_mpr): + case STATLineType::mpr: write_header_row(mpr_columns, n_mpr_columns, 1, dump_at, 0, 0); break; - case(stat_nbrctc): + case STATLineType::nbrctc: write_header_row(nbrctc_columns, n_nbrctc_columns, 1, dump_at, 0, 0); break; - case(stat_nbrcts): + case STATLineType::nbrcts: write_header_row(nbrcts_columns, n_nbrcts_columns, 1, dump_at, 0, 0); break; - case(stat_nbrcnt): + case STATLineType::nbrcnt: write_header_row(nbrcnt_columns, n_nbrcnt_columns, 1, dump_at, 0, 0); break; - case(stat_grad): + case STATLineType::grad: write_header_row(grad_columns, n_grad_columns, 1, dump_at, 0, 0); break; - case(stat_ecnt): + case STATLineType::ecnt: write_header_row(ecnt_columns, n_ecnt_columns, 1, dump_at, 0, 0); break; - case(stat_isc): + case STATLineType::isc: write_header_row(isc_columns, n_isc_columns, 1, dump_at, 0, 0); break; - case(stat_ssvar): + case STATLineType::ssvar: write_header_row(ssvar_columns, n_ssvar_columns, 1, dump_at, 0, 0); break; - case(stat_seeps): + case STATLineType::seeps: write_header_row(seeps_columns, n_seeps_columns, 1, dump_at, 0, 0); break; - case(stat_seeps_mpr): + case STATLineType::seeps_mpr: write_header_row(seeps_mpr_columns, n_seeps_mpr_columns, 1, dump_at, 0, 0); break; // Just write a STAT header line for indeterminant line types - case(stat_mctc): - case(stat_mcts): - case(stat_pct): - case(stat_pstd): - case(stat_pjc): - case(stat_prc): - case(stat_eclv): - case(stat_rhist): - case(stat_phist): - case(stat_relp): - case(stat_orank): - case(stat_genmpr): + case STATLineType::mctc: + case STATLineType::mcts: + case STATLineType::pct: + case STATLineType::pstd: + case STATLineType::pjc: + case STATLineType::prc: + case STATLineType::eclv: + case STATLineType::rhist: + case STATLineType::phist: + case STATLineType::relp: + case STATLineType::orank: + case STATLineType::genmpr: write_header_row((const char **) 0, 0, 1, dump_at, 0, 0); break; @@ -2347,7 +2348,7 @@ ConcatString STATAnalysisJob::get_jobstring() const { js.clear(); // job type - if(job_type != no_stat_job_type) { + if(job_type != STATJobType::None) { js << "-job " << statjobtype_to_string(job_type) << " "; } @@ -2567,7 +2568,7 @@ ConcatString STATAnalysisJob::get_jobstring() const { } // thresh_logic - if(thresh_logic != SetLogic_None) { + if(thresh_logic != SetLogic::None) { js << "-thresh_logic " << setlogic_to_string(thresh_logic) << " "; } @@ -2690,7 +2691,7 @@ ConcatString STATAnalysisJob::get_jobstring() const { } // out_cnt_logic - if(job_type == stat_job_aggr_stat && + if(job_type == STATJobType::aggr_stat && line_type.has(stat_mpr_str) && (out_line_type.has(stat_cnt_str) || out_line_type.has(stat_sl1l2_str)) && (out_fcst_thresh.n() > 0 || out_obs_thresh.n() > 0)) { @@ -2716,7 +2717,7 @@ ConcatString STATAnalysisJob::get_jobstring() const { } // out_wind_logic - if(job_type == stat_job_aggr_stat && + if(job_type == STATJobType::aggr_stat && line_type.has(stat_mpr_str) && out_line_type.has(stat_wdir_str) && (out_fcst_wind_thresh.get_type() != thresh_na || @@ -2725,7 +2726,7 @@ ConcatString STATAnalysisJob::get_jobstring() const { } // Jobs which use out_alpha - if(job_type == stat_job_summary || + if(job_type == STATJobType::summary || out_line_type.has(stat_cts_str) || out_line_type.has(stat_mcts_str) || out_line_type.has(stat_cnt_str) || @@ -2738,12 +2739,12 @@ ConcatString STATAnalysisJob::get_jobstring() const { } // Ramp jobs - if(job_type == stat_job_ramp) { + if(job_type == STATJobType::ramp) { // ramp_type js << "-ramp_type " << timeseriestype_to_string(ramp_type) << " "; - if(ramp_type == TimeSeriesType_DyDt) { + if(ramp_type == TimeSeriesType::DyDt) { // ramp_time if(ramp_time_fcst == ramp_time_obs) { @@ -2767,7 +2768,7 @@ ConcatString STATAnalysisJob::get_jobstring() const { } } - if(ramp_type == TimeSeriesType_Swing) { + if(ramp_type == TimeSeriesType::Swing) { // swing_width js << "-swing_width " << swing_width << " "; @@ -2789,7 +2790,7 @@ ConcatString STATAnalysisJob::get_jobstring() const { // Jobs which use out_bin_size if(line_type.n() > 0) { - if(string_to_statlinetype(line_type[0].c_str()) == stat_orank && + if(string_to_statlinetype(line_type[0].c_str()) == STATLineType::orank && (out_line_type.has(stat_phist_str) || out_line_type.has(stat_ecnt_str))) { @@ -2798,9 +2799,9 @@ ConcatString STATAnalysisJob::get_jobstring() const { } } - // Jobs which use out_eclv_points if(line_type.n() > 0) { - if(string_to_statlinetype(line_type[0].c_str()) == stat_mpr && + // Jobs which use out_eclv_points + if(string_to_statlinetype(line_type[0].c_str()) == STATLineType::mpr && out_line_type.has(stat_eclv_str)) { // out_eclv_points @@ -2808,12 +2809,10 @@ ConcatString STATAnalysisJob::get_jobstring() const { js << "-out_eclv_points " << out_eclv_points[i] << " "; } } - } - // Jobs which perform bootstrapping - if(line_type.n() > 0) { + // Jobs which perform bootstrapping type = string_to_statlinetype(line_type[0].c_str()); - if(type == stat_mpr && + if(type == STATLineType::mpr && (out_line_type.has(stat_cts_str) || out_line_type.has(stat_mcts_str) || out_line_type.has(stat_cnt_str) || @@ -2821,7 +2820,7 @@ ConcatString STATAnalysisJob::get_jobstring() const { out_line_type.has(stat_nbrcnt_str))) { // Bootstrap Information - js << "-boot_interval " << boot_interval << " "; + js << "-boot_interval " << bootintervaltype_to_string(boot_interval) << " "; js << "-boot_rep_prop " << boot_rep_prop << " "; js << "-n_boot_rep " << n_boot_rep << " "; js << "-boot_rng " << boot_rng << " "; @@ -2837,9 +2836,9 @@ ConcatString STATAnalysisJob::get_jobstring() const { } // Jobs which compute the skill score index - if(job_type == stat_job_go_index || - job_type == stat_job_cbs_index || - job_type == stat_job_ss_index) { + if(job_type == STATJobType::go_index || + job_type == STATJobType::cbs_index || + job_type == STATJobType::ss_index) { // ss_index_name js << "-ss_index_name " << ss_index_name << " "; @@ -2937,7 +2936,7 @@ int STATAnalysisJob::is_in_mask_sid(const char *sid) const { //////////////////////////////////////////////////////////////////////// const char * statjobtype_to_string(const STATJobType t) { - return statjobtype_str[t]; + return statjobtype_str[enum_class_as_int(t)]; } //////////////////////////////////////////////////////////////////////// @@ -2956,23 +2955,23 @@ STATJobType string_to_statjobtype(const char *str) { STATJobType t; if( strcasecmp(str, statjobtype_str[0]) == 0) - t = stat_job_filter; + t = STATJobType::filter; else if(strcasecmp(str, statjobtype_str[1]) == 0) - t = stat_job_summary; + t = STATJobType::summary; else if(strcasecmp(str, statjobtype_str[2]) == 0) - t = stat_job_aggr; + t = STATJobType::aggr; else if(strcasecmp(str, statjobtype_str[3]) == 0) - t = stat_job_aggr_stat; + t = STATJobType::aggr_stat; else if(strcasecmp(str, statjobtype_str[4]) == 0) - t = stat_job_go_index; + t = STATJobType::go_index; else if(strcasecmp(str, statjobtype_str[5]) == 0) - t = stat_job_cbs_index; + t = STATJobType::cbs_index; else if(strcasecmp(str, statjobtype_str[6]) == 0) - t = stat_job_ss_index; + t = STATJobType::ss_index; else if(strcasecmp(str, statjobtype_str[7]) == 0) - t = stat_job_ramp; + t = STATJobType::ramp; else - t = no_stat_job_type; + t = STATJobType::None; return t; } diff --git a/src/libcode/vx_analysis_util/stat_job.h b/src/libcode/vx_analysis_util/stat_job.h index 96ee2fc103..208c6d4894 100644 --- a/src/libcode/vx_analysis_util/stat_job.h +++ b/src/libcode/vx_analysis_util/stat_job.h @@ -37,7 +37,7 @@ static const bool default_column_union = false; // // Ramp job type defaults // -static const TimeSeriesType default_ramp_type = TimeSeriesType_DyDt; +static const TimeSeriesType default_ramp_type = TimeSeriesType::DyDt; static const char default_ramp_line_type[] = "MPR"; static const char default_ramp_out_line_type[] = "CTC,CTS"; static const char default_ramp_fcst_col[] = "FCST"; @@ -57,30 +57,30 @@ static const int dump_stat_buffer_cols = 512; // // Enumerate all the possible STAT Analysis Job Types // -enum STATJobType { +enum class STATJobType { - stat_job_filter = 0, // Filter out the STAT data and write the - // lines to the filename specified. + filter = 0, /* Filter out the STAT data and write the + lines to the filename specified. */ - stat_job_summary = 1, // Compute min, max, mean, stdev and - // percentiles for a column of data. + summary = 1, /* Compute min, max, mean, stdev and + percentiles for a column of data. */ - stat_job_aggr = 2, // Aggregate the input counts/scores and - // generate the same output line type - // containing the aggregated counts/scores. + aggr = 2, /* Aggregate the input counts/scores and + generate the same output line type + containing the aggregated counts/scores. */ - stat_job_aggr_stat = 3, // Aggregate the input counts/scores and - // generate the requested output line type. + aggr_stat = 3, /* Aggregate the input counts/scores and + generate the requested output line type. */ - stat_job_go_index = 4, // Compute the GO Index. + go_index = 4, /* Compute the GO Index. */ - stat_job_cbs_index = 5, // Compute the CBS Index. + cbs_index = 5, /* Compute the CBS Index. */ - stat_job_ss_index = 6, // Compute the Skill Score Index. + ss_index = 6, /* Compute the Skill Score Index. */ - stat_job_ramp = 7, // Time-series ramp evaluation. + ramp = 7, /* Time-series ramp evaluation. */ - no_stat_job_type = 8 // Default value + None = 8 /* Default value */ }; static const int n_statjobtypes = 9; @@ -267,14 +267,14 @@ class STATAnalysisJob { NumArray out_eclv_points; // output ECLV points // - // Variables used for the stat_job_summary job type + // Variables used for the STATJobType::summary job type // bool do_derive; StringArray wmo_sqrt_stats; StringArray wmo_fisher_stats; // - // Variables used for the stat_job_aggr_mpr job type + // Variables used for the STATJobType::aggr_mpr job type // ConcatString mask_grid_str; ConcatString mask_poly_str; @@ -286,7 +286,7 @@ class STATAnalysisJob { StringArray mask_sid; // - // Variables used for the stat_job_ramp job type + // Variables used for the STATJobType::ramp job type // TimeSeriesType ramp_type; int ramp_time_fcst; // stored in seconds @@ -305,9 +305,8 @@ class STATAnalysisJob { // // Type of bootstrap confidence interval method: - // 0 = BCa, 1 = Percentile (Default = 1) // - int boot_interval; + BootIntervalType boot_interval; // // When using the percentile method, this is the proportion diff --git a/src/libcode/vx_analysis_util/stat_line.cc b/src/libcode/vx_analysis_util/stat_line.cc index a8f869fa74..c3006b5189 100644 --- a/src/libcode/vx_analysis_util/stat_line.cc +++ b/src/libcode/vx_analysis_util/stat_line.cc @@ -140,7 +140,7 @@ void STATLine::clear() DataLine::clear(); -Type = no_stat_line_type; +Type = STATLineType::none; HdrLine = (AsciiHeaderLine *) nullptr; return; @@ -265,7 +265,7 @@ if ( !status || n_items() == 0 ) { if ( strcmp(get_item(0), "VERSION") == 0 ) { - Type = stat_header; + Type = STATLineType::header; return 1; } @@ -278,7 +278,7 @@ offset = METHdrTable.col_offset(get_item(0), "STAT", na_str, "LINE_TYPE"); if( is_bad_data(offset) || n_items() < (offset + 1) ) { - Type = no_stat_line_type; + Type = STATLineType::none; return 0; } @@ -315,7 +315,7 @@ bool STATLine::is_header() const { -return ( Type == stat_header ); +return ( Type == STATLineType::header ); } @@ -829,14 +829,14 @@ SetLogic STATLine::thresh_logic() const { -SetLogic t = SetLogic_None; +SetLogic t = SetLogic::None; ConcatString cs = (string)get_item("FCST_THRESH", false); - if(cs.endswith(setlogic_symbol_union)) t = SetLogic_Union; -else if(cs.endswith(setlogic_symbol_intersection)) t = SetLogic_Intersection; -else if(cs.endswith(setlogic_symbol_symdiff)) t = SetLogic_SymDiff; -else t = SetLogic_None; + if(cs.endswith(setlogic_symbol_union)) t = SetLogic::Union; +else if(cs.endswith(setlogic_symbol_intersection)) t = SetLogic::Intersection; +else if(cs.endswith(setlogic_symbol_symdiff)) t = SetLogic::SymDiff; +else t = SetLogic::None; return t; diff --git a/src/libcode/vx_grid/tcrmw_grid.cc b/src/libcode/vx_grid/tcrmw_grid.cc index 507c1874b8..a2e1738e1b 100644 --- a/src/libcode/vx_grid/tcrmw_grid.cc +++ b/src/libcode/vx_grid/tcrmw_grid.cc @@ -213,8 +213,9 @@ RLLD.rot_lat_ll = 90.0 - range_max_deg; RLLD.rot_lon_ll = 0.0; RLLD.delta_rot_lat = range_max_deg/(Range_n - 1); -// RLLD.delta_rot_lon = 360.0/Azimuth_n; -RLLD.delta_rot_lon = 360.0/(Azimuth_n - 1); + +// MET #2833 divide by n rather than n-1 for the azimuth increment +RLLD.delta_rot_lon = 360.0/Azimuth_n; RLLD.Nlat = Range_n; RLLD.Nlon = Azimuth_n; diff --git a/src/libcode/vx_grid/tcrmw_grid.h b/src/libcode/vx_grid/tcrmw_grid.h index 010748bff9..8af34d9261 100644 --- a/src/libcode/vx_grid/tcrmw_grid.h +++ b/src/libcode/vx_grid/tcrmw_grid.h @@ -69,7 +69,7 @@ class TcrmwGrid : public RotatedLatLonGrid { int azimuth_n () const; double range_max_km () const; - double range_delta_km () const; // Range_Max_km/Range_n + double range_delta_km () const; // Range_max_km/(Range_n - 1) double azimuth_delta_deg () const; // 360.0/Azimuth_n @@ -117,7 +117,7 @@ inline int TcrmwGrid::azimuth_n () const { return ( Azimuth_n ); } inline double TcrmwGrid::range_max_km () const { return ( Range_max_km ); } -inline double TcrmwGrid::range_delta_km () const { return ( Range_max_km/Range_n ); } +inline double TcrmwGrid::range_delta_km () const { return ( Range_max_km/(Range_n - 1) ); } inline double TcrmwGrid::azimuth_delta_deg () const { return ( 360.0/Azimuth_n ); } diff --git a/src/libcode/vx_gsl_prob/gsl_randist.cc b/src/libcode/vx_gsl_prob/gsl_randist.cc index 3a9d87442d..956e912727 100644 --- a/src/libcode/vx_gsl_prob/gsl_randist.cc +++ b/src/libcode/vx_gsl_prob/gsl_randist.cc @@ -219,31 +219,31 @@ double ran_draw(const gsl_rng *r, DistType t, double p1, double p2) { // Switch on the distribution type switch(t) { - case(DistType_Normal): + case(DistType::Normal): v = gsl_ran_gaussian(r, p1); break; - case(DistType_Exponential): + case(DistType::Exponential): v = gsl_ran_exponential(r, p1); break; - case(DistType_ChiSquared): + case(DistType::ChiSquared): v = gsl_ran_chisq(r, p1); break; - case(DistType_Gamma): + case(DistType::Gamma): v = gsl_ran_gamma(r, p1, p2); break; - case(DistType_Uniform): + case(DistType::Uniform): v = gsl_ran_flat(r, p1, p2); break; - case(DistType_Beta): + case(DistType::Beta): v = gsl_ran_beta(r, p1, p2); break; - case(DistType_None): + case(DistType::None): default: v = 0.0; break; @@ -269,31 +269,31 @@ double dist_var(DistType t, double p1, double p2) { // Switch on the distribution type switch(t) { - case(DistType_Normal): + case(DistType::Normal): v = p1*p1; break; - case(DistType_Exponential): + case(DistType::Exponential): v = 1.0 / (p1*p1); break; - case(DistType_ChiSquared): + case(DistType::ChiSquared): v = 2*p1; break; - case(DistType_Gamma): + case(DistType::Gamma): v = p1 / (p2*p2); break; - case(DistType_Uniform): + case(DistType::Uniform): v = ((p2-p1)*(p2-p1)) / 12.0; break; - case(DistType_Beta): + case(DistType::Beta): v = (p1*p2) / ((p1+p2)*(p1+p2)*(p1+p2+1.0)); break; - case(DistType_None): + case(DistType::None): default: v = 0.0; break; diff --git a/src/libcode/vx_gsl_prob/gsl_randist.h b/src/libcode/vx_gsl_prob/gsl_randist.h index e66c312230..1e8555e0d4 100644 --- a/src/libcode/vx_gsl_prob/gsl_randist.h +++ b/src/libcode/vx_gsl_prob/gsl_randist.h @@ -23,14 +23,14 @@ // Enumeration for distribution types // -enum DistType { - DistType_None, // No distribution - DistType_Normal, // Normal distribution - DistType_Exponential, // Exponential distribution - DistType_ChiSquared, // Chi-Squared distribution - DistType_Gamma, // Gamma distribution - DistType_Uniform, // Uniform distribution - DistType_Beta // Beta distribution +enum class DistType { + None, // No distribution + Normal, // Normal distribution + Exponential, // Exponential distribution + ChiSquared, // Chi-Squared distribution + Gamma, // Gamma distribution + Uniform, // Uniform distribution + Beta // Beta distribution }; //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_nc_util/write_netcdf.cc b/src/libcode/vx_nc_util/write_netcdf.cc index 0f141ac50e..6a747cf7df 100644 --- a/src/libcode/vx_nc_util/write_netcdf.cc +++ b/src/libcode/vx_nc_util/write_netcdf.cc @@ -228,12 +228,12 @@ void write_netcdf_grid_weight(NcFile *f_out, NcDim *lat_dim, NcDim *lon_dim, switch(t) { - case GridWeightType_Cos_Lat: + case GridWeightType::Cos_Lat: add_att(&wgt_var, long_name_att_name, "cosine latitude grid weight"); add_att(&wgt_var, units_att_name, "NA"); break; - case GridWeightType_Area: + case GridWeightType::Area: add_att(&wgt_var, long_name_att_name, "true area grid weight"); add_att(&wgt_var, units_att_name, "km^2"); break; diff --git a/src/libcode/vx_pb_util/do_blocking.cc b/src/libcode/vx_pb_util/do_blocking.cc index 0a62342983..0e6df01b22 100644 --- a/src/libcode/vx_pb_util/do_blocking.cc +++ b/src/libcode/vx_pb_util/do_blocking.cc @@ -115,13 +115,13 @@ unsigned char * b = (unsigned char *) nullptr; switch ( padsize ) { - case padsize_4: + case PadSize::size_4: bytes = 4; b = (unsigned char *) (&I); I = (unsigned int) value; break; - case padsize_8: + case PadSize::size_8: bytes = 8; b = (unsigned char *) (&L); L = (unsigned long long) value; diff --git a/src/libcode/vx_pb_util/do_unblocking.cc b/src/libcode/vx_pb_util/do_unblocking.cc index e0fa2ef90d..0a159c31e6 100644 --- a/src/libcode/vx_pb_util/do_unblocking.cc +++ b/src/libcode/vx_pb_util/do_unblocking.cc @@ -85,12 +85,12 @@ unsigned char * b = (unsigned char *) nullptr; switch ( padsize ) { - case padsize_4: + case PadSize::size_4: bytes = 4; b = (unsigned char *) (&I); break; - case padsize_8: + case PadSize::size_8: bytes = 8; b = (unsigned char *) (&L); break; @@ -119,11 +119,11 @@ if ( (n_read < 0) || ((n_read > 0) && (n_read != bytes)) ) { switch ( padsize ) { - case padsize_4: + case PadSize::size_4: value = I; break; - case padsize_8: + case PadSize::size_8: value = (int) L; break; diff --git a/src/libcode/vx_pb_util/pblock.cc b/src/libcode/vx_pb_util/pblock.cc index 0626c0ac39..f8b2f3cecc 100644 --- a/src/libcode/vx_pb_util/pblock.cc +++ b/src/libcode/vx_pb_util/pblock.cc @@ -57,9 +57,9 @@ void pblock(const char *infile, const char *outfile, Action action) { // Set the block size for this compiler // #ifdef BLOCK4 - padsize = padsize_4; + padsize = PadSize::size_4; #else - padsize = padsize_8; + padsize = PadSize::size_8; #endif // @@ -67,11 +67,11 @@ void pblock(const char *infile, const char *outfile, Action action) { // switch(action) { - case block: + case Action::block: do_blocking(in, out, padsize); break; - case unblock: + case Action::unblock: do_unblocking(in, out, padsize); break; diff --git a/src/libcode/vx_pb_util/pblock.h b/src/libcode/vx_pb_util/pblock.h index cab711e358..43a4b32fe5 100644 --- a/src/libcode/vx_pb_util/pblock.h +++ b/src/libcode/vx_pb_util/pblock.h @@ -18,12 +18,12 @@ //////////////////////////////////////////////////////////////////////// -enum PadSize { +enum class PadSize { - padsize_4, - padsize_8, + size_4, + size_8, - no_padsize + no_pad }; @@ -31,7 +31,7 @@ enum PadSize { //////////////////////////////////////////////////////////////////////// -enum Action { +enum class Action { block, unblock, diff --git a/src/libcode/vx_plot_util/vx_plot_util.h b/src/libcode/vx_plot_util/vx_plot_util.h index 5ba9a597bb..4d8aedfe7d 100644 --- a/src/libcode/vx_plot_util/vx_plot_util.h +++ b/src/libcode/vx_plot_util/vx_plot_util.h @@ -37,7 +37,7 @@ //////////////////////////////////////////////////////////////////////////////// -typedef enum {satellite, lambert, mercator} Projection; +/* enum Projection {satellite, lambert, mercator} Projection; */ //////////////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_python3_utils/point.py b/src/libcode/vx_python3_utils/point.py deleted file mode 100644 index 699aa46e51..0000000000 --- a/src/libcode/vx_python3_utils/point.py +++ /dev/null @@ -1,39 +0,0 @@ - - -############################################################### - - -import sys - - -############################################################### - -print ('============= start point.py ===========') - -print (sys.argv) - - -############################################################### - - -point_data = [[ 'ADPUPA', '72365', '20070331_120000', 35.03, -106.62, 1618.0, 7, 837.0, 1618, 'NA', 1618 ], - [ 'ADPUPA', '72365', '20070331_120000', 35.03, -106.62, 1618.0, 11, 837.0, 1618, 'NA', 273.05 ], - [ 'ADPUPA', '72365', '20070331_120000', 35.03, -106.62, 1618.0, 17, 837.0, 1618, 'NA', 271.85 ], - [ 'ADPUPA', '72365', '20070331_120000', 35.03, -106.62, 1618.0, 52, 837.0, 1618, 'NA', 92 ], - [ 'ADPUPA', '72365', '20070331_120000', 35.03, -106.62, 1618.0, 53, 837.0, 1618, 'NA', 0.00417 ], - [ 'ADPUPA', '72365', '20070331_120000', 35.03, -106.62, 1618.0, 7, 826.0, 1724, 'NA', 1724 ], - [ 'ADPUPA', '72365', '20070331_120000', 35.03, -106.62, 1618.0, 11, 826.0, 1724, 'NA', 274.55 ]] - - -############################################################### - - -print (point_data) - - -print ('============= end point.py ===========') - - -############################################################### - - diff --git a/src/libcode/vx_regrid/vx_regrid.cc b/src/libcode/vx_regrid/vx_regrid.cc index 418cceb5c3..7abfee78b4 100644 --- a/src/libcode/vx_regrid/vx_regrid.cc +++ b/src/libcode/vx_regrid/vx_regrid.cc @@ -32,30 +32,30 @@ DataPlane out; switch ( info.method ) { - case InterpMthd_Min: - case InterpMthd_Max: - case InterpMthd_Median: - case InterpMthd_UW_Mean: - case InterpMthd_DW_Mean: - case InterpMthd_LS_Fit: - case InterpMthd_Bilin: - case InterpMthd_Nearest: + case InterpMthd::Min: + case InterpMthd::Max: + case InterpMthd::Median: + case InterpMthd::UW_Mean: + case InterpMthd::DW_Mean: + case InterpMthd::LS_Fit: + case InterpMthd::Bilin: + case InterpMthd::Nearest: out = met_regrid_generic (in, from_grid, to_grid, info); break; - case InterpMthd_Budget: + case InterpMthd::Budget: out = met_regrid_budget (in, from_grid, to_grid, info); break; - case InterpMthd_AW_Mean: + case InterpMthd::AW_Mean: out = met_regrid_area_weighted (in, from_grid, to_grid, info); break; - case InterpMthd_Force: + case InterpMthd::Force: out = met_regrid_force (in, from_grid, to_grid, info); break; - case InterpMthd_MaxGauss: + case InterpMthd::MaxGauss: out = met_regrid_maxgauss (in, from_grid, to_grid, info); break; @@ -97,9 +97,9 @@ DataPlane met_regrid_nearest (const DataPlane & from_data, const Grid & from_gri RegridInfo ri; ri.enable = true; -ri.method = InterpMthd_Nearest; +ri.method = InterpMthd::Nearest; ri.width = 1; -ri.shape = GridTemplateFactory::GridTemplate_Square; +ri.shape = GridTemplateFactory::GridTemplates::Square; return met_regrid_generic(from_data, from_grid, to_grid, ri); @@ -346,7 +346,7 @@ for (xt=0; xt<(to_grid.nx()); ++xt) { } else { value = compute_horz_interp(from_data, x_from, y_from, - bad_data_double, InterpMthd_Max, info.width, + bad_data_double, InterpMthd::Max, info.width, info.shape, from_grid.wrap_lon(), info.vld_thresh); } diff --git a/src/libcode/vx_shapedata/engine.cc b/src/libcode/vx_shapedata/engine.cc index e0fc008464..dcc5840a47 100644 --- a/src/libcode/vx_shapedata/engine.cc +++ b/src/libcode/vx_shapedata/engine.cc @@ -17,6 +17,7 @@ #include #include +#include "enum_as_int.hpp" #include "engine.h" #include "mode_columns.h" #include "vx_util.h" @@ -191,7 +192,7 @@ void ModeFuzzyEngine::init_from_scratch() { clear_features(); - data_type = ModeDataType_Traditional; + data_type = ModeDataType::Traditional; return; } @@ -248,9 +249,9 @@ void ModeFuzzyEngine::clear_colors() { void ModeFuzzyEngine::set(const ShapeData &fcst_wd, const ShapeData &obs_wd) { - if (data_type == ModeDataType_MvMode_Fcst) { + if (data_type == ModeDataType::MvMode_Fcst) { set_fcst(fcst_wd); - } else if (data_type == ModeDataType_MvMode_Obs) { + } else if (data_type == ModeDataType::MvMode_Obs) { set_obs(obs_wd); } else { ConcatString path; @@ -279,9 +280,9 @@ void ModeFuzzyEngine::set(const ShapeData &fcst_wd, const ShapeData &obs_wd) void ModeFuzzyEngine::set_no_conv(const ShapeData &fcst_wd, const ShapeData &obs_wd) { - if (data_type == ModeDataType_MvMode_Fcst) { + if (data_type == ModeDataType::MvMode_Fcst) { set_fcst_no_conv(fcst_wd); - } else if (data_type == ModeDataType_MvMode_Obs) { + } else if (data_type == ModeDataType::MvMode_Obs) { set_obs_no_conv ( obs_wd); } else { ConcatString path; @@ -310,9 +311,9 @@ void ModeFuzzyEngine::set_only_split(const ShapeData &fcst_wd, const ShapeData & { - if (data_type == ModeDataType_MvMode_Fcst) { + if (data_type == ModeDataType::MvMode_Fcst) { set_fcst_only_split (fcst_wd); - } else if (data_type == ModeDataType_MvMode_Obs) { + } else if (data_type == ModeDataType::MvMode_Obs) { set_obs_only_split ( obs_wd); } else { ConcatString path; @@ -916,12 +917,12 @@ void ModeFuzzyEngine::do_fcst_merging(const char *default_config, if(!need_fcst_merge) return; - if(conf_info.Fcst->merge_flag == MergeType_Both || - conf_info.Fcst->merge_flag == MergeType_Thresh) + if(conf_info.Fcst->merge_flag == MergeType::Both || + conf_info.Fcst->merge_flag == MergeType::Thresh) do_fcst_merge_thresh(); - if(conf_info.Fcst->merge_flag == MergeType_Both || - conf_info.Fcst->merge_flag == MergeType_Engine) + if(conf_info.Fcst->merge_flag == MergeType::Both || + conf_info.Fcst->merge_flag == MergeType::Engine) do_fcst_merge_engine(default_config, merge_config); // @@ -944,12 +945,12 @@ void ModeFuzzyEngine::do_obs_merging(const char *default_config, if(!need_obs_merge) return; - if(conf_info.Obs->merge_flag == MergeType_Both || - conf_info.Obs->merge_flag == MergeType_Thresh) + if(conf_info.Obs->merge_flag == MergeType::Both || + conf_info.Obs->merge_flag == MergeType::Thresh) do_obs_merge_thresh(); - if(conf_info.Obs->merge_flag == MergeType_Both || - conf_info.Obs->merge_flag == MergeType_Engine) + if(conf_info.Obs->merge_flag == MergeType::Both || + conf_info.Obs->merge_flag == MergeType::Engine) do_obs_merge_engine(default_config, merge_config); // @@ -978,12 +979,12 @@ void ModeFuzzyEngine::do_fcst_merging(const ShapeData &merge_data) exit(1); } - if(conf_info.Fcst->merge_flag == MergeType_Both || - conf_info.Fcst->merge_flag == MergeType_Thresh) + if(conf_info.Fcst->merge_flag == MergeType::Both || + conf_info.Fcst->merge_flag == MergeType::Thresh) do_fcst_merge_thresh(merge_data); - if(conf_info.Fcst->merge_flag == MergeType_Both || - conf_info.Fcst->merge_flag == MergeType_Engine) + if(conf_info.Fcst->merge_flag == MergeType::Both || + conf_info.Fcst->merge_flag == MergeType::Engine) do_fcst_merge_engine("", ""); // @@ -1012,12 +1013,12 @@ void ModeFuzzyEngine::do_obs_merging(const ShapeData &merge_data) exit(1); } - if(conf_info.Obs->merge_flag == MergeType_Both || - conf_info.Obs->merge_flag == MergeType_Thresh) + if(conf_info.Obs->merge_flag == MergeType::Both || + conf_info.Obs->merge_flag == MergeType::Thresh) do_obs_merge_thresh(merge_data); - if(conf_info.Obs->merge_flag == MergeType_Both || - conf_info.Obs->merge_flag == MergeType_Engine) + if(conf_info.Obs->merge_flag == MergeType::Both || + conf_info.Obs->merge_flag == MergeType::Engine) do_obs_merge_engine("", ""); // @@ -1037,23 +1038,23 @@ void ModeFuzzyEngine::do_matching() { if(!need_match) return; - if(conf_info.match_flag == MatchType_None) { + if(conf_info.match_flag == MatchType::None) { mlog << Warning << "\nModeFuzzyEngine::do_matching() -> " << "no matching requested in configuration file\n\n"; do_no_match(); } - else if(conf_info.match_flag == MatchType_MergeBoth) { + else if(conf_info.match_flag == MatchType::MergeBoth) { do_match_merge(); } - else if(conf_info.match_flag == MatchType_MergeFcst) { + else if(conf_info.match_flag == MatchType::MergeFcst) { do_match_fcst_merge(); } - else if(conf_info.match_flag == MatchType_NoMerge) { + else if(conf_info.match_flag == MatchType::NoMerge) { do_match_only(); } else { mlog << Error << "\nModeFuzzyEngine::do_matching() -> " - << "invalid match_flag value of " << conf_info.match_flag + << "invalid match_flag value of " << enum_class_as_int(conf_info.match_flag) << " specified.\n\n"; exit(1); } @@ -2928,9 +2929,9 @@ double interest_percentile(ModeFuzzyEngine &eng, const double p, const int flag) double *v = (double *) nullptr; NumArray fcst_na, obs_na; - if(eng.conf_info.match_flag == 0 || - eng.n_fcst == 0 || - eng.n_obs == 0) return 0.0; + if(eng.conf_info.match_flag == MatchType::None || + eng.n_fcst == 0 || + eng.n_obs == 0) return 0.0; // // Initialize the maximum interest value for each object to zero. @@ -3079,7 +3080,7 @@ for (x=0; x<(grid.nx()); ++x) { // // If no matching was requested, don't write any more // - if(eng.conf_info.match_flag == 0) return; + if(eng.conf_info.match_flag == MatchType::None) return; // // Object pairs, increment the counter within the subroutine diff --git a/src/libcode/vx_shapedata/mode_conf_info.cc b/src/libcode/vx_shapedata/mode_conf_info.cc index c037fd4b0e..642db14034 100644 --- a/src/libcode/vx_shapedata/mode_conf_info.cc +++ b/src/libcode/vx_shapedata/mode_conf_info.cc @@ -192,7 +192,7 @@ void ModeConfInfo::clear() desc.clear(); obtype.clear(); - mask_missing_flag = FieldType_None; + mask_missing_flag = FieldType::None; grid_res = bad_data_double; @@ -202,15 +202,15 @@ void ModeConfInfo::clear() fcst_multivar_logic.clear(); obs_multivar_logic.clear(); - match_flag = MatchType_None; + match_flag = MatchType::None; max_centroid_dist = bad_data_double; mask_grid_name.clear(); - mask_grid_flag = FieldType_None; + mask_grid_flag = FieldType::None; mask_poly_name.clear(); - mask_poly_flag = FieldType_None; + mask_poly_flag = FieldType::None; centroid_dist_wt = bad_data_double; boundary_dist_wt = bad_data_double; @@ -267,7 +267,7 @@ void ModeConfInfo::clear() Obs = 0; // so traditional mode will have the right value - data_type = ModeDataType_Traditional; + data_type = ModeDataType::Traditional; N_fields_f = 0; N_fields_o = 0; @@ -301,7 +301,7 @@ void ModeConfInfo::read_config(const char * default_file_name, const char * user void ModeConfInfo::process_config_traditional(GrdFileType ftype, GrdFileType otype) { process_config_except_fields(); - process_config_field (ftype, otype, ModeDataType_Traditional, 0); + process_config_field (ftype, otype, ModeDataType::Traditional, 0); } //////////////////////////////////////////////////////////////////////// @@ -412,7 +412,7 @@ void ModeConfInfo::process_config_except_fields() // Check that the sum of the weights is non-zero for matching - if(match_flag != MatchType_None && + if(match_flag != MatchType::None && is_eq(centroid_dist_wt + boundary_dist_wt + convex_hull_dist_wt + angle_diff_wt + aspect_diff_wt + area_ratio_wt + @@ -513,11 +513,11 @@ void ModeConfInfo::process_config_field(GrdFileType ftype, GrdFileType otype, { set_data_type(dt); - if (data_type == ModeDataType_MvMode_Fcst) { + if (data_type == ModeDataType::MvMode_Fcst) { process_config_fcst(ftype, field_index); - } else if (data_type == ModeDataType_MvMode_Obs) { + } else if (data_type == ModeDataType::MvMode_Obs) { process_config_obs(otype, field_index); @@ -580,7 +580,7 @@ void ModeConfInfo::process_config_both(GrdFileType ftype, GrdFileType otype, evaluate_fcst_settings(field_index); evaluate_obs_settings(field_index); - if (data_type == ModeDataType_Traditional) { + if (data_type == ModeDataType::Traditional) { if ( fcst_array[field_index].conv_radius_array.n_elements() != obs_array[field_index].conv_radius_array.n_elements() ) { @@ -702,7 +702,7 @@ void ModeConfInfo::config_set_all_percentile_thresholds(const std::vector " << "When matching is disabled (match_flag = " << matchtype_to_string(match_flag) @@ -903,7 +903,7 @@ void ModeConfInfo::evaluate_obs_settings(int j) if ( obs_array[j].merge_thresh_array.n_elements() == 1 ) obs_array[j].merge_thresh = obs_array[j].merge_thresh_array[0]; // Check that match_flag is set between 0 and 3 - if(match_flag == MatchType_None && obs_array[j].merge_flag != MergeType_None) { + if(match_flag == MatchType::None && obs_array[j].merge_flag != MergeType::None) { mlog << Warning << "\nModeConfInfo::evaluate_obs_settings(" << j << ") -> " << "When matching is disabled (match_flag = " << matchtype_to_string(match_flag) @@ -942,7 +942,7 @@ if ( field->is_array() ) { const DictionaryEntry * e = 0; const Dictionary & D = *field; - if (data_type == ModeDataType_Traditional) { + if (data_type == ModeDataType::Traditional) { // traditional mode, extra test if ( (N_fields_f > 0) && (N != N_fields_f) ) { mlog << Error @@ -1098,7 +1098,7 @@ return pwl_if; void ModeConfInfo::set_field_index(int k) { - if (data_type == ModeDataType_MvMode_Obs) { + if (data_type == ModeDataType::MvMode_Obs) { if ( (k < 0) || (k >= N_fields_o) ) { mlog << Error << "\nModeConfInfo::set_field_index(int) -> range check error\n\n"; @@ -1108,7 +1108,7 @@ void ModeConfInfo::set_field_index(int k) Field_Index_f = -1; Obs = obs_array + k; } - else if (data_type == ModeDataType_MvMode_Fcst) { + else if (data_type == ModeDataType::MvMode_Fcst) { if ( (k < 0) || (k >= N_fields_f) ) { mlog << Error << "\nModeConfInfo::set_field_index(int) -> range check error\n\n"; @@ -1144,10 +1144,10 @@ if ( (f_index < 0) || (f_index >= N_fields_f) || (o_index < 0) || Field_Index_f = f_index; Field_Index_o = o_index; -if (data_type != ModeDataType_MvMode_Fcst) { +if (data_type != ModeDataType::MvMode_Fcst) { Obs = obs_array + o_index; } -if (data_type != ModeDataType_MvMode_Obs) { +if (data_type != ModeDataType::MvMode_Obs) { Fcst = fcst_array + f_index; } return; @@ -1220,9 +1220,9 @@ void ModeConfInfo::set_perc_thresh(const DataPlane &dp) // Mode_Field_Info *F; - if (data_type == ModeDataType_MvMode_Obs) { + if (data_type == ModeDataType::MvMode_Obs) { F = Obs; - } else if (data_type == ModeDataType_MvMode_Fcst) { + } else if (data_type == ModeDataType::MvMode_Fcst) { F = Fcst; } else { mlog << Warning @@ -1337,7 +1337,7 @@ return; void ModeConfInfo::set_conv_radius_by_index(int k) { - if (data_type != ModeDataType_MvMode_Obs) { + if (data_type != ModeDataType::MvMode_Obs) { if ( (k < 0) || (k >= Fcst->conv_radius_array.n_elements()) ) { mlog << Error << "\nModeConfInfo::set_conv_radius_by_index(int) -> " @@ -1346,7 +1346,7 @@ void ModeConfInfo::set_conv_radius_by_index(int k) } Fcst->conv_radius = Fcst->conv_radius_array[k]; } - if (data_type != ModeDataType_MvMode_Fcst) { + if (data_type != ModeDataType::MvMode_Fcst) { if ( (k < 0) || (k >= Obs->conv_radius_array.n_elements()) ) { mlog << Error @@ -1365,10 +1365,10 @@ void ModeConfInfo::set_conv_radius_by_index(int k) void ModeConfInfo::set_conv_thresh(SingleThresh s) { - if (data_type != ModeDataType_MvMode_Obs) { + if (data_type != ModeDataType::MvMode_Obs) { Fcst->conv_thresh = s; } - if (data_type != ModeDataType_MvMode_Fcst) { + if (data_type != ModeDataType::MvMode_Fcst) { Obs->conv_thresh = s; } } @@ -1377,10 +1377,10 @@ void ModeConfInfo::set_conv_thresh(SingleThresh s) void ModeConfInfo::set_conv_radius(int r) { - if (data_type != ModeDataType_MvMode_Obs) { + if (data_type != ModeDataType::MvMode_Obs) { Fcst->conv_radius = r; } - if (data_type != ModeDataType_MvMode_Fcst) { + if (data_type != ModeDataType::MvMode_Fcst) { Obs->conv_radius = r; } } @@ -1390,7 +1390,7 @@ void ModeConfInfo::set_conv_radius(int r) void ModeConfInfo::set_conv_thresh_by_index(int k) { - if (data_type != ModeDataType_MvMode_Fcst) { + if (data_type != ModeDataType::MvMode_Fcst) { if ( (k < 0) || (k >= Obs->conv_thresh_array.n_elements()) ) { mlog << Error << "\nModeConfInfo::set_conv_thresh_by_index(int) -> " @@ -1399,7 +1399,7 @@ void ModeConfInfo::set_conv_thresh_by_index(int k) } Obs->conv_thresh = Obs->conv_thresh_array[k]; } - if (data_type != ModeDataType_MvMode_Obs) { + if (data_type != ModeDataType::MvMode_Obs) { if ( (k < 0) || (k >= Fcst->conv_thresh_array.n_elements()) ) { mlog << Error @@ -1417,10 +1417,10 @@ void ModeConfInfo::set_conv_thresh_by_index(int k) void ModeConfInfo::set_merge_thresh_by_index(int k) { - if (data_type != ModeDataType_MvMode_Fcst) { + if (data_type != ModeDataType::MvMode_Fcst) { if ( Obs->need_merge_thresh () ) set_obs_merge_thresh_by_index (k); } - if (data_type != ModeDataType_MvMode_Obs) { + if (data_type != ModeDataType::MvMode_Obs) { if ( Fcst->need_merge_thresh () ) set_fcst_merge_thresh_by_index (k); } } @@ -1431,7 +1431,7 @@ void ModeConfInfo::set_merge_thresh_by_index(int k) void ModeConfInfo::set_fcst_merge_thresh_by_index(int k) { - if (data_type == ModeDataType_MvMode_Obs) + if (data_type == ModeDataType::MvMode_Obs) { mlog << Error << "\nModeConfInfo::set_fcst_merge_thresh_by_index(int) -> " @@ -1451,10 +1451,10 @@ void ModeConfInfo::set_fcst_merge_thresh_by_index(int k) void ModeConfInfo::set_conv_thresh_by_merge_index(int k) { - if (data_type != ModeDataType_MvMode_Fcst) { + if (data_type != ModeDataType::MvMode_Fcst) { if (Obs->need_merge_thresh()) set_obs_conv_thresh_by_merge_index (k); } - if (data_type != ModeDataType_MvMode_Obs) { + if (data_type != ModeDataType::MvMode_Obs) { if (Fcst->need_merge_thresh()) set_fcst_conv_thresh_by_merge_index (k); } } @@ -1465,7 +1465,7 @@ void ModeConfInfo::set_conv_thresh_by_merge_index(int k) void ModeConfInfo::set_fcst_conv_thresh_by_merge_index(int k) { - if (data_type == ModeDataType_MvMode_Obs) + if (data_type == ModeDataType::MvMode_Obs) { mlog << Error << "\nModeConfInfo::set_fcst_conv_thresh_by_merge_index(int) -> " @@ -1485,7 +1485,7 @@ void ModeConfInfo::set_fcst_conv_thresh_by_merge_index(int k) void ModeConfInfo::set_obs_conv_thresh_by_merge_index(int k) { - if (data_type == ModeDataType_MvMode_Fcst) + if (data_type == ModeDataType::MvMode_Fcst) { mlog << Error << "\nModeConfInfo::set_obs_conv_thresh_by_merge_index(int) -> " @@ -1502,7 +1502,7 @@ void ModeConfInfo::set_obs_conv_thresh_by_merge_index(int k) void ModeConfInfo::set_fcst_merge_flag(MergeType t) { - if (data_type == ModeDataType_MvMode_Obs) + if (data_type == ModeDataType::MvMode_Obs) { mlog << Error << "\nModeConfInfo::set_fcst_merge_flag(int) -> " @@ -1516,7 +1516,7 @@ void ModeConfInfo::set_fcst_merge_flag(MergeType t) void ModeConfInfo::set_obs_merge_flag(MergeType t) { - if (data_type == ModeDataType_MvMode_Fcst) + if (data_type == ModeDataType::MvMode_Fcst) { mlog << Error << "\nModeConfInfo::set_obs_merge_flag(int) -> " @@ -1530,7 +1530,7 @@ void ModeConfInfo::set_obs_merge_flag(MergeType t) void ModeConfInfo::set_fcst_merge_thresh(SingleThresh s) { - if (data_type == ModeDataType_MvMode_Obs) + if (data_type == ModeDataType::MvMode_Obs) { mlog << Error << "\nModeConfInfo::set_fcst_merge_thresh(int) -> " @@ -1544,7 +1544,7 @@ void ModeConfInfo::set_fcst_merge_thresh(SingleThresh s) void ModeConfInfo::set_obs_merge_thresh(SingleThresh s) { - if (data_type == ModeDataType_MvMode_Fcst) + if (data_type == ModeDataType::MvMode_Fcst) { mlog << Error << "\nModeConfInfo::set_obs_merge_thresh(int) -> " @@ -1560,7 +1560,7 @@ void ModeConfInfo::set_obs_merge_thresh(SingleThresh s) void ModeConfInfo::set_obs_merge_thresh_by_index(int k) { - if (data_type == ModeDataType_MvMode_Fcst) + if (data_type == ModeDataType::MvMode_Fcst) { mlog << Error << "\nModeConfInfo::set_obs_merge_thresh_by_index(int) -> " @@ -1734,8 +1734,8 @@ void ModeConfInfo::check_multivar_not_implemented() } for (int i=0; iconv_radius_array.n_elements() ); } else { @@ -328,7 +328,7 @@ inline int ModeConfInfo::n_conv_threshs() const { // this could break down if multivar mode relaxes // its limitations on number of thresh (obs and fcst could be different) - if (data_type == ModeDataType_MvMode_Obs) + if (data_type == ModeDataType::MvMode_Obs) { return ( Obs->conv_thresh_array.n_elements() ); } else { diff --git a/src/libcode/vx_shapedata/mode_data_type.h b/src/libcode/vx_shapedata/mode_data_type.h index 59f4aea3d2..18696d5fe2 100644 --- a/src/libcode/vx_shapedata/mode_data_type.h +++ b/src/libcode/vx_shapedata/mode_data_type.h @@ -20,10 +20,10 @@ using std::string; enum ModeDataType { - ModeDataType_Traditional, // default - ModeDataType_MvMode_Obs, // mvmode, obs data only - ModeDataType_MvMode_Fcst, // mvmode, fcst data only - ModeDataType_MvMode_Both // mvmode, fcst and obs + Traditional, // default + MvMode_Obs, // mvmode, obs data only + MvMode_Fcst, // mvmode, fcst data only + MvMode_Both // mvmode, fcst and obs }; @@ -33,13 +33,13 @@ inline string sprintModeDataType(ModeDataType type) { switch (type) { - case ModeDataType_MvMode_Obs: + case ModeDataType::MvMode_Obs: return "MvMode_Obs"; - case ModeDataType_MvMode_Fcst: + case ModeDataType::MvMode_Fcst: return "MvMode_Fcst"; - case ModeDataType_MvMode_Both: + case ModeDataType::MvMode_Both: return "MvMode_Both"; - case ModeDataType_Traditional: + case ModeDataType::Traditional: default: return "TraditionalMode"; } diff --git a/src/libcode/vx_shapedata/mode_field_info.cc b/src/libcode/vx_shapedata/mode_field_info.cc index b49a805681..df3bd475f7 100644 --- a/src/libcode/vx_shapedata/mode_field_info.cc +++ b/src/libcode/vx_shapedata/mode_field_info.cc @@ -167,7 +167,7 @@ conv_thresh.clear(); merge_thresh.clear(); -merge_flag = MergeType_Engine; +merge_flag = MergeType::Engine; file_type = FileType_None; @@ -263,7 +263,7 @@ if ( dict->lookup(conf_key_vld_thresh) ) { if ( _multivar ) { // set defaults to no merging merge_thresh.clear(); - merge_flag = MergeType_None; + merge_flag = MergeType::None; // pull out the name string name = var_info->name(); @@ -286,7 +286,7 @@ if ( _multivar ) { // because that is inconsistent merge_thresh_array = dict->lookup_thresh_array(conf_key_merge_thresh); - if (merge_flag != MergeType_None) { + if (merge_flag != MergeType::None) { mlog << Error << "\nMode_Field_Info::set() -> " << "Field:" << name << ". " << " When 'merge_flag' is explicitly set, 'merge_thresh' must be explicitly set for multivariate mode\n\n"; @@ -310,7 +310,7 @@ if ( _multivar ) { // individual entry doesn't have a merge_thresh, parent has a merge_flag // expect parent to have a merge_thresh merge_thresh_array = dict->lookup_thresh_array(conf_key_merge_thresh); - if (merge_thresh_array.n() == 0 && merge_flag != MergeType_None) { + if (merge_thresh_array.n() == 0 && merge_flag != MergeType::None) { // parent has a merge_flag but no merge_thresh mlog << Error << "\nMode_Field_Info::set() -> " << "Field:" << name << ". using parent merge_flag: " << merge_name @@ -403,7 +403,7 @@ bool Mode_Field_Info::need_merge_thresh () const { -bool status = (merge_flag == MergeType_Both) || (merge_flag == MergeType_Thresh); +bool status = (merge_flag == MergeType::Both) || (merge_flag == MergeType::Thresh); return status; diff --git a/src/libcode/vx_shapedata/shapedata.cc b/src/libcode/vx_shapedata/shapedata.cc index ca2c6ead1c..3e4491e380 100644 --- a/src/libcode/vx_shapedata/shapedata.cc +++ b/src/libcode/vx_shapedata/shapedata.cc @@ -35,6 +35,7 @@ #include "shapedata.h" #include "mode_columns.h" +#include "enum_as_int.hpp" #include "vx_log.h" #include "vx_util.h" #include "vx_math.h" @@ -64,7 +65,7 @@ static const bool do_split_fatten = true; static double dot(double, double, double, double); static void boundary_step(const ShapeData &, int &, int &, int &); -static int get_step_case(bool, bool, bool, bool); +static StepCase get_step_case(bool, bool, bool, bool); /////////////////////////////////////////////////////////////////////////////// // @@ -532,7 +533,7 @@ void ShapeData::conv_filter_circ(int diameter, double vld_thresh) { // Build the grid template with shape circle and wrap_lon false GridTemplateFactory gtf; - GridTemplate* gt = gtf.buildGT(GridTemplateFactory::GridTemplate_Circle, + GridTemplate* gt = gtf.buildGT(GridTemplateFactory::GridTemplates::Circle, diameter, false); #pragma omp single @@ -1698,7 +1699,7 @@ void boundary_step(const ShapeData &sd, int &xn, int &yn, int &direction) { // switch(direction) { - case(plus_x): + case plus_x: if(sd.s_is_on(xn, yn-1, false)) lr = true; if(sd.s_is_on(xn+1, yn-1, false)) ur = true; if(sd.s_is_on(xn+1, yn , false)) ul = true; @@ -1707,7 +1708,7 @@ void boundary_step(const ShapeData &sd, int &xn, int &yn, int &direction) { xn += 1; break; - case(plus_y): + case plus_y: if(sd.s_is_on(xn, yn , false)) lr = true; if(sd.s_is_on(xn, yn+1, false)) ur = true; if(sd.s_is_on(xn-1, yn+1, false)) ul = true; @@ -1716,7 +1717,7 @@ void boundary_step(const ShapeData &sd, int &xn, int &yn, int &direction) { yn += 1; break; - case(minus_x): + case minus_x: if(sd.s_is_on(xn-1, yn , false)) lr = true; if(sd.s_is_on(xn-2, yn , false)) ur = true; if(sd.s_is_on(xn-2, yn-1, false)) ul = true; @@ -1725,7 +1726,7 @@ void boundary_step(const ShapeData &sd, int &xn, int &yn, int &direction) { xn -= 1; break; - case(minus_y): + case minus_y: if(sd.s_is_on(xn-1, yn-1, false)) lr = true; if(sd.s_is_on(xn-1, yn-2, false)) ur = true; if(sd.s_is_on(xn, yn-2, false)) ul = true; @@ -1745,24 +1746,24 @@ void boundary_step(const ShapeData &sd, int &xn, int &yn, int &direction) { // switch(get_step_case(lr, ur, ul, ll)) { - case ll_case: - case lr_ul_case: - case lr_ur_ul_case: + case StepCase::ll_case: + case StepCase::lr_ul_case: + case StepCase::lr_ur_ul_case: // Turn left direction = (direction + 1)%4; if(direction < 0) direction += 4; break; - case lr_case: - case ur_ll_case: - case ur_ul_ll_case: + case StepCase::lr_case: + case StepCase::ur_ll_case: + case StepCase::ur_ul_ll_case: // Turn right direction = (direction - 1)%4; if(direction < 0) direction += 4; break; - case ul_ll_case: - case lr_ur_case: + case StepCase::ul_ll_case: + case StepCase::lr_ur_case: // Continue straight: direction remains unchanged break; @@ -1770,7 +1771,7 @@ void boundary_step(const ShapeData &sd, int &xn, int &yn, int &direction) { mlog << Error << "\nboundary_step() -> " << "bad step case: " - << get_step_case(lr, ur, ul, ll) << "\n\n"; + << enum_class_as_int(get_step_case(lr, ur, ul, ll)) << "\n\n"; exit(1); } @@ -1779,38 +1780,38 @@ void boundary_step(const ShapeData &sd, int &xn, int &yn, int &direction) { //////////////////////////////////////////////////////////////////////// -int get_step_case(bool lr, bool ur, bool ul, bool ll) { +StepCase get_step_case(bool lr, bool ur, bool ul, bool ll) { // // Valid cases with exactly one cell on // // Lower Left - if(!lr && !ur && !ul && ll) return ll_case; + if(!lr && !ur && !ul && ll) return StepCase::ll_case; // Lower Right - else if(lr && !ur && !ul && !ll) return lr_case; + else if(lr && !ur && !ul && !ll) return StepCase::lr_case; // // Valid cases with exactly two cells on // // Upper Left, Lower Left - else if(!lr && !ur && ul && ll) return ul_ll_case; + else if(!lr && !ur && ul && ll) return StepCase::ul_ll_case; // Lower Right, Upper Right - else if(lr && ur && !ul && !ll) return lr_ur_case; + else if(lr && ur && !ul && !ll) return StepCase::lr_ur_case; // Lower Right, Upper Left - else if(lr && !ur && ul && !ll) return lr_ul_case; + else if(lr && !ur && ul && !ll) return StepCase::lr_ul_case; // Upper Right, Lower Left - else if(!lr && ur && !ul && ll) return ur_ll_case; + else if(!lr && ur && !ul && ll) return StepCase::ur_ll_case; // // Valid cases with exactly three cells on // // Upper Right, Upper Left, Lower Left - else if(!lr && ur && ul && ll) return ur_ul_ll_case; + else if(!lr && ur && ul && ll) return StepCase::ur_ul_ll_case; // Lower Right, Upper Right, Upper Left - else if(lr && ur && ul && !ll) return lr_ur_ul_case; + else if(lr && ur && ul && !ll) return StepCase::lr_ur_ul_case; // // Otherwise, combination is invalid diff --git a/src/libcode/vx_shapedata/shapedata.h b/src/libcode/vx_shapedata/shapedata.h index e1acfb55fd..9654844047 100644 --- a/src/libcode/vx_shapedata/shapedata.h +++ b/src/libcode/vx_shapedata/shapedata.h @@ -39,7 +39,7 @@ // // Enumerations used in computing the boundary of a ShapeData object // -enum StepCase { +enum class StepCase { ll_case = 0, lr_case = 1, ul_ll_case = 2, diff --git a/src/libcode/vx_stat_out/stat_columns.cc b/src/libcode/vx_stat_out/stat_columns.cc index 55aded1e28..07c4df90d6 100644 --- a/src/libcode/vx_stat_out/stat_columns.cc +++ b/src/libcode/vx_stat_out/stat_columns.cc @@ -536,7 +536,7 @@ void write_fho_row(StatHdrColumns &shc, const CTSInfo &cts_info, shc.set_obs_thresh(cts_info.othresh); // Not Applicable - shc.set_thresh_logic(SetLogic_None); + shc.set_thresh_logic(SetLogic::None); shc.set_alpha(bad_data_double); shc.set_cov_thresh(na_str); @@ -547,7 +547,7 @@ void write_fho_row(StatHdrColumns &shc, const CTSInfo &cts_info, write_fho_cols(cts_info, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -575,7 +575,7 @@ void write_ctc_row(StatHdrColumns &shc, const CTSInfo &cts_info, shc.set_obs_thresh(cts_info.othresh); // Not Applicable - shc.set_thresh_logic(SetLogic_None); + shc.set_thresh_logic(SetLogic::None); shc.set_alpha(bad_data_double); shc.set_cov_thresh(na_str); @@ -586,7 +586,7 @@ void write_ctc_row(StatHdrColumns &shc, const CTSInfo &cts_info, write_ctc_cols(cts_info, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -615,7 +615,7 @@ void write_cts_row(StatHdrColumns &shc, const CTSInfo &cts_info, shc.set_obs_thresh(cts_info.othresh); // Not Applicable - shc.set_thresh_logic(SetLogic_None); + shc.set_thresh_logic(SetLogic::None); shc.set_cov_thresh(na_str); // Write a line for each alpha value @@ -631,7 +631,7 @@ void write_cts_row(StatHdrColumns &shc, const CTSInfo &cts_info, write_cts_cols(cts_info, i, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -660,7 +660,7 @@ void write_mctc_row(StatHdrColumns &shc, const MCTSInfo &mcts_info, shc.set_obs_thresh(mcts_info.othresh); // Not Applicable - shc.set_thresh_logic(SetLogic_None); + shc.set_thresh_logic(SetLogic::None); shc.set_alpha(bad_data_double); shc.set_cov_thresh(na_str); @@ -671,7 +671,7 @@ void write_mctc_row(StatHdrColumns &shc, const MCTSInfo &mcts_info, write_mctc_cols(mcts_info, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -700,7 +700,7 @@ void write_mcts_row(StatHdrColumns &shc, const MCTSInfo &mcts_info, shc.set_obs_thresh(mcts_info.othresh); // Not Applicable - shc.set_thresh_logic(SetLogic_None); + shc.set_thresh_logic(SetLogic::None); shc.set_cov_thresh(na_str); // Write a line for each alpha value @@ -716,7 +716,7 @@ void write_mcts_row(StatHdrColumns &shc, const MCTSInfo &mcts_info, write_mcts_cols(mcts_info, i, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -767,7 +767,7 @@ void write_cnt_row(StatHdrColumns &shc, const CNTInfo &cnt_info, write_cnt_cols(cnt_info, i, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -815,7 +815,7 @@ void write_sl1l2_row(StatHdrColumns &shc, const SL1L2Info &sl1l2_info, write_sl1l2_cols(sl1l2_info, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -862,7 +862,7 @@ void write_sal1l2_row(StatHdrColumns &shc, const SL1L2Info &sl1l2_info, write_sal1l2_cols(sl1l2_info, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -904,7 +904,7 @@ void write_vl1l2_row(StatHdrColumns &shc, const VL1L2Info &vl1l2_info, write_vl1l2_cols(vl1l2_info, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -943,7 +943,7 @@ void write_val1l2_row(StatHdrColumns &shc, const VL1L2Info &vl1l2_info, write_val1l2_cols(vl1l2_info, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -988,7 +988,7 @@ void write_vcnt_row(StatHdrColumns &shc, const VL1L2Info &vcnt_info, write_vcnt_cols(vcnt_info, i, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -1019,7 +1019,7 @@ void write_pct_row(StatHdrColumns &shc, const PCTInfo &pct_info, if(update_thresh) { shc.set_fcst_thresh(pct_info.fthresh); shc.set_obs_thresh(pct_info.othresh); - shc.set_thresh_logic(SetLogic_None); + shc.set_thresh_logic(SetLogic::None); shc.set_cov_thresh(na_str); } @@ -1037,7 +1037,7 @@ void write_pct_row(StatHdrColumns &shc, const PCTInfo &pct_info, write_pct_cols(pct_info, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -1070,7 +1070,7 @@ void write_pstd_row(StatHdrColumns &shc, const PCTInfo &pct_info, if(update_thresh) { shc.set_fcst_thresh(pct_info.fthresh); shc.set_obs_thresh(pct_info.othresh); - shc.set_thresh_logic(SetLogic_None); + shc.set_thresh_logic(SetLogic::None); shc.set_cov_thresh(na_str); } @@ -1091,7 +1091,7 @@ void write_pstd_row(StatHdrColumns &shc, const PCTInfo &pct_info, write_pstd_cols(pct_info, i, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -1124,7 +1124,7 @@ void write_pjc_row(StatHdrColumns &shc, const PCTInfo &pct_info, if(update_thresh) { shc.set_fcst_thresh(pct_info.fthresh); shc.set_obs_thresh(pct_info.othresh); - shc.set_thresh_logic(SetLogic_None); + shc.set_thresh_logic(SetLogic::None); shc.set_cov_thresh(na_str); } @@ -1142,7 +1142,7 @@ void write_pjc_row(StatHdrColumns &shc, const PCTInfo &pct_info, write_pjc_cols(pct_info, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -1174,7 +1174,7 @@ void write_prc_row(StatHdrColumns &shc, const PCTInfo &pct_info, if(update_thresh) { shc.set_fcst_thresh(pct_info.fthresh); shc.set_obs_thresh(pct_info.othresh); - shc.set_thresh_logic(SetLogic_None); + shc.set_thresh_logic(SetLogic::None); shc.set_cov_thresh(na_str); } @@ -1192,7 +1192,7 @@ void write_prc_row(StatHdrColumns &shc, const PCTInfo &pct_info, write_prc_cols(pct_info, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -1223,7 +1223,7 @@ void write_eclv_row(StatHdrColumns &shc, const PCTInfo &pct_info, // Set the threshold columns, if requested. shc.set_obs_thresh(pct_info.othresh); - shc.set_thresh_logic(SetLogic_None); + shc.set_thresh_logic(SetLogic::None); shc.set_cov_thresh(na_str); // Not Applicable @@ -1247,7 +1247,7 @@ void write_eclv_row(StatHdrColumns &shc, const PCTInfo &pct_info, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -1280,7 +1280,7 @@ void write_eclv_row(StatHdrColumns &shc, const CTSInfo &cts_info, shc.set_obs_thresh(cts_info.othresh); // Not Applicable - shc.set_thresh_logic(SetLogic_None); + shc.set_thresh_logic(SetLogic::None); shc.set_alpha(bad_data_double); shc.set_cov_thresh(na_str); @@ -1292,7 +1292,7 @@ void write_eclv_row(StatHdrColumns &shc, const CTSInfo &cts_info, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -1323,7 +1323,7 @@ void write_nbrctc_row(StatHdrColumns &shc, const NBRCTSInfo &nbrcts_info, shc.set_cov_thresh(nbrcts_info.cthresh); // Not Applicable - shc.set_thresh_logic(SetLogic_None); + shc.set_thresh_logic(SetLogic::None); shc.set_alpha(bad_data_double); // Write the header columns @@ -1333,7 +1333,7 @@ void write_nbrctc_row(StatHdrColumns &shc, const NBRCTSInfo &nbrcts_info, write_nbrctc_cols(nbrcts_info, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -1365,7 +1365,7 @@ void write_nbrcts_row(StatHdrColumns &shc, const NBRCTSInfo &nbrcts_info, shc.set_cov_thresh(nbrcts_info.cthresh); // Not Applicable - shc.set_thresh_logic(SetLogic_None); + shc.set_thresh_logic(SetLogic::None); // Write a line for each alpha value for(i=0; i " << "expected " << n_req << " parameter(s) but got " @@ -714,7 +714,7 @@ double add_obs_error_inc(const gsl_rng *r, FieldType t, if(!e || is_bad_data(v)) return v; // Apply the specified random perturbation - if(e->dist_type != DistType_None) { + if(e->dist_type != DistType::None) { v_new += ran_draw(r, e->dist_type, e->dist_parm[0], e->dist_parm[1]); } @@ -727,7 +727,7 @@ double add_obs_error_inc(const gsl_rng *r, FieldType t, if(mlog.verbosity_level() >= 4) { // Check for no updates - if(e->dist_type == DistType_None) { + if(e->dist_type == DistType::None) { mlog << Debug(4) << "Applying no observation error update for " << fieldtype_to_string(t) << " value " << v diff --git a/src/libcode/vx_statistics/pair_base.cc b/src/libcode/vx_statistics/pair_base.cc index a7b305c8a5..f3ffaed3fb 100644 --- a/src/libcode/vx_statistics/pair_base.cc +++ b/src/libcode/vx_statistics/pair_base.cc @@ -74,8 +74,8 @@ void PairBase::clear() { msg_typ_vals.clear(); interp_wdth = 0; - interp_mthd = InterpMthd_None; - interp_shape = GridTemplateFactory::GridTemplate_None; + interp_mthd = InterpMthd::None; + interp_shape = GridTemplateFactory::GridTemplates::None; o_na.clear(); x_na.clear(); @@ -97,7 +97,7 @@ void PairBase::clear() { fcst_ut = 0; - obs_summary = ObsSummary_None; + obs_summary = ObsSummary::None; obs_perc_value = bad_data_int; check_unique = false; @@ -123,8 +123,8 @@ void PairBase::erase() { msg_typ.clear(); msg_typ_vals.clear(); - interp_mthd = InterpMthd_None; - interp_shape = GridTemplateFactory::GridTemplate_None; + interp_mthd = InterpMthd::None; + interp_shape = GridTemplateFactory::GridTemplates::None; o_na.erase(); x_na.erase(); @@ -146,7 +146,7 @@ void PairBase::erase() { fcst_ut = 0; - obs_summary = ObsSummary_None; + obs_summary = ObsSummary::None; obs_perc_value = bad_data_int; check_unique = false; @@ -464,7 +464,7 @@ bool PairBase::add_point_obs(const char *sid, ret = true; } - if(obs_summary == ObsSummary_None) { + if(obs_summary == ObsSummary::None) { sid_sa.add(sid); lat_na.add(lat); lon_na.add(lon); @@ -630,7 +630,7 @@ void PairBase::print_obs_summary(){ if(!IsPointVx) return; - if(obs_summary == ObsSummary_None || + if(obs_summary == ObsSummary::None || mlog.verbosity_level() < 4 || !map_val.size()) return; @@ -689,28 +689,28 @@ void PairBase::calc_obs_summary(){ regex_clean(mat); switch(obs_summary) { - case ObsSummary_Nearest: + case ObsSummary::Nearest: ob = compute_nearest(msg_key); break; - case ObsSummary_Min: + case ObsSummary::Min: ob = compute_min(msg_key); break; - case ObsSummary_Max: + case ObsSummary::Max: ob = compute_max(msg_key); break; - case ObsSummary_UW_Mean: + case ObsSummary::UW_Mean: ob = compute_uw_mean(msg_key); break; - case ObsSummary_DW_Mean: + case ObsSummary::DW_Mean: ob = compute_dw_mean(msg_key); break; - case ObsSummary_Median: + case ObsSummary::Median: ob = compute_percentile(msg_key, 50); break; - case ObsSummary_Perc: + case ObsSummary::Perc: ob = compute_percentile(msg_key, obs_perc_value); break; - case ObsSummary_None: + case ObsSummary::None: default: return; } diff --git a/src/libcode/vx_statistics/pair_base.h b/src/libcode/vx_statistics/pair_base.h index 8ef4c777f4..3a0f869edb 100644 --- a/src/libcode/vx_statistics/pair_base.h +++ b/src/libcode/vx_statistics/pair_base.h @@ -109,7 +109,7 @@ class PairBase { bool check_unique; // Check for duplicates, keeping unique obs ObsSummary obs_summary; // Summarize multiple observations - int obs_perc_value; // Percentile value for ObsSummary_Perc + int obs_perc_value; // Percentile value for ObsSummary::Perc StringArray map_key; std::map map_val; // Storage for single obs values diff --git a/src/libcode/vx_statistics/pair_data_ensemble.cc b/src/libcode/vx_statistics/pair_data_ensemble.cc index c2178687ce..2cf41de138 100644 --- a/src/libcode/vx_statistics/pair_data_ensemble.cc +++ b/src/libcode/vx_statistics/pair_data_ensemble.cc @@ -1399,7 +1399,7 @@ void VxPairDataEnsemble::set_ens_size(int n) { for(int k=0; kflag) { // Use config file setting, if specified - if(obs_error_info->entry.dist_type != DistType_None) { + if(obs_error_info->entry.dist_type != DistType::None) { oerr_ptr = &(obs_error_info->entry); } // Otherwise, do a table lookup @@ -1634,7 +1634,7 @@ void VxPairDataEnsemble::add_point_obs(float *hdr_arr, int *hdr_typ_arr, // bias correction, if requested if(obs_error_info->flag) { obs_v = add_obs_error_bc(obs_error_info->rng_ptr, - FieldType_Obs, oerr_ptr, obs_v); + FieldType::Obs, oerr_ptr, obs_v); } // Look through all of the PairData objects to see if the observation @@ -1692,10 +1692,10 @@ void VxPairDataEnsemble::add_point_obs(float *hdr_arr, int *hdr_typ_arr, // Check for valid interpolation options if(climo_sd_dpa.n_planes() > 0 && - (pd[0][0][k].interp_mthd == InterpMthd_Min || - pd[0][0][k].interp_mthd == InterpMthd_Max || - pd[0][0][k].interp_mthd == InterpMthd_Median || - pd[0][0][k].interp_mthd == InterpMthd_Best)) { + (pd[0][0][k].interp_mthd == InterpMthd::Min || + pd[0][0][k].interp_mthd == InterpMthd::Max || + pd[0][0][k].interp_mthd == InterpMthd::Median || + pd[0][0][k].interp_mthd == InterpMthd::Best)) { mlog << Warning << "\nVxPairDataEnsemble::add_point_obs() -> " << "applying the " << interpmthd_to_string(pd[0][0][k].interp_mthd) @@ -1752,7 +1752,7 @@ void VxPairDataEnsemble::add_ens(int member, bool mn, Grid &gr) { for(k=0; k " @@ -1785,7 +1785,7 @@ void VxPairDataEnsemble::add_ens(int member, bool mn, Grid &gr) { } // Extract the HiRA neighborhood of values - if(pd[0][0][k].interp_mthd == InterpMthd_HiRA) { + if(pd[0][0][k].interp_mthd == InterpMthd::HiRA) { // For HiRA, set the ensemble mean to bad data if(mn) { @@ -1844,7 +1844,7 @@ void VxPairDataEnsemble::add_ens(int member, bool mn, Grid &gr) { // Apply observation error perturbation, if requested if(obs_error_info->flag) { fcst_v = add_obs_error_inc( - obs_error_info->rng_ptr, FieldType_Fcst, + obs_error_info->rng_ptr, FieldType::Fcst, pd[i][j][k].obs_error_entry[l], pd[i][j][k].o_na[l], fcst_na[m]); } @@ -1891,7 +1891,7 @@ void VxPairDataEnsemble::set_duplicate_flag(DuplicateType duplicate_flag) { for(int i=0; i < n_msg_typ; i++){ for(int j=0; j < n_mask; j++){ for(int k=0; k < n_interp; k++){ - pd[i][j][k].set_check_unique(duplicate_flag == DuplicateType_Unique); + pd[i][j][k].set_check_unique(duplicate_flag == DuplicateType::Unique); } } } diff --git a/src/libcode/vx_statistics/pair_data_point.cc b/src/libcode/vx_statistics/pair_data_point.cc index 2b19b94391..cac91ea6c1 100644 --- a/src/libcode/vx_statistics/pair_data_point.cc +++ b/src/libcode/vx_statistics/pair_data_point.cc @@ -25,6 +25,7 @@ #include "vx_grid.h" #include "vx_math.h" #include "vx_log.h" +#include "enum_as_int.hpp" using namespace std; @@ -1081,8 +1082,8 @@ void VxPairDataPoint::add_point_obs(float *hdr_arr, const char *hdr_typ_str, // Interpolate model topography to observation location double topo = compute_horz_interp( *sfc_info.topo_ptr, obs_x, obs_y, hdr_elv, - InterpMthd_Bilin, 2, - GridTemplateFactory::GridTemplate_Square, + InterpMthd::Bilin, 2, + GridTemplateFactory::GridTemplates::Square, gr.wrap_lon(), 1.0); // Skip bad topography values @@ -1277,10 +1278,10 @@ void VxPairDataPoint::add_point_obs(float *hdr_arr, const char *hdr_typ_str, // Check for valid interpolation options if(climo_sd_dpa.n_planes() > 0 && - (pd[0][0][k].interp_mthd == InterpMthd_Min || - pd[0][0][k].interp_mthd == InterpMthd_Max || - pd[0][0][k].interp_mthd == InterpMthd_Median || - pd[0][0][k].interp_mthd == InterpMthd_Best)) { + (pd[0][0][k].interp_mthd == InterpMthd::Min || + pd[0][0][k].interp_mthd == InterpMthd::Max || + pd[0][0][k].interp_mthd == InterpMthd::Median || + pd[0][0][k].interp_mthd == InterpMthd::Best)) { mlog << Warning << "\nVxPairDataPoint::add_point_obs() -> " << "applying the " << interpmthd_to_string(pd[0][0][k].interp_mthd) @@ -1429,7 +1430,7 @@ void VxPairDataPoint::set_duplicate_flag(DuplicateType duplicate_flag) { for(int i=0; i < n_msg_typ; i++){ for(int j=0; j < n_mask; j++){ for(int k=0; k < n_interp; k++){ - pd[i][j][k].set_check_unique(duplicate_flag == DuplicateType_Unique); + pd[i][j][k].set_check_unique(duplicate_flag == DuplicateType::Unique); } } } @@ -1592,25 +1593,25 @@ bool check_fo_thresh(double f, double o, double cmn, double csd, // If either of the thresholds is NA, reset the logic to intersection // because an NA threshold is always true. if(ft.get_type() == thresh_na || ot.get_type() == thresh_na) { - t = SetLogic_Intersection; + t = SetLogic::Intersection; } switch(t) { - case(SetLogic_Union): + case(SetLogic::Union): if(!fcheck && !ocheck) status = false; break; - case(SetLogic_Intersection): + case(SetLogic::Intersection): if(!fcheck || !ocheck) status = false; break; - case(SetLogic_SymDiff): + case(SetLogic::SymDiff): if(fcheck == ocheck) status = false; break; default: mlog << Error << "\ncheck_fo_thresh() -> " - << "Unexpected SetLogic value of " << type << ".\n\n"; + << "Unexpected SetLogic value of " << enum_class_as_int(type) << ".\n\n"; exit(1); } diff --git a/src/libcode/vx_tc_util/atcf_line_base.cc b/src/libcode/vx_tc_util/atcf_line_base.cc index d49ffbb7f5..ff0aa402d8 100644 --- a/src/libcode/vx_tc_util/atcf_line_base.cc +++ b/src/libcode/vx_tc_util/atcf_line_base.cc @@ -146,7 +146,7 @@ void ATCFLineBase::clear() { // Do not reset pointers: // BasinMap, BestTechnique, OperTechnique, TechSuffix - Type = NoATCFLineType; + Type = ATCFLineType::None; Basin.clear(); Technique.clear(); IsBestTrack = false; @@ -210,14 +210,14 @@ ConcatString ATCFLineBase::get_item(int i) const { ConcatString cs; int i_col = i; - // For ATCFLineType_GenTrack: + // For ATCFLineType::GenTrack: // Columns 1 and 2 are consistent: // Use offsets 0 and 1 // Column 3 for is an EXTRA column for this line type: // Add special handling in storm_id() - // Columns 4-20 are the same as columns 3-19 of ATCFLineType_Track: + // Columns 4-20 are the same as columns 3-19 of ATCFLineType::Track: // Shift those column indices by 1. - if(Type == ATCFLineType_GenTrack && i >= 2 && i <= 18) i_col++; + if(Type == ATCFLineType::GenTrack && i >= 2 && i <= 18) i_col++; cs = DataLine::get_item(i_col); @@ -361,9 +361,9 @@ int ATCFLineBase::lead() const { ConcatString ATCFLineBase::storm_id() const { ConcatString cs; - // For ATCFLineType_GenTrack, use the contents of the extra 3rd column + // For ATCFLineType::GenTrack, use the contents of the extra 3rd column // Call DataLine::get_item() to avoid the column shifting logic - if(Type == ATCFLineType_GenTrack) { + if(Type == ATCFLineType::GenTrack) { cs = DataLine::get_item(GenStormIdOffset); } else { @@ -481,21 +481,21 @@ int parse_int_check_zero(const char *s) { ATCFLineType string_to_atcflinetype(const char *s) { ATCFLineType t; - if(!s) t = NoATCFLineType; + if(!s) t = ATCFLineType::None; // YYYYMMDDHH in the 4th column for Genesis Tracks - else if(is_yyyymmddhh(s)) t = ATCFLineType_GenTrack; - else if(is_number(s)) t = ATCFLineType_Track; // ADECK - else if(m_strlen(s) == 0) t = ATCFLineType_Track; // BDECK - else if(strcasecmp(s, "TR") == 0) t = ATCFLineType_ProbTR; - else if(strcasecmp(s, "IN") == 0) t = ATCFLineType_ProbIN; - else if(strcasecmp(s, "RI") == 0) t = ATCFLineType_ProbRI; - else if(strcasecmp(s, "RW") == 0) t = ATCFLineType_ProbRW; - else if(strcasecmp(s, "WR") == 0) t = ATCFLineType_ProbWR; - else if(strcasecmp(s, "PR") == 0) t = ATCFLineType_ProbPR; - else if(strcasecmp(s, "GN") == 0) t = ATCFLineType_ProbGN; - else if(strcasecmp(s, "GS") == 0) t = ATCFLineType_ProbGS; - else if(strcasecmp(s, "ER") == 0) t = ATCFLineType_ProbER; - else t = NoATCFLineType; + else if(is_yyyymmddhh(s)) t = ATCFLineType::GenTrack; + else if(is_number(s)) t = ATCFLineType::Track; // ADECK + else if(m_strlen(s) == 0) t = ATCFLineType::Track; // BDECK + else if(strcasecmp(s, "TR") == 0) t = ATCFLineType::ProbTR; + else if(strcasecmp(s, "IN") == 0) t = ATCFLineType::ProbIN; + else if(strcasecmp(s, "RI") == 0) t = ATCFLineType::ProbRI; + else if(strcasecmp(s, "RW") == 0) t = ATCFLineType::ProbRW; + else if(strcasecmp(s, "WR") == 0) t = ATCFLineType::ProbWR; + else if(strcasecmp(s, "PR") == 0) t = ATCFLineType::ProbPR; + else if(strcasecmp(s, "GN") == 0) t = ATCFLineType::ProbGN; + else if(strcasecmp(s, "GS") == 0) t = ATCFLineType::ProbGS; + else if(strcasecmp(s, "ER") == 0) t = ATCFLineType::ProbER; + else t = ATCFLineType::None; return t; } @@ -506,19 +506,19 @@ ConcatString atcflinetype_to_string(const ATCFLineType t) { const char *s = (const char *) nullptr; switch(t) { - case ATCFLineType_Track: s = "Track"; break; - case ATCFLineType_GenTrack: s = "GenTrack"; break; - case ATCFLineType_ProbTR: s = "ProbTR"; break; - case ATCFLineType_ProbIN: s = "ProbIN"; break; - case ATCFLineType_ProbRI: s = "ProbRI"; break; - case ATCFLineType_ProbRW: s = "ProbRW"; break; - case ATCFLineType_ProbWR: s = "ProbWR"; break; - case ATCFLineType_ProbPR: s = "ProbPR"; break; - case ATCFLineType_ProbGN: s = "ProbGN"; break; - case ATCFLineType_ProbGS: s = "ProbGS"; break; - case ATCFLineType_ProbER: s = "ProbER"; break; - case NoATCFLineType: s = na_str; break; - default: s = na_str; break; + case ATCFLineType::Track: s = "Track"; break; + case ATCFLineType::GenTrack: s = "GenTrack"; break; + case ATCFLineType::ProbTR: s = "ProbTR"; break; + case ATCFLineType::ProbIN: s = "ProbIN"; break; + case ATCFLineType::ProbRI: s = "ProbRI"; break; + case ATCFLineType::ProbRW: s = "ProbRW"; break; + case ATCFLineType::ProbWR: s = "ProbWR"; break; + case ATCFLineType::ProbPR: s = "ProbPR"; break; + case ATCFLineType::ProbGN: s = "ProbGN"; break; + case ATCFLineType::ProbGS: s = "ProbGS"; break; + case ATCFLineType::ProbER: s = "ProbER"; break; + case ATCFLineType::None: s = na_str; break; + default: s = na_str; break; } return ConcatString(s); diff --git a/src/libcode/vx_tc_util/atcf_line_base.h b/src/libcode/vx_tc_util/atcf_line_base.h index d7c04863d1..8b1141ffad 100644 --- a/src/libcode/vx_tc_util/atcf_line_base.h +++ b/src/libcode/vx_tc_util/atcf_line_base.h @@ -29,20 +29,20 @@ //////////////////////////////////////////////////////////////////////// -enum ATCFLineType { - ATCFLineType_Track, // Track and intensity line type (numeric) - ATCFLineType_GenTrack, // Genesis Track and intensity line type (numeric) - ATCFLineType_ProbTR, // Track probability (TR) - ATCFLineType_ProbIN, // Intensity probability (IN) - ATCFLineType_ProbRI, // Rapid intensification probability (RI) - ATCFLineType_ProbRW, // Rapid weakening probability (RW) - ATCFLineType_ProbWR, // Wind radii probability (WR) - ATCFLineType_ProbPR, // Pressure probability (PR) - ATCFLineType_ProbGN, // TC genesis probability (GN) - ATCFLineType_ProbGS, // TC genesis shape probability (GS) - ATCFLineType_ProbER, // Eyewall replacement probability (ER) - - NoATCFLineType +enum class ATCFLineType { + Track, // Track and intensity line type (numeric) + GenTrack, // Genesis Track and intensity line type (numeric) + ProbTR, // Track probability (TR) + ProbIN, // Intensity probability (IN) + ProbRI, // Rapid intensification probability (RI) + ProbRW, // Rapid weakening probability (RW) + ProbWR, // Wind radii probability (WR) + ProbPR, // Pressure probability (PR) + ProbGN, // TC genesis probability (GN) + ProbGS, // TC genesis shape probability (GS) + ProbER, // Eyewall replacement probability (ER) + + None }; extern ATCFLineType string_to_atcflinetype(const char *); diff --git a/src/libcode/vx_tc_util/atcf_offsets.h b/src/libcode/vx_tc_util/atcf_offsets.h index deb4758cb8..50f2df28e2 100644 --- a/src/libcode/vx_tc_util/atcf_offsets.h +++ b/src/libcode/vx_tc_util/atcf_offsets.h @@ -30,7 +30,7 @@ static const int LonTenthsOffset = 7; // // Offsets specific to the ADECK and BDECK track lines // http://www.nrlmry.navy.mil/atcf_web/docs/database/new/abrdeck.html -// Offsets for columns common to ATCFLineType_Track and ATCFLineType_GenTrack +// Offsets for columns common to ATCFLineType::Track and ATCFLineType::GenTrack // static const int VMaxOffset = 8; @@ -49,7 +49,7 @@ static const int IsobarRadiusOffset = 18; static const int MaxWindRadiusOffset = 19; // -// Offsets for columns specific to the ATCFLineType_Track +// Offsets for columns specific to the ATCFLineType::Track // static const int GustsOffset = 20; @@ -76,7 +76,7 @@ static const int WarmCoreOffset = 39; static const char ThermoParams_Str[] = "THERMO PARARMS"; // -// Offsets for columns specific to the ATCFLineType_GenTrack +// Offsets for columns specific to the ATCFLineType::GenTrack // Reference: https://dtcenter.org/HurrWRF/users/docs/users_guide/HWRF-UG-2018.pdf // diff --git a/src/libcode/vx_tc_util/atcf_prob_line.cc b/src/libcode/vx_tc_util/atcf_prob_line.cc index c5cc659a9d..8b320eb912 100644 --- a/src/libcode/vx_tc_util/atcf_prob_line.cc +++ b/src/libcode/vx_tc_util/atcf_prob_line.cc @@ -120,11 +120,11 @@ int ATCFProbLine::read_line(LineDataFile * ldf) { // Check the line type switch(Type) { - case ATCFLineType_ProbRI: + case ATCFLineType::ProbRI: n_expect = MinATCFProbRIRWElements; break; - case ATCFLineType_ProbGN: + case ATCFLineType::ProbGN: n_expect = MinATCFProbGNElements; break; diff --git a/src/libcode/vx_tc_util/atcf_track_line.cc b/src/libcode/vx_tc_util/atcf_track_line.cc index d6368e38a3..8dc42d3f42 100644 --- a/src/libcode/vx_tc_util/atcf_track_line.cc +++ b/src/libcode/vx_tc_util/atcf_track_line.cc @@ -143,8 +143,8 @@ int ATCFTrackLine::read_line(LineDataFile * ldf) { if(!status) return 0; // Check the line type - if(Type != ATCFLineType_Track && - Type != ATCFLineType_GenTrack) { + if(Type != ATCFLineType::Track && + Type != ATCFLineType::GenTrack) { mlog << Warning << "\nint ATCFTrackLine::read_line(LineDataFile * ldf) -> " << "unexpected ATCF line type (" @@ -153,9 +153,9 @@ int ATCFTrackLine::read_line(LineDataFile * ldf) { } // Check for the minumum number of track line elements - if((Type == ATCFLineType_Track && + if((Type == ATCFLineType::Track && n_items() < MinATCFTrackElements) || - (Type == ATCFLineType_GenTrack && + (Type == ATCFLineType::GenTrack && n_items() < MinATCFGenTrackElements)) { mlog << Warning << "\nint ATCFTrackLine::read_line(LineDataFile * ldf) -> " @@ -189,7 +189,7 @@ int ATCFTrackLine::mslp() const { CycloneLevel ATCFTrackLine::level() const { return(LevelOffset < N_items ? string_to_cyclonelevel(get_item(LevelOffset).c_str()) : - NoCycloneLevel); + CycloneLevel::None); } //////////////////////////////////////////////////////////////////////// @@ -205,7 +205,7 @@ int ATCFTrackLine::wind_intensity() const { QuadrantType ATCFTrackLine::quadrant() const { return(QuadrantOffset < N_items ? string_to_quadranttype(get_item(QuadrantOffset).c_str()) : - NoQuadrantType); + QuadrantType::None); } //////////////////////////////////////////////////////////////////////// @@ -267,11 +267,11 @@ int ATCFTrackLine::max_wind_radius() const { //////////////////////////////////////////////////////////////////////// int ATCFTrackLine::storm_direction() const { - if(Type == ATCFLineType_Track && + if(Type == ATCFLineType::Track && StormDirectionOffset < N_items) { return parse_int(get_item(StormDirectionOffset).c_str()); } - else if(Type == ATCFLineType_GenTrack && + else if(Type == ATCFLineType::GenTrack && StormDirectionOffset < N_items) { return parse_int(get_item(GenStormDirectionOffset).c_str()); } @@ -281,11 +281,11 @@ int ATCFTrackLine::storm_direction() const { //////////////////////////////////////////////////////////////////////// int ATCFTrackLine::storm_speed() const { - if(Type == ATCFLineType_Track && + if(Type == ATCFLineType::Track && StormSpeedOffset < N_items) { return parse_int(get_item(StormSpeedOffset).c_str()); } - else if(Type == ATCFLineType_GenTrack && + else if(Type == ATCFLineType::GenTrack && StormSpeedOffset < N_items) { return parse_int(get_item(GenStormSpeedOffset).c_str()); } @@ -294,18 +294,18 @@ int ATCFTrackLine::storm_speed() const { //////////////////////////////////////////////////////////////////////// // -// For ATCFLineType_Track, only valid when UserDefined = THERMO PARAMS -// For ATCFLineType_GenTrack, get the warm core column +// For ATCFLineType::Track, only valid when UserDefined = THERMO PARAMS +// For ATCFLineType::GenTrack, get the warm core column // //////////////////////////////////////////////////////////////////////// bool ATCFTrackLine::warm_core() const { - if(Type == ATCFLineType_Track && + if(Type == ATCFLineType::Track && WarmCoreOffset < N_items) { return(get_item(UserDefinedOffset).comparecase(ThermoParams_Str) == 0 && get_item(WarmCoreOffset).comparecase("Y") == 0); } - else if(Type == ATCFLineType_GenTrack && + else if(Type == ATCFLineType::GenTrack && GenWarmCoreOffset < N_items) { return(get_item(GenWarmCoreOffset).comparecase("Y") == 0); } @@ -314,12 +314,12 @@ bool ATCFTrackLine::warm_core() const { //////////////////////////////////////////////////////////////////////// // -// Specific to ATCFLineType_Track +// Specific to ATCFLineType::Track // //////////////////////////////////////////////////////////////////////// int ATCFTrackLine::gusts() const { - return(Type == ATCFLineType_Track && GustsOffset < N_items ? + return(Type == ATCFLineType::Track && GustsOffset < N_items ? parse_int_check_zero(get_item(GustsOffset).c_str()) : bad_data_int); } @@ -327,7 +327,7 @@ int ATCFTrackLine::gusts() const { //////////////////////////////////////////////////////////////////////// int ATCFTrackLine::eye_diameter() const { - return(Type == ATCFLineType_Track && EyeDiameterOffset < N_items ? + return(Type == ATCFLineType::Track && EyeDiameterOffset < N_items ? parse_int_check_zero(get_item(EyeDiameterOffset).c_str()) : bad_data_int); } @@ -335,15 +335,15 @@ int ATCFTrackLine::eye_diameter() const { //////////////////////////////////////////////////////////////////////// SubregionCode ATCFTrackLine::subregion() const { - return(Type == ATCFLineType_Track && SubRegionOffset < N_items ? + return(Type == ATCFLineType::Track && SubRegionOffset < N_items ? string_to_subregioncode(get_item(SubRegionOffset).c_str()) : - NoSubregionCode); + SubregionCode::None); } //////////////////////////////////////////////////////////////////////// int ATCFTrackLine::max_seas() const { - return(Type == ATCFLineType_Track && MaxSeasOffset < N_items ? + return(Type == ATCFLineType::Track && MaxSeasOffset < N_items ? parse_int_check_zero(get_item(MaxSeasOffset).c_str()) : bad_data_int); } @@ -351,7 +351,7 @@ int ATCFTrackLine::max_seas() const { //////////////////////////////////////////////////////////////////////// ConcatString ATCFTrackLine::initials() const { - return(Type == ATCFLineType_Track && InitialsOffset < N_items ? + return(Type == ATCFLineType::Track && InitialsOffset < N_items ? (string) get_item(InitialsOffset) : (string) ""); } @@ -359,7 +359,7 @@ ConcatString ATCFTrackLine::initials() const { //////////////////////////////////////////////////////////////////////// ConcatString ATCFTrackLine::storm_name() const { - return(Type == ATCFLineType_Track && StormNameOffset < N_items ? + return(Type == ATCFLineType::Track && StormNameOffset < N_items ? (string) get_item(StormNameOffset) : (string) ""); } @@ -367,15 +367,15 @@ ConcatString ATCFTrackLine::storm_name() const { //////////////////////////////////////////////////////////////////////// SystemsDepth ATCFTrackLine::depth() const { - return(Type == ATCFLineType_Track && DepthOffset < N_items ? + return(Type == ATCFLineType::Track && DepthOffset < N_items ? string_to_systemsdepth(get_item(DepthOffset).c_str()) : - NoSystemsDepth); + SystemsDepth::None); } //////////////////////////////////////////////////////////////////////// int ATCFTrackLine::wave_height() const { - return(Type == ATCFLineType_Track && WaveHeightOffset < N_items ? + return(Type == ATCFLineType::Track && WaveHeightOffset < N_items ? parse_int_check_zero(get_item(WaveHeightOffset).c_str()) : bad_data_int); } @@ -383,15 +383,15 @@ int ATCFTrackLine::wave_height() const { //////////////////////////////////////////////////////////////////////// QuadrantType ATCFTrackLine::seas_code() const { - return(Type == ATCFLineType_Track && SeasCodeOffset < N_items ? + return(Type == ATCFLineType::Track && SeasCodeOffset < N_items ? string_to_quadranttype(get_item(SeasCodeOffset).c_str()) : - NoQuadrantType); + QuadrantType::None); } //////////////////////////////////////////////////////////////////////// int ATCFTrackLine::seas_radius1() const { - return(Type == ATCFLineType_Track && SeasRadius1Offset < N_items ? + return(Type == ATCFLineType::Track && SeasRadius1Offset < N_items ? parse_int_check_zero(get_item(SeasRadius1Offset).c_str()) : bad_data_int); } @@ -399,7 +399,7 @@ int ATCFTrackLine::seas_radius1() const { //////////////////////////////////////////////////////////////////////// int ATCFTrackLine::seas_radius2() const { - return(Type == ATCFLineType_Track && SeasRadius2Offset < N_items ? + return(Type == ATCFLineType::Track && SeasRadius2Offset < N_items ? parse_int_check_zero(get_item(SeasRadius2Offset).c_str()) : bad_data_int); } @@ -407,7 +407,7 @@ int ATCFTrackLine::seas_radius2() const { //////////////////////////////////////////////////////////////////////// int ATCFTrackLine::seas_radius3() const { - return(Type == ATCFLineType_Track && SeasRadius3Offset < N_items ? + return(Type == ATCFLineType::Track && SeasRadius3Offset < N_items ? parse_int_check_zero(get_item(SeasRadius3Offset).c_str()) : bad_data_int); } @@ -415,19 +415,19 @@ int ATCFTrackLine::seas_radius3() const { //////////////////////////////////////////////////////////////////////// int ATCFTrackLine::seas_radius4() const { - return(Type == ATCFLineType_Track && SeasRadius4Offset < N_items ? + return(Type == ATCFLineType::Track && SeasRadius4Offset < N_items ? parse_int_check_zero(get_item(SeasRadius4Offset).c_str()) : bad_data_int); } //////////////////////////////////////////////////////////////////////// // -// Specific to ATCFLineType_Track +// Specific to ATCFLineType::Track // //////////////////////////////////////////////////////////////////////// double ATCFTrackLine::parameter_b() const { - int v = (Type == ATCFLineType_GenTrack && GenParameterBOffset < N_items ? + int v = (Type == ATCFLineType::GenTrack && GenParameterBOffset < N_items ? parse_int(get_item(GenParameterBOffset).c_str(), -999) : bad_data_int); return(!is_bad_data(v) ? v/10.0 : bad_data_double); @@ -436,7 +436,7 @@ double ATCFTrackLine::parameter_b() const { //////////////////////////////////////////////////////////////////////// double ATCFTrackLine::therm_wind_lower() const { - int v = (Type == ATCFLineType_GenTrack && GenThermWindLowerOffset < N_items ? + int v = (Type == ATCFLineType::GenTrack && GenThermWindLowerOffset < N_items ? parse_int(get_item(GenThermWindLowerOffset).c_str(), -9999) : bad_data_int); return(!is_bad_data(v) ? v/10.0 : bad_data_double); @@ -445,7 +445,7 @@ double ATCFTrackLine::therm_wind_lower() const { //////////////////////////////////////////////////////////////////////// double ATCFTrackLine::therm_wind_upper() const { - int v = (Type == ATCFLineType_GenTrack && GenThermWindUpperOffset < N_items ? + int v = (Type == ATCFLineType::GenTrack && GenThermWindUpperOffset < N_items ? parse_int(get_item(GenThermWindUpperOffset).c_str(), -9999) : bad_data_int); return(!is_bad_data(v) ? v/10.0 : bad_data_double); @@ -454,7 +454,7 @@ double ATCFTrackLine::therm_wind_upper() const { //////////////////////////////////////////////////////////////////////// int ATCFTrackLine::mean_850_vort() const { - return(Type == ATCFLineType_GenTrack && GenMean850VortOffset < N_items ? + return(Type == ATCFLineType::GenTrack && GenMean850VortOffset < N_items ? parse_int(get_item(GenThermWindUpperOffset).c_str(), -9999) : bad_data_int); } @@ -462,7 +462,7 @@ int ATCFTrackLine::mean_850_vort() const { //////////////////////////////////////////////////////////////////////// int ATCFTrackLine::max_850_vort() const { - return(Type == ATCFLineType_GenTrack && GenMax850VortOffset < N_items ? + return(Type == ATCFLineType::GenTrack && GenMax850VortOffset < N_items ? parse_int(get_item(GenThermWindUpperOffset).c_str(), -9999) : bad_data_int); } @@ -470,7 +470,7 @@ int ATCFTrackLine::max_850_vort() const { //////////////////////////////////////////////////////////////////////// int ATCFTrackLine::mean_700_vort() const { - return(Type == ATCFLineType_GenTrack && GenMean700VortOffset < N_items ? + return(Type == ATCFLineType::GenTrack && GenMean700VortOffset < N_items ? parse_int(get_item(GenThermWindUpperOffset).c_str(), -9999) : bad_data_int); } @@ -478,7 +478,7 @@ int ATCFTrackLine::mean_700_vort() const { //////////////////////////////////////////////////////////////////////// int ATCFTrackLine::max_700_vort() const { - return(Type == ATCFLineType_GenTrack && GenMax700VortOffset < N_items ? + return(Type == ATCFLineType::GenTrack && GenMax700VortOffset < N_items ? parse_int(get_item(GenThermWindUpperOffset).c_str(), -9999) : bad_data_int); } @@ -500,19 +500,19 @@ WatchWarnType ww_max(const WatchWarnType t1, const WatchWarnType t2) { // GaleWarn, // StormWarn - if(t1 == HurricaneWarn || - t2 == HurricaneWarn ) t = HurricaneWarn; - else if(t1 == TropicalStormWarn || - t2 == TropicalStormWarn ) t = TropicalStormWarn; - else if(t1 == HurricaneWatch || - t2 == HurricaneWatch ) t = HurricaneWatch; - else if(t1 == TropicalStormWatch || - t2 == TropicalStormWatch ) t = TropicalStormWatch; - else if(t1 == GaleWarn || - t2 == GaleWarn ) t = GaleWarn; - else if(t1 == StormWarn || - t2 == StormWarn ) t = StormWarn; - else t = NoWatchWarnType; + if(t1 == WatchWarnType::HurricaneWarn || + t2 == WatchWarnType::HurricaneWarn ) t = WatchWarnType::HurricaneWarn; + else if(t1 == WatchWarnType::TropicalStormWarn || + t2 == WatchWarnType::TropicalStormWarn ) t = WatchWarnType::TropicalStormWarn; + else if(t1 == WatchWarnType::HurricaneWatch || + t2 == WatchWarnType::HurricaneWatch ) t = WatchWarnType::HurricaneWatch; + else if(t1 == WatchWarnType::TropicalStormWatch || + t2 == WatchWarnType::TropicalStormWatch ) t = WatchWarnType::TropicalStormWatch; + else if(t1 == WatchWarnType::GaleWarn || + t2 == WatchWarnType::GaleWarn ) t = WatchWarnType::GaleWarn; + else if(t1 == WatchWarnType::StormWarn || + t2 == WatchWarnType::StormWarn ) t = WatchWarnType::StormWarn; + else t = WatchWarnType::None; return t; } @@ -522,13 +522,13 @@ WatchWarnType ww_max(const WatchWarnType t1, const WatchWarnType t2) { WatchWarnType int_to_watchwarntype(int i) { WatchWarnType t; - if(i == 1) t = TropicalStormWatch; - else if(i == 2) t = TropicalStormWarn; - else if(i == 3) t = GaleWarn; - else if(i == 4) t = StormWarn; - else if(i == 5) t = HurricaneWatch; - else if(i == 6) t = HurricaneWarn; - else t = NoWatchWarnType; + if(i == 1) t = WatchWarnType::TropicalStormWatch; + else if(i == 2) t = WatchWarnType::TropicalStormWarn; + else if(i == 3) t = WatchWarnType::GaleWarn; + else if(i == 4) t = WatchWarnType::StormWarn; + else if(i == 5) t = WatchWarnType::HurricaneWatch; + else if(i == 6) t = WatchWarnType::HurricaneWarn; + else t = WatchWarnType::None; return t; } @@ -539,13 +539,13 @@ WatchWarnType int_to_watchwarntype(int i) { WatchWarnType string_to_watchwarntype(const char *s) { WatchWarnType t; - if(strcasecmp(s, "TSWATCH") == 0) t = TropicalStormWatch; - else if(strcasecmp(s, "TSWARN") == 0) t = TropicalStormWarn; - else if(strcasecmp(s, "GLWARN") == 0) t = GaleWarn; - else if(strcasecmp(s, "STWARN") == 0) t = StormWarn; - else if(strcasecmp(s, "HUWATCH") == 0) t = HurricaneWatch; - else if(strcasecmp(s, "HUWARN") == 0) t = HurricaneWarn; - else t = NoWatchWarnType; + if(strcasecmp(s, "TSWATCH") == 0) t = WatchWarnType::TropicalStormWatch; + else if(strcasecmp(s, "TSWARN") == 0) t = WatchWarnType::TropicalStormWarn; + else if(strcasecmp(s, "GLWARN") == 0) t = WatchWarnType::GaleWarn; + else if(strcasecmp(s, "STWARN") == 0) t = WatchWarnType::StormWarn; + else if(strcasecmp(s, "HUWATCH") == 0) t = WatchWarnType::HurricaneWatch; + else if(strcasecmp(s, "HUWARN") == 0) t = WatchWarnType::HurricaneWarn; + else t = WatchWarnType::None; return t; } @@ -556,14 +556,14 @@ ConcatString watchwarntype_to_string(const WatchWarnType t) { const char *s = (const char *) nullptr; switch(t) { - case TropicalStormWatch: s = "TSWATCH"; break; - case TropicalStormWarn: s = "TSWARN"; break; - case GaleWarn: s = "GLWARN"; break; - case StormWarn: s = "STWARN"; break; - case HurricaneWatch: s = "HUWATCH"; break; - case HurricaneWarn: s = "HUWARN"; break; - case NoWatchWarnType: s = na_str; break; - default: s = na_str; break; + case WatchWarnType::TropicalStormWatch: s = "TSWATCH"; break; + case WatchWarnType::TropicalStormWarn: s = "TSWARN"; break; + case WatchWarnType::GaleWarn: s = "GLWARN"; break; + case WatchWarnType::StormWarn: s = "STWARN"; break; + case WatchWarnType::HurricaneWatch: s = "HUWATCH"; break; + case WatchWarnType::HurricaneWarn: s = "HUWARN"; break; + case WatchWarnType::None: s = na_str; break; + default: s = na_str; break; } return ConcatString(s); @@ -574,22 +574,22 @@ ConcatString watchwarntype_to_string(const WatchWarnType t) { CycloneLevel string_to_cyclonelevel(const char *s) { CycloneLevel l; - if(strcmp(s, "DB") == 0) l = Disturbance; - else if(strcmp(s, "TD") == 0) l = TropicalDepression; - else if(strcmp(s, "TS") == 0) l = TropicalStorm; - else if(strcmp(s, "TY") == 0) l = Typhoon; - else if(strcmp(s, "ST") == 0) l = SuperTyphoon; - else if(strcmp(s, "TC") == 0) l = TropicalCyclone; - else if(strcmp(s, "HU") == 0) l = Hurricane; - else if(strcmp(s, "SD") == 0) l = SubtropicalDepression; - else if(strcmp(s, "SS") == 0) l = SubtropicalStorm; - else if(strcmp(s, "EX") == 0) l = ExtratropicalSystem; - else if(strcmp(s, "IN") == 0) l = Inland; - else if(strcmp(s, "DS") == 0) l = Dissipating; - else if(strcmp(s, "LO") == 0) l = Low; - else if(strcmp(s, "WV") == 0) l = TropicalWave; - else if(strcmp(s, "ET") == 0) l = Extrapolated; - else /* "XX" */ l = NoCycloneLevel; + if(strcmp(s, "DB") == 0) l = CycloneLevel::Disturbance; + else if(strcmp(s, "TD") == 0) l = CycloneLevel::TropicalDepression; + else if(strcmp(s, "TS") == 0) l = CycloneLevel::TropicalStorm; + else if(strcmp(s, "TY") == 0) l = CycloneLevel::Typhoon; + else if(strcmp(s, "ST") == 0) l = CycloneLevel::SuperTyphoon; + else if(strcmp(s, "TC") == 0) l = CycloneLevel::TropicalCyclone; + else if(strcmp(s, "HU") == 0) l = CycloneLevel::Hurricane; + else if(strcmp(s, "SD") == 0) l = CycloneLevel::SubtropicalDepression; + else if(strcmp(s, "SS") == 0) l = CycloneLevel::SubtropicalStorm; + else if(strcmp(s, "EX") == 0) l = CycloneLevel::ExtratropicalSystem; + else if(strcmp(s, "IN") == 0) l = CycloneLevel::Inland; + else if(strcmp(s, "DS") == 0) l = CycloneLevel::Dissipating; + else if(strcmp(s, "LO") == 0) l = CycloneLevel::Low; + else if(strcmp(s, "WV") == 0) l = CycloneLevel::TropicalWave; + else if(strcmp(s, "ET") == 0) l = CycloneLevel::Extrapolated; + else /* "XX" */ l = CycloneLevel::None; return l; } @@ -600,23 +600,23 @@ ConcatString cyclonelevel_to_string(const CycloneLevel t) { const char *s = (const char *) nullptr; switch(t) { - case Disturbance: s = "DB"; break; - case TropicalDepression: s = "TD"; break; - case TropicalStorm: s = "TS"; break; - case Typhoon: s = "TY"; break; - case SuperTyphoon: s = "ST"; break; - case TropicalCyclone: s = "TC"; break; - case Hurricane: s = "HU"; break; - case SubtropicalDepression: s = "SD"; break; - case SubtropicalStorm: s = "SS"; break; - case ExtratropicalSystem: s = "EX"; break; - case Inland: s = "IN"; break; - case Dissipating: s = "DS"; break; - case Low: s = "LO"; break; - case TropicalWave: s = "WV"; break; - case Extrapolated: s = "ET"; break; - case NoCycloneLevel: s = na_str; break; - default: s = na_str; break; + case CycloneLevel::Disturbance: s = "DB"; break; + case CycloneLevel::TropicalDepression: s = "TD"; break; + case CycloneLevel::TropicalStorm: s = "TS"; break; + case CycloneLevel::Typhoon: s = "TY"; break; + case CycloneLevel::SuperTyphoon: s = "ST"; break; + case CycloneLevel::TropicalCyclone: s = "TC"; break; + case CycloneLevel::Hurricane: s = "HU"; break; + case CycloneLevel::SubtropicalDepression: s = "SD"; break; + case CycloneLevel::SubtropicalStorm: s = "SS"; break; + case CycloneLevel::ExtratropicalSystem: s = "EX"; break; + case CycloneLevel::Inland: s = "IN"; break; + case CycloneLevel::Dissipating: s = "DS"; break; + case CycloneLevel::Low: s = "LO"; break; + case CycloneLevel::TropicalWave: s = "WV"; break; + case CycloneLevel::Extrapolated: s = "ET"; break; + case CycloneLevel::None: s = na_str; break; + default: s = na_str; break; } return ConcatString(s); @@ -628,9 +628,9 @@ CycloneLevel wind_speed_to_cyclonelevel(int s) { CycloneLevel l; // Apply logic to convert wind speed to CycloneLevel - if(s <= 33) l = TropicalDepression; - else if(s <= 63) l = TropicalStorm; - else l = Hurricane; + if(s <= 33) l = CycloneLevel::TropicalDepression; + else if(s <= 63) l = CycloneLevel::TropicalStorm; + else l = CycloneLevel::Hurricane; return l; } @@ -640,16 +640,16 @@ CycloneLevel wind_speed_to_cyclonelevel(int s) { QuadrantType string_to_quadranttype(const char *s) { QuadrantType t; - if(strcmp(s, "AAA") == 0) t = FullCircle; - else if(strcmp(s, "NNQ") == 0) t = N_Quadrant; - else if(strcmp(s, "EEQ") == 0) t = E_Quadrant; - else if(strcmp(s, "SSQ") == 0) t = S_Quadrant; - else if(strcmp(s, "WWQ") == 0) t = W_Quadrant; - else if(strcmp(s, "NEQ") == 0) t = NE_Quadrant; - else if(strcmp(s, "SEQ") == 0) t = SE_Quadrant; - else if(strcmp(s, "SWQ") == 0) t = SW_Quadrant; - else if(strcmp(s, "NWQ") == 0) t = NW_Quadrant; - else t = NoQuadrantType; + if(strcmp(s, "AAA") == 0) t = QuadrantType::FullCircle; + else if(strcmp(s, "NNQ") == 0) t = QuadrantType::N; + else if(strcmp(s, "EEQ") == 0) t = QuadrantType::E; + else if(strcmp(s, "SSQ") == 0) t = QuadrantType::S; + else if(strcmp(s, "WWQ") == 0) t = QuadrantType::W; + else if(strcmp(s, "NEQ") == 0) t = QuadrantType::NE; + else if(strcmp(s, "SEQ") == 0) t = QuadrantType::SE; + else if(strcmp(s, "SWQ") == 0) t = QuadrantType::SW; + else if(strcmp(s, "NWQ") == 0) t = QuadrantType::NW; + else t = QuadrantType::None; return t; } @@ -660,17 +660,17 @@ ConcatString quadranttype_to_string(const QuadrantType t) { const char *s = (const char *) nullptr; switch(t) { - case FullCircle: s = "AAA"; break; - case N_Quadrant: s = "NNQ"; break; - case E_Quadrant: s = "EEQ"; break; - case S_Quadrant: s = "SSQ"; break; - case W_Quadrant: s = "WWQ"; break; - case NE_Quadrant: s = "NEQ"; break; - case SE_Quadrant: s = "SEQ"; break; - case SW_Quadrant: s = "SWQ"; break; - case NW_Quadrant: s = "NWQ"; break; - case NoQuadrantType: s = na_str; break; - default: s = na_str; break; + case QuadrantType::FullCircle: s = "AAA"; break; + case QuadrantType::N: s = "NNQ"; break; + case QuadrantType::E: s = "EEQ"; break; + case QuadrantType::S: s = "SSQ"; break; + case QuadrantType::W: s = "WWQ"; break; + case QuadrantType::NE: s = "NEQ"; break; + case QuadrantType::SE: s = "SEQ"; break; + case QuadrantType::SW: s = "SWQ"; break; + case QuadrantType::NW: s = "NWQ"; break; + case QuadrantType::None: s = na_str; break; + default: s = na_str; break; } return ConcatString(s); @@ -681,16 +681,16 @@ ConcatString quadranttype_to_string(const QuadrantType t) { SubregionCode string_to_subregioncode(const char *s) { SubregionCode c; - if(strcmp(s, "A") == 0) c = Arabian_Sea; - else if(strcmp(s, "B") == 0) c = Bay_of_Bengal; - else if(strcmp(s, "C") == 0) c = Central_Pacific; - else if(strcmp(s, "E") == 0) c = Eastern_Pacific; - else if(strcmp(s, "L") == 0) c = Atlantic; - else if(strcmp(s, "P") == 0) c = South_Pacific; - else if(strcmp(s, "Q") == 0) c = South_Atlantic; - else if(strcmp(s, "S") == 0) c = South_IO; - else if(strcmp(s, "W") == 0) c = Western_Pacific; - else c = NoSubregionCode; + if(strcmp(s, "A") == 0) c = SubregionCode::Arabian_Sea; + else if(strcmp(s, "B") == 0) c = SubregionCode::Bay_of_Bengal; + else if(strcmp(s, "C") == 0) c = SubregionCode::Central_Pacific; + else if(strcmp(s, "E") == 0) c = SubregionCode::Eastern_Pacific; + else if(strcmp(s, "L") == 0) c = SubregionCode::Atlantic; + else if(strcmp(s, "P") == 0) c = SubregionCode::South_Pacific; + else if(strcmp(s, "Q") == 0) c = SubregionCode::South_Atlantic; + else if(strcmp(s, "S") == 0) c = SubregionCode::South_IO; + else if(strcmp(s, "W") == 0) c = SubregionCode::Western_Pacific; + else c = SubregionCode::None; return c; } @@ -701,17 +701,17 @@ ConcatString subregioncode_to_string(const SubregionCode t) { const char *s = (const char *) nullptr; switch(t) { - case Arabian_Sea: s = "A"; break; - case Bay_of_Bengal: s = "B"; break; - case Central_Pacific: s = "C"; break; - case Eastern_Pacific: s = "E"; break; - case Atlantic: s = "L"; break; - case South_Pacific: s = "P"; break; - case South_Atlantic: s = "Q"; break; - case South_IO: s = "S"; break; - case Western_Pacific: s = "W"; break; - case NoSubregionCode: s = na_str; break; - default: s = na_str; break; + case SubregionCode::Arabian_Sea: s = "A"; break; + case SubregionCode::Bay_of_Bengal: s = "B"; break; + case SubregionCode::Central_Pacific: s = "C"; break; + case SubregionCode::Eastern_Pacific: s = "E"; break; + case SubregionCode::Atlantic: s = "L"; break; + case SubregionCode::South_Pacific: s = "P"; break; + case SubregionCode::South_Atlantic: s = "Q"; break; + case SubregionCode::South_IO: s = "S"; break; + case SubregionCode::Western_Pacific: s = "W"; break; + case SubregionCode::None : s = na_str; break; + default: s = na_str; break; } return ConcatString(s); @@ -722,10 +722,10 @@ ConcatString subregioncode_to_string(const SubregionCode t) { SystemsDepth string_to_systemsdepth(const char *s) { SystemsDepth d; - if(strcmp(s, "D") == 0) d = DeepDepth; - else if(strcmp(s, "M") == 0) d = MediumDepth; - else if(strcmp(s, "S") == 0) d = ShallowDepth; - else d = NoSystemsDepth; + if(strcmp(s, "D") == 0) d = SystemsDepth::Deep; + else if(strcmp(s, "M") == 0) d = SystemsDepth::Medium; + else if(strcmp(s, "S") == 0) d = SystemsDepth::Shallow; + else d = SystemsDepth::None; return d; } @@ -736,11 +736,11 @@ ConcatString systemsdepth_to_string(const SystemsDepth t) { const char *s = (const char *) nullptr; switch(t) { - case DeepDepth: s = "D"; break; - case MediumDepth: s = "M"; break; - case ShallowDepth: s = "S"; break; - case NoSystemsDepth: s = na_str; break; - default: s = na_str; break; + case SystemsDepth::Deep: s = "D"; break; + case SystemsDepth::Medium: s = "M"; break; + case SystemsDepth::Shallow: s = "S"; break; + case SystemsDepth::None: s = na_str; break; + default: s = na_str; break; } return ConcatString(s); diff --git a/src/libcode/vx_tc_util/atcf_track_line.h b/src/libcode/vx_tc_util/atcf_track_line.h index d5ebb5555b..e7c9606904 100644 --- a/src/libcode/vx_tc_util/atcf_track_line.h +++ b/src/libcode/vx_tc_util/atcf_track_line.h @@ -26,7 +26,7 @@ //////////////////////////////////////////////////////////////////////// -enum WatchWarnType { +enum class WatchWarnType { TropicalStormWatch, // Tropical Storm Watch TropicalStormWarn, // Tropical Storm Warning @@ -36,7 +36,7 @@ enum WatchWarnType { HurricaneWatch, // Hurricane Watch HurricaneWarn, // Hurricane Warning - NoWatchWarnType + None }; extern WatchWarnType ww_max(const WatchWarnType, const WatchWarnType); @@ -46,7 +46,7 @@ extern ConcatString watchwarntype_to_string(const WatchWarnType); //////////////////////////////////////////////////////////////////////// -enum CycloneLevel { +enum class CycloneLevel { Disturbance, // DB TropicalDepression, // TD TropicalStorm, // TS @@ -67,7 +67,7 @@ enum CycloneLevel { TropicalWave, // WV Extrapolated, // ET - NoCycloneLevel // XX + None // XX }; extern CycloneLevel string_to_cyclonelevel(const char *); @@ -76,20 +76,20 @@ extern CycloneLevel wind_speed_to_cyclonelevel(int); //////////////////////////////////////////////////////////////////////// -enum QuadrantType { +enum class QuadrantType { FullCircle, // AAA - N_Quadrant, // NNQ - E_Quadrant, // EEQ - S_Quadrant, // SSQ - W_Quadrant, // WWQ + N, // NNQ + E, // EEQ + S, // SSQ + W, // WWQ - NE_Quadrant, // NEQ - SE_Quadrant, // SEQ - SW_Quadrant, // SWQ - NW_Quadrant, // NWQ + NE, // NEQ + SE, // SEQ + SW, // SWQ + NW, // NWQ - NoQuadrantType + None }; extern QuadrantType string_to_quadranttype(const char *); @@ -97,7 +97,7 @@ extern ConcatString quadranttype_to_string(const QuadrantType); //////////////////////////////////////////////////////////////////////// -enum SubregionCode { +enum class SubregionCode { Arabian_Sea, // A Bay_of_Bengal, // B Central_Pacific, // C @@ -107,7 +107,7 @@ enum SubregionCode { South_Atlantic, // Q South_IO, // S Western_Pacific, // W - NoSubregionCode + None }; extern SubregionCode string_to_subregioncode(const char *); @@ -115,11 +115,11 @@ extern ConcatString subregioncode_to_string(const SubregionCode); //////////////////////////////////////////////////////////////////////// -enum SystemsDepth { - DeepDepth, // D - MediumDepth, // M - ShallowDepth, // S - NoSystemsDepth // X +enum class SystemsDepth { + Deep, // D + Medium, // M + Shallow, // S + None // X }; extern SystemsDepth string_to_systemsdepth(const char *); @@ -177,7 +177,7 @@ class ATCFTrackLine : public ATCFLineBase { bool warm_core () const; // - // specific to ATCFLineType_Track + // specific to ATCFLineType::Track // int gusts () const; @@ -198,7 +198,7 @@ class ATCFTrackLine : public ATCFLineBase { int seas_radius4 () const; // - // specific to ATCFLineType_GenTrack + // specific to ATCFLineType::GenTrack // double parameter_b () const; diff --git a/src/libcode/vx_tc_util/diag_file.cc b/src/libcode/vx_tc_util/diag_file.cc index 2ea4fdeb3c..71cd94a81b 100644 --- a/src/libcode/vx_tc_util/diag_file.cc +++ b/src/libcode/vx_tc_util/diag_file.cc @@ -163,7 +163,7 @@ void DiagFile::init_from_scratch() { void DiagFile::clear() { // Initialize values - DiagSource = DiagType_None; + DiagSource = DiagType::None; TrackSource.clear(); FieldSource.clear(); StormId.clear(); @@ -215,10 +215,10 @@ void DiagFile::read(const ConcatString &path, const ConcatString &diag_source, DiagType type = string_to_diagtype(diag_source.c_str()); // Read diagnostics based on the source type - if(type == DiagType_CIRA_RT) { + if(type == DiagType::CIRA_RT) { read_cira_rt(path, convert_map); } - else if(type == DiagType_SHIPS_RT) { + else if(type == DiagType::SHIPS_RT) { read_ships_rt(path, convert_map); } else { @@ -249,7 +249,7 @@ void DiagFile::read_cira_rt(const ConcatString &path, clear(); // Store the file type - DiagSource = DiagType_CIRA_RT; + DiagSource = DiagType::CIRA_RT; // Open the file open(path.c_str()); @@ -399,7 +399,7 @@ void DiagFile::read_ships_rt(const ConcatString &path, clear(); // Store the file type - DiagSource = DiagType_SHIPS_RT; + DiagSource = DiagType::SHIPS_RT; // Open the file open(path.c_str()); diff --git a/src/libcode/vx_tc_util/pair_data_genesis.cc b/src/libcode/vx_tc_util/pair_data_genesis.cc index fe03b9bf3a..6eba3517d1 100644 --- a/src/libcode/vx_tc_util/pair_data_genesis.cc +++ b/src/libcode/vx_tc_util/pair_data_genesis.cc @@ -31,11 +31,11 @@ ConcatString genesispaircategory_to_string(const GenesisPairCategory c) { const char *s = (const char *) nullptr; switch(c) { - case FYOYGenesis: s = "FYOY"; break; - case FYONGenesis: s = "FYON"; break; - case FNOYGenesis: s = "FNOY"; break; - case DiscardGenesis: s = "DISCARD"; break; - default: s = na_str; break; + case GenesisPairCategory::FYOY: s = "FYOY"; break; + case GenesisPairCategory::FYON: s = "FYON"; break; + case GenesisPairCategory::FNOY: s = "FNOY"; break; + case GenesisPairCategory::Discard: s = "DISCARD"; break; + default: s = na_str; break; } return ConcatString(s); @@ -59,8 +59,8 @@ void GenesisPairDiff::clear() { DevDist = bad_data_double; DevDSec = bad_data_int; OpsDSec = bad_data_int; - DevCategory = NoGenesisPairCategory; - OpsCategory = NoGenesisPairCategory; + DevCategory = GenesisPairCategory::None; + OpsCategory = GenesisPairCategory::None; return; } diff --git a/src/libcode/vx_tc_util/pair_data_genesis.h b/src/libcode/vx_tc_util/pair_data_genesis.h index 8b248e2084..89b0a5b2f6 100644 --- a/src/libcode/vx_tc_util/pair_data_genesis.h +++ b/src/libcode/vx_tc_util/pair_data_genesis.h @@ -28,12 +28,12 @@ // //////////////////////////////////////////////////////////////////////// -enum GenesisPairCategory { - FYOYGenesis, // Hit - FYONGenesis, // False Alarm - FNOYGenesis, // Miss - DiscardGenesis, // Discard - NoGenesisPairCategory +enum class GenesisPairCategory { + FYOY, // Hit + FYON, // False Alarm + FNOY, // Miss + Discard, // Discard + None }; extern ConcatString genesispaircategory_to_string(const GenesisPairCategory); diff --git a/src/libcode/vx_tc_util/prob_gen_info.cc b/src/libcode/vx_tc_util/prob_gen_info.cc index 900142610a..7f3f37b83a 100644 --- a/src/libcode/vx_tc_util/prob_gen_info.cc +++ b/src/libcode/vx_tc_util/prob_gen_info.cc @@ -200,7 +200,7 @@ bool ProbGenInfo::add(const ATCFProbLine &l, double dland, bool check_dup) { } // Initialize the header information, if necessary - if(Type == NoATCFLineType) initialize(l, dland); + if(Type == ATCFLineType::None) initialize(l, dland); // Check for matching header information if(!is_match(l)) return false; diff --git a/src/libcode/vx_tc_util/prob_info_array.cc b/src/libcode/vx_tc_util/prob_info_array.cc index 9cfa6196a1..35a37708e2 100644 --- a/src/libcode/vx_tc_util/prob_info_array.cc +++ b/src/libcode/vx_tc_util/prob_info_array.cc @@ -244,7 +244,7 @@ bool ProbInfoArray::add(const ATCFProbLine &l, double dland, bool check_dup) { // Store based on the input line type switch(l.type()) { - case(ATCFLineType_ProbRI): + case(ATCFLineType::ProbRI): // Add line to an existing entry if(ProbRIRW.size() > 0 && @@ -260,7 +260,7 @@ bool ProbInfoArray::add(const ATCFProbLine &l, double dland, bool check_dup) { } break; - case(ATCFLineType_ProbGN): + case(ATCFLineType::ProbGN): // Add line to an existing entry if(ProbGen.size() > 0 && @@ -276,14 +276,14 @@ bool ProbInfoArray::add(const ATCFProbLine &l, double dland, bool check_dup) { if(gi.gen_or_dis() != "genFcst") { mlog << Debug(4) << "bool ProbInfoArray::add() -> " - << "skipping ATCF " << atcflinetype_to_string(ATCFLineType_ProbGN) + << "skipping ATCF " << atcflinetype_to_string(ATCFLineType::ProbGN) << " line with non-genesis probability type (" << gi.gen_or_dis() << " != genFcst).\n"; } else if(is_bad_data(gi.lat()) || is_bad_data(gi.lon())) { mlog << Debug(4) << "bool ProbInfoArray::add() -> " - << "skipping ATCF " << atcflinetype_to_string(ATCFLineType_ProbGN) + << "skipping ATCF " << atcflinetype_to_string(ATCFLineType::ProbGN) << " line with no predicted genesis location.\n"; } else { diff --git a/src/libcode/vx_tc_util/prob_info_base.cc b/src/libcode/vx_tc_util/prob_info_base.cc index 65e1a1abdc..762a9bfd88 100644 --- a/src/libcode/vx_tc_util/prob_info_base.cc +++ b/src/libcode/vx_tc_util/prob_info_base.cc @@ -71,7 +71,7 @@ void ProbInfoBase::init_from_scratch() { void ProbInfoBase::clear() { - Type = NoATCFLineType; + Type = ATCFLineType::None; StormId.clear(); Basin.clear(); Cyclone.clear(); @@ -266,7 +266,7 @@ bool ProbInfoBase::add(const ATCFProbLine &l, double dland, bool check_dup) { } // Initialize the header information, if necessary - if(Type == NoATCFLineType) initialize(l, dland); + if(Type == ATCFLineType::None) initialize(l, dland); // Check for matching header information if(!is_match(l)) return false; @@ -292,8 +292,8 @@ void ProbInfoBase::set(const TCStatLine &l) { // Store column information switch(l.type()) { - case TCStatLineType_ProbRIRW: - Type = ATCFLineType_ProbRI; + case TCStatLineType::ProbRIRW: + Type = ATCFLineType::ProbRI; break; default: diff --git a/src/libcode/vx_tc_util/prob_rirw_info.cc b/src/libcode/vx_tc_util/prob_rirw_info.cc index 8c31b24f87..ea662ef4c3 100644 --- a/src/libcode/vx_tc_util/prob_rirw_info.cc +++ b/src/libcode/vx_tc_util/prob_rirw_info.cc @@ -191,7 +191,7 @@ bool ProbRIRWInfo::add(const ATCFProbLine &l, double dland, bool check_dup) { } // Initialize the header information, if necessary - if(Type == NoATCFLineType) initialize(l, dland); + if(Type == ATCFLineType::None) initialize(l, dland); // Check for matching header information if(!is_match(l)) return false; diff --git a/src/libcode/vx_tc_util/prob_rirw_pair_info.cc b/src/libcode/vx_tc_util/prob_rirw_pair_info.cc index fe2f5f07a4..94aeaa01fd 100644 --- a/src/libcode/vx_tc_util/prob_rirw_pair_info.cc +++ b/src/libcode/vx_tc_util/prob_rirw_pair_info.cc @@ -15,6 +15,7 @@ #include #include +#include "enum_as_int.hpp" #include "prob_rirw_pair_info.h" using namespace std; @@ -80,7 +81,7 @@ void ProbRIRWPairInfo::clear() { XErr = YErr = bad_data_double; BBegV = BEndV = bad_data_double; BMinV = BMaxV = bad_data_double; - BBegLev = BEndLev = NoCycloneLevel; + BBegLev = BEndLev = CycloneLevel::None; Line.clear(); return; @@ -102,9 +103,9 @@ void ProbRIRWPairInfo::dump(ostream &out, int indent_depth) const { << prefix << "XErr = " << XErr << "\n" << prefix << "YErr = " << YErr << "\n" << prefix << "BBegV = " << BBegV << "\n" - << prefix << "BBegLev = " << BBegLev << "\n" + << prefix << "BBegLev = " << enum_class_as_int(BBegLev) << "\n" << prefix << "BEndV = " << BEndV << "\n" - << prefix << "BEndLev = " << BEndLev << "\n" + << prefix << "BEndLev = " << enum_class_as_int(BEndLev) << "\n" << prefix << "BMinV = " << BMinV << "\n" << prefix << "BMaxV = " << BMaxV << "\n" << prefix << "ProbRIRW: " << "\n"; @@ -268,7 +269,7 @@ void ProbRIRWPairInfo::set(const TCStatLine &l) { clear(); // Check the line type - if(l.type() != TCStatLineType_ProbRIRW) return; + if(l.type() != TCStatLineType::ProbRIRW) return; // Parse ProbRIRWInfo ProbRIRW.set(l); diff --git a/src/libcode/vx_tc_util/tc_stat_line.cc b/src/libcode/vx_tc_util/tc_stat_line.cc index b8aa0c8b5d..a8556a7dd2 100644 --- a/src/libcode/vx_tc_util/tc_stat_line.cc +++ b/src/libcode/vx_tc_util/tc_stat_line.cc @@ -99,7 +99,7 @@ void TCStatLine::clear() { DataLine::clear(); - Type = NoTCStatLineType; + Type = TCStatLineType::None; HdrLine = (AsciiHeaderLine *) nullptr; return; @@ -126,7 +126,7 @@ int TCStatLine::read_line(LineDataFile * ldf) { // Check for a header line // if(strcmp(get_item(0), "VERSION") == 0) { - Type = TCStatLineType_Header; + Type = TCStatLineType::Header; return 1; } @@ -136,7 +136,7 @@ int TCStatLine::read_line(LineDataFile * ldf) { offset = METHdrTable.col_offset(get_item(0), "TCST", na_str, "LINE_TYPE"); if(is_bad_data(offset) || n_items() < (offset + 1)) { - Type = NoTCStatLineType; + Type = TCStatLineType::None; return 0; } @@ -159,7 +159,7 @@ bool TCStatLine::is_ok() const { //////////////////////////////////////////////////////////////////////// bool TCStatLine::is_header() const { - return(Type == TCStatLineType_Header); + return(Type == TCStatLineType::Header); } //////////////////////////////////////////////////////////////////////// @@ -370,11 +370,11 @@ ConcatString TCStatLine::header() const { TCStatLineType string_to_tcstatlinetype(const char *s) { TCStatLineType t; - if(strcmp(s, TCStatLineType_TCMPR_Str) == 0) t = TCStatLineType_TCMPR; - else if(strcmp(s, TCStatLineType_TCDIAG_Str) == 0) t = TCStatLineType_TCDIAG; - else if(strcmp(s, TCStatLineType_ProbRIRW_Str) == 0) t = TCStatLineType_ProbRIRW; - else if(strcmp(s, TCStatLineType_Header_Str) == 0) t = TCStatLineType_Header; - else t = NoTCStatLineType; + if(strcmp(s, TCStatLineType_TCMPR_Str) == 0) t = TCStatLineType::TCMPR; + else if(strcmp(s, TCStatLineType_TCDIAG_Str) == 0) t = TCStatLineType::TCDIAG; + else if(strcmp(s, TCStatLineType_ProbRIRW_Str) == 0) t = TCStatLineType::ProbRIRW; + else if(strcmp(s, TCStatLineType_Header_Str) == 0) t = TCStatLineType::Header; + else t = TCStatLineType::None; return t; } @@ -385,11 +385,11 @@ ConcatString tcstatlinetype_to_string(const TCStatLineType t) { const char *s = (const char *) nullptr; switch(t) { - case TCStatLineType_TCMPR: s = TCStatLineType_TCMPR_Str; break; - case TCStatLineType_TCDIAG: s = TCStatLineType_TCDIAG_Str; break; - case TCStatLineType_ProbRIRW: s = TCStatLineType_ProbRIRW_Str; break; - case TCStatLineType_Header: s = TCStatLineType_Header_Str; break; - default: s = na_str; break; + case TCStatLineType::TCMPR: s = TCStatLineType_TCMPR_Str; break; + case TCStatLineType::TCDIAG: s = TCStatLineType_TCDIAG_Str; break; + case TCStatLineType::ProbRIRW: s = TCStatLineType_ProbRIRW_Str; break; + case TCStatLineType::Header: s = TCStatLineType_Header_Str; break; + default: s = na_str; break; } return ConcatString(s); diff --git a/src/libcode/vx_tc_util/tc_stat_line.h b/src/libcode/vx_tc_util/tc_stat_line.h index 6c3ead9365..276fad1638 100644 --- a/src/libcode/vx_tc_util/tc_stat_line.h +++ b/src/libcode/vx_tc_util/tc_stat_line.h @@ -22,13 +22,13 @@ //////////////////////////////////////////////////////////////////////// // Enumerate all the possible line types -enum TCStatLineType { +enum class TCStatLineType { - TCStatLineType_TCMPR, - TCStatLineType_TCDIAG, - TCStatLineType_ProbRIRW, - TCStatLineType_Header, - NoTCStatLineType + TCMPR, + TCDIAG, + ProbRIRW, + Header, + None }; @@ -103,7 +103,7 @@ class TCStatLine : public DataLine { //////////////////////////////////////////////////////////////////////// -inline TCStatLineType TCStatLine::type() const { return(Type); } +inline TCStatLineType TCStatLine::type() const { return Type; } //////////////////////////////////////////////////////////////////////// diff --git a/src/libcode/vx_tc_util/track_info.cc b/src/libcode/vx_tc_util/track_info.cc index a6c411c572..c287d47f9a 100644 --- a/src/libcode/vx_tc_util/track_info.cc +++ b/src/libcode/vx_tc_util/track_info.cc @@ -91,7 +91,7 @@ void TrackInfo::clear() { MaxValidTime = (unixtime) 0; MinWarmCore = (unixtime) 0; MaxWarmCore = (unixtime) 0; - DiagSource = DiagType_None; + DiagSource = DiagType::None; TrackSource.clear(); FieldSource.clear(); DiagName.clear(); diff --git a/src/libcode/vx_tc_util/track_pair_info.cc b/src/libcode/vx_tc_util/track_pair_info.cc index 37e92621e5..2fd84368a7 100644 --- a/src/libcode/vx_tc_util/track_pair_info.cc +++ b/src/libcode/vx_tc_util/track_pair_info.cc @@ -311,8 +311,8 @@ void TrackPairInfo::add(const TrackPoint &a, const TrackPoint &b, void TrackPairInfo::add(const TCStatLine &l) { // Check the line type - if(l.type() == TCStatLineType_TCMPR) add_tcmpr_line(l); - else if(l.type() == TCStatLineType_TCDIAG) add_tcdiag_line(l); + if(l.type() == TCStatLineType::TCMPR) add_tcmpr_line(l); + else if(l.type() == TCStatLineType::TCDIAG) add_tcdiag_line(l); return; } @@ -327,7 +327,7 @@ void TrackPairInfo::add_tcmpr_line(const TCStatLine &l) { int i, j; // Check the line type - if(l.type() != TCStatLineType_TCMPR) return; + if(l.type() != TCStatLineType::TCMPR) return; // Store the input TCMPR line and TCDIAG placeholder TCMPRLine.push_back(l); @@ -439,7 +439,7 @@ void TrackPairInfo::add_tcdiag_line(const TCStatLine &l) { ConcatString cs; // Check the line type - if(l.type() != TCStatLineType_TCDIAG) return; + if(l.type() != TCStatLineType::TCDIAG) return; // Should have already parsed TCMPR if(NPoints == 0) { @@ -473,7 +473,7 @@ void TrackPairInfo::add_tcdiag_line(const TCStatLine &l) { // Make sure DIAG_SOURCE does not change DiagType diag_source = string_to_diagtype(l.get_item("DIAG_SOURCE")); - if(ADeck.diag_source() != DiagType_None && + if(ADeck.diag_source() != DiagType::None && ADeck.diag_source() != diag_source) { mlog << Error << "\nTrackPairInfo::add_tcdiag_line() -> " << "the diagnostic source type has changed (" @@ -567,7 +567,7 @@ int TrackPairInfo::i_init() const { //////////////////////////////////////////////////////////////////////// WatchWarnType TrackPairInfo::watch_warn(int i) const { - WatchWarnType ww_type = NoWatchWarnType; + WatchWarnType ww_type = WatchWarnType::None; // Only check points common to both the ADECK and BDECK tracks if(!is_bad_data(ADeck[i].lat()) && !is_bad_data(ADeck[i].lon()) && @@ -642,7 +642,7 @@ int TrackPairInfo::check_rirw(const TrackType track_type, int acur, aprv, bcur, bprv; // Nothing to do. - if(track_type == TrackType_None) return 0; + if(track_type == TrackType::None) return 0; // Check threshold type for non-exact intensity differences. if(!exact_adeck && @@ -751,7 +751,7 @@ int TrackPairInfo::check_rirw(const TrackType track_type, // Print debug message when rapid intensification is found if(is_eq(ADeckRIRW[i], 1.0) && - (track_type == TrackType_ADeck || track_type == TrackType_Both)) { + (track_type == TrackType::ADeck || track_type == TrackType::Both)) { mlog << Debug(4) << "Found ADECK RI/RW: " << case_info() << ", VALID = " << unix_to_yyyymmdd_hhmmss(ADeck[i].valid()) << ", " @@ -762,7 +762,7 @@ int TrackPairInfo::check_rirw(const TrackType track_type, << acur - aprv << st_adeck.get_str() << "\n"; } if(is_eq(BDeckRIRW[i], 1.0) && - (track_type == TrackType_BDeck || track_type == TrackType_Both)) { + (track_type == TrackType::BDeck || track_type == TrackType::Both)) { mlog << Debug(4) << "Found BDECK RI/RW: " << case_info() << ", VALID = " << unix_to_yyyymmdd_hhmmss(BDeck[i].valid()) << ", " @@ -777,9 +777,9 @@ int TrackPairInfo::check_rirw(const TrackType track_type, if(!Keep[i]) continue; // Update the keep status - if((track_type == TrackType_ADeck && !is_eq(ADeckRIRW[i], 1.0)) || - (track_type == TrackType_BDeck && !is_eq(BDeckRIRW[i], 1.0)) || - (track_type == TrackType_Both && !is_eq(ADeckRIRW[i], 1.0) && !is_eq(BDeckRIRW[i], 1.0))) { + if((track_type == TrackType::ADeck && !is_eq(ADeckRIRW[i], 1.0)) || + (track_type == TrackType::BDeck && !is_eq(BDeckRIRW[i], 1.0)) || + (track_type == TrackType::Both && !is_eq(ADeckRIRW[i], 1.0) && !is_eq(BDeckRIRW[i], 1.0))) { Keep.set(i, 0); n_rej++; } diff --git a/src/libcode/vx_tc_util/track_point.cc b/src/libcode/vx_tc_util/track_point.cc index 09ec2d68a5..6a32d4ac9d 100644 --- a/src/libcode/vx_tc_util/track_point.cc +++ b/src/libcode/vx_tc_util/track_point.cc @@ -230,32 +230,32 @@ void QuadInfo::set_quad_vals(QuadrantType ref_quad, switch(ref_quad) { // Full circle radius is stored in the first radius - case(FullCircle): + case QuadrantType::FullCircle: ALVal = rad1; break; - case(NE_Quadrant): + case QuadrantType::NE: NEVal = rad1; SEVal = rad2; SWVal = rad3; NWVal = rad4; break; - case(SE_Quadrant): + case QuadrantType::SE: NEVal = rad4; SEVal = rad1; SWVal = rad2; NWVal = rad3; break; - case(SW_Quadrant): + case QuadrantType::SW: NEVal = rad3; SEVal = rad4; SWVal = rad1; NWVal = rad2; break; - case(NW_Quadrant): + case QuadrantType::NW: NEVal = rad2; SEVal = rad3; SWVal = rad4; @@ -263,7 +263,7 @@ void QuadInfo::set_quad_vals(QuadrantType ref_quad, break; // Nothing to do - case(NoQuadrantType): + case QuadrantType::None: break; default: @@ -441,7 +441,7 @@ void TrackPoint::clear() { Lon = bad_data_double; Vmax = bad_data_int; MSLP = bad_data_int; - Level = NoCycloneLevel; + Level = CycloneLevel::None; RadP = bad_data_double; RRP = bad_data_double; MRD = bad_data_double; @@ -449,9 +449,9 @@ void TrackPoint::clear() { Eye = bad_data_double; Direction = bad_data_double; Speed = bad_data_double; - Depth = NoSystemsDepth; + Depth = SystemsDepth::None; WarmCore = false; - WatchWarn = NoWatchWarnType; + WatchWarn = WatchWarnType::None; NumMembers = bad_data_int; TrackSpread = bad_data_double; diff --git a/src/libcode/vx_time_series/time_series_util.cc b/src/libcode/vx_time_series/time_series_util.cc index 145de93009..d3e40c1201 100644 --- a/src/libcode/vx_time_series/time_series_util.cc +++ b/src/libcode/vx_time_series/time_series_util.cc @@ -27,9 +27,9 @@ using namespace std; TimeSeriesType string_to_timeseriestype(const char *s) { TimeSeriesType t; - if(strcasecmp(s, timeseriestype_dydt_str) == 0) t = TimeSeriesType_DyDt; - else if(strcasecmp(s, timeseriestype_swing_str) == 0) t = TimeSeriesType_Swing; - else t = TimeSeriesType_None; + if(strcasecmp(s, timeseriestype_dydt_str) == 0) t = TimeSeriesType::DyDt; + else if(strcasecmp(s, timeseriestype_swing_str) == 0) t = TimeSeriesType::Swing; + else t = TimeSeriesType::None; return t; } @@ -40,9 +40,9 @@ const char * timeseriestype_to_string(const TimeSeriesType t) { const char *s = (const char *) nullptr; switch(t) { - case(TimeSeriesType_DyDt): s = timeseriestype_dydt_str; break; - case(TimeSeriesType_Swing): s = timeseriestype_swing_str; break; - default: s = na_str; break; + case(TimeSeriesType::DyDt): s = timeseriestype_dydt_str; break; + case(TimeSeriesType::Swing): s = timeseriestype_swing_str; break; + default: s = na_str; break; } return s; diff --git a/src/libcode/vx_time_series/time_series_util.h b/src/libcode/vx_time_series/time_series_util.h index a03176afcc..92adbe0ae2 100644 --- a/src/libcode/vx_time_series/time_series_util.h +++ b/src/libcode/vx_time_series/time_series_util.h @@ -21,10 +21,10 @@ // Enumeration for time-series analysis types // -enum TimeSeriesType { - TimeSeriesType_None, // Default - TimeSeriesType_DyDt, // Threshold change over time window - TimeSeriesType_Swing // Apply swinging door algorithm +enum class TimeSeriesType { + None, // Default + DyDt, // Threshold change over time window + Swing // Apply swinging door algorithm }; static const char timeseriestype_dydt_str[] = "DYDT"; diff --git a/src/tools/core/ensemble_stat/ensemble_stat.cc b/src/tools/core/ensemble_stat/ensemble_stat.cc index 73204c02f9..f00ca74bfd 100644 --- a/src/tools/core/ensemble_stat/ensemble_stat.cc +++ b/src/tools/core/ensemble_stat/ensemble_stat.cc @@ -517,7 +517,7 @@ void process_grid(const Grid &fcst_grid) { ri = conf_info.vx_opt[0].vx_pd.fcst_info->get_var_info()->regrid(); // Read gridded observation data, if necessary - if(ri.field == FieldType_Obs) { + if(ri.field == FieldType::Obs) { if(!grid_obs_flag) { mlog << Error << "\nprocess_grid() -> " @@ -1285,7 +1285,7 @@ void process_grid_vx() { if(conf_info.vx_opt[i].obs_error.flag) { // Use config file setting, if specified - if(conf_info.vx_opt[i].obs_error.entry.dist_type != DistType_None) { + if(conf_info.vx_opt[i].obs_error.entry.dist_type != DistType::None) { mlog << Debug(3) << "Observation error for gridded verification is " << "defined in the configuration file.\n"; @@ -1476,11 +1476,11 @@ void process_grid_vx() { FieldType field = conf_info.vx_opt[i].interp_info.field; // Check for allowable smoothing operation - if(mthd == InterpMthd_DW_Mean || - mthd == InterpMthd_LS_Fit || - mthd == InterpMthd_Bilin || - mthd == InterpMthd_Nbrhd || - mthd == InterpMthd_HiRA) { + if(mthd == InterpMthd::DW_Mean || + mthd == InterpMthd::LS_Fit || + mthd == InterpMthd::Bilin || + mthd == InterpMthd::Nbrhd || + mthd == InterpMthd::HiRA) { mlog << Warning << "\nprocess_grid_vx() -> " << mthd_str << " option not supported for " @@ -1493,13 +1493,13 @@ void process_grid_vx() { shc.set_interp_wdth(wdth); // Smooth the ensemble mean field, if requested - if(field == FieldType_Fcst || field == FieldType_Both) { + if(field == FieldType::Fcst || field == FieldType::Both) { emn_dp = smooth_field(emn_dp, mthd, wdth, shape, grid.wrap_lon(), vld_thresh, gaussian); } // Smooth the observation field, if requested - if(field == FieldType_Obs || field == FieldType_Both) { + if(field == FieldType::Obs || field == FieldType::Both) { obs_dp = smooth_field(obs_dp, mthd, wdth, shape, grid.wrap_lon(), vld_thresh, gaussian); } @@ -1513,7 +1513,7 @@ void process_grid_vx() { << "Applying observation error bias correction to " << "gridded observation data.\n"; obs_dp = add_obs_error_bc(conf_info.rng_ptr, - FieldType_Obs, oerr_ptr, oraw_dp, oraw_dp, + FieldType::Obs, oerr_ptr, oraw_dp, oraw_dp, conf_info.vx_opt[i].vx_pd.obs_info->name().c_str(), conf_info.obtype.c_str()); } @@ -1522,7 +1522,7 @@ void process_grid_vx() { for(k=0; k < conf_info.vx_opt[i].vx_pd.fcst_info->inputs_n(); k++) { // Smooth the forecast field, if requested - if(field == FieldType_Fcst || field == FieldType_Both) { + if(field == FieldType::Fcst || field == FieldType::Both) { fcst_dp[k] = smooth_field(fcst_dp[k], mthd, wdth, shape, grid.wrap_lon(), vld_thresh, gaussian); } @@ -1538,7 +1538,7 @@ void process_grid_vx() { << "Applying observation error perturbation to " << "ensemble member " << k+1 << ".\n"; fcst_dp[k] = add_obs_error_inc(conf_info.rng_ptr, - FieldType_Fcst, oerr_ptr, fraw_dp[k], oraw_dp, + FieldType::Fcst, oerr_ptr, fraw_dp[k], oraw_dp, conf_info.vx_opt[i].vx_pd.obs_info->name().c_str(), conf_info.obtype.c_str()); } @@ -1719,7 +1719,7 @@ void do_ecnt(const EnsembleStatVxOpt &vx_opt, ecnt_info.set(*pd_ptr); // Write out ECNT - if(vx_opt.output_flag[i_ecnt] != STATOutputType_None && + if(vx_opt.output_flag[i_ecnt] != STATOutputType::None && ecnt_info.n_pair > 0) { write_ecnt_row(shc, ecnt_info, vx_opt.output_flag[i_ecnt], stat_at, i_stat_row, @@ -1756,7 +1756,7 @@ void do_rps(const EnsembleStatVxOpt &vx_opt, rps_info.set(*pd_ptr); // Write out RPS - if(vx_opt.output_flag[i_rps] != STATOutputType_None && + if(vx_opt.output_flag[i_rps] != STATOutputType::None && rps_info.n_pair > 0) { write_rps_row(shc, rps_info, vx_opt.output_flag[i_rps], stat_at, i_stat_row, @@ -1878,7 +1878,7 @@ void setup_txt_files() { for(i=0; i 1 && (type_cs != "OBS" || - conf_info.vx_opt[i_vx].interp_info.field == FieldType_Obs || - conf_info.vx_opt[i_vx].interp_info.field == FieldType_Both)) { + conf_info.vx_opt[i_vx].interp_info.field == FieldType::Obs || + conf_info.vx_opt[i_vx].interp_info.field == FieldType::Both)) { var_name << "_" << mthd_str << "_" << wdth*wdth; name_str << "_" << mthd_str << "_" << wdth*wdth; } @@ -2739,7 +2739,7 @@ void finish_txt_files() { for(i=0; ifield == FieldType_Fcst || - interp->field == FieldType_Both) { + if(interp->field == FieldType::Fcst || + interp->field == FieldType::Both) { smooth_field(fcst_dp, fcst_dp_smooth, interp_mthd, interp->width[j], interp->shape, grid.wrap_lon(), interp->vld_thresh, interp->gaussian); @@ -862,8 +862,8 @@ void process_scores() { } // If requested in the config file, smooth the observation field - if(interp->field == FieldType_Obs || - interp->field == FieldType_Both) { + if(interp->field == FieldType::Obs || + interp->field == FieldType::Both) { smooth_field(obs_dp, obs_dp_smooth, interp_mthd, interp->width[j], interp->shape, grid.wrap_lon(), interp->vld_thresh, interp->gaussian); @@ -917,10 +917,10 @@ void process_scores() { // Compute CTS scores if(!conf_info.vx_opt[i].fcst_info->is_prob() && conf_info.vx_opt[i].fcat_ta.n() > 0 && - (conf_info.vx_opt[i].output_flag[i_fho] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_ctc] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_cts] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_eclv] != STATOutputType_None)) { + (conf_info.vx_opt[i].output_flag[i_fho] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_ctc] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_cts] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_eclv] != STATOutputType::None)) { // Initialize for(m=0; m 0) { write_fho_row(shc, cts_info[m], @@ -942,7 +942,7 @@ void process_scores() { } // Write out CTC - if(conf_info.vx_opt[i].output_flag[i_ctc] != STATOutputType_None && + if(conf_info.vx_opt[i].output_flag[i_ctc] != STATOutputType::None && cts_info[m].cts.n() > 0) { write_ctc_row(shc, cts_info[m], @@ -952,7 +952,7 @@ void process_scores() { } // Write out CTS - if(conf_info.vx_opt[i].output_flag[i_cts] != STATOutputType_None && + if(conf_info.vx_opt[i].output_flag[i_cts] != STATOutputType::None && cts_info[m].cts.n() > 0) { write_cts_row(shc, cts_info[m], @@ -962,7 +962,7 @@ void process_scores() { } // Write out ECLV - if(conf_info.vx_opt[i].output_flag[i_eclv] != STATOutputType_None && + if(conf_info.vx_opt[i].output_flag[i_eclv] != STATOutputType::None && cts_info[m].cts.n() > 0) { write_eclv_row(shc, cts_info[m], conf_info.vx_opt[i].eclv_points, @@ -976,8 +976,8 @@ void process_scores() { // Compute MCTS scores if(!conf_info.vx_opt[i].fcst_info->is_prob() && conf_info.vx_opt[i].fcat_ta.n() > 1 && - (conf_info.vx_opt[i].output_flag[i_mctc] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_mcts] != STATOutputType_None)) { + (conf_info.vx_opt[i].output_flag[i_mctc] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_mcts] != STATOutputType::None)) { // Initialize mcts_info.clear(); @@ -986,7 +986,7 @@ void process_scores() { do_mcts(mcts_info, i, &pd); // Write out MCTC - if(conf_info.vx_opt[i].output_flag[i_mctc] != STATOutputType_None && + if(conf_info.vx_opt[i].output_flag[i_mctc] != STATOutputType::None && mcts_info.cts.total() > 0) { write_mctc_row(shc, mcts_info, @@ -996,7 +996,7 @@ void process_scores() { } // Write out MCTS - if(conf_info.vx_opt[i].output_flag[i_mcts] != STATOutputType_None && + if(conf_info.vx_opt[i].output_flag[i_mcts] != STATOutputType::None && mcts_info.cts.total() > 0) { write_mcts_row(shc, mcts_info, @@ -1008,9 +1008,9 @@ void process_scores() { // Compute CNT, SL1L2, and SAL1L2 scores if(!conf_info.vx_opt[i].fcst_info->is_prob() && - (conf_info.vx_opt[i].output_flag[i_cnt] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_sl1l2] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_sal1l2] != STATOutputType_None)) { + (conf_info.vx_opt[i].output_flag[i_cnt] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_sl1l2] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_sal1l2] != STATOutputType::None)) { do_cnt_sl1l2(conf_info.vx_opt[i], &pd); } @@ -1018,9 +1018,9 @@ void process_scores() { if(!conf_info.vx_opt[i].fcst_info->is_prob() && conf_info.vx_opt[i].fcst_info->is_v_wind() && conf_info.vx_opt[i].fcst_info->uv_index() >= 0 && - (conf_info.vx_opt[i].output_flag[i_vl1l2] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_val1l2] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_vcnt] != STATOutputType_None)) { + (conf_info.vx_opt[i].output_flag[i_vl1l2] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_val1l2] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_vcnt] != STATOutputType::None)) { // Store the forecast variable name shc.set_fcst_var(ugrd_vgrd_abbr_str); @@ -1052,8 +1052,8 @@ void process_scores() { // If requested in the config file, smooth the forecast // and climatology U-wind fields - if(interp->field == FieldType_Fcst || - interp->field == FieldType_Both) { + if(interp->field == FieldType::Fcst || + interp->field == FieldType::Both) { smooth_field(fu_dp, fu_dp_smooth, interp_mthd, interp->width[j], interp->shape, grid.wrap_lon(), interp->vld_thresh, interp->gaussian); @@ -1065,8 +1065,8 @@ void process_scores() { // If requested in the config file, smooth the observation // U-wind field - if(interp->field == FieldType_Obs || - interp->field == FieldType_Both) { + if(interp->field == FieldType::Obs || + interp->field == FieldType::Both) { smooth_field(ou_dp, ou_dp_smooth, interp_mthd, interp->width[j], interp->shape, grid.wrap_lon(), @@ -1089,7 +1089,7 @@ void process_scores() { for(m=0; m 0) { write_vl1l2_row(shc, vl1l2_info[m], conf_info.vx_opt[i].output_flag[i_vl1l2], @@ -1098,7 +1098,7 @@ void process_scores() { } // Write out VAL1L2 - if(conf_info.vx_opt[i].output_flag[i_val1l2] != STATOutputType_None && + if(conf_info.vx_opt[i].output_flag[i_val1l2] != STATOutputType::None && vl1l2_info[m].vacount > 0) { write_val1l2_row(shc, vl1l2_info[m], conf_info.vx_opt[i].output_flag[i_val1l2], @@ -1107,7 +1107,7 @@ void process_scores() { } // Write out VCNT - if(conf_info.vx_opt[i].output_flag[i_vcnt] != STATOutputType_None && + if(conf_info.vx_opt[i].output_flag[i_vcnt] != STATOutputType::None && vl1l2_info[m].vcount > 0) { write_vcnt_row(shc, vl1l2_info[m], conf_info.vx_opt[i].output_flag[i_vcnt], @@ -1127,11 +1127,11 @@ void process_scores() { // Compute PCT counts and scores if(conf_info.vx_opt[i].fcst_info->is_prob() && - (conf_info.vx_opt[i].output_flag[i_pct] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_pstd] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_pjc] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_prc] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_eclv] != STATOutputType_None)) { + (conf_info.vx_opt[i].output_flag[i_pct] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_pstd] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_pjc] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_prc] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_eclv] != STATOutputType::None)) { do_pct(conf_info.vx_opt[i], &pd); } @@ -1196,7 +1196,7 @@ void process_scores() { } // Write out the fields of requested SEEPS - if(conf_info.vx_opt[i].output_flag[i_seeps] != STATOutputType_None + if(conf_info.vx_opt[i].output_flag[i_seeps] != STATOutputType::None && conf_info.vx_opt[i].fcst_info->is_precipitation() && conf_info.vx_opt[i].obs_info->is_precipitation()) { SeepsAggScore seeps; @@ -1220,7 +1220,7 @@ void process_scores() { // Compute gradient statistics if requested in the config file if(!conf_info.vx_opt[i].fcst_info->is_prob() && - conf_info.vx_opt[i].output_flag[i_grad] != STATOutputType_None) { + conf_info.vx_opt[i].output_flag[i_grad] != STATOutputType::None) { // Allocate memory in one big chunk based on grid size DataPlane fgx_dp, fgy_dp, ogx_dp, ogy_dp; @@ -1275,7 +1275,7 @@ void process_scores() { pd_gx.o_na, pd_gy.o_na, pd_gx.wgt_na); // Write out GRAD - if(conf_info.vx_opt[i].output_flag[i_grad] != STATOutputType_None && + if(conf_info.vx_opt[i].output_flag[i_grad] != STATOutputType::None && grad_info.total > 0) { write_grad_row(shc, grad_info, @@ -1308,7 +1308,7 @@ void process_scores() { // Compute distance map statistics if requested in the config file if(!conf_info.vx_opt[i].fcst_info->is_prob() && - conf_info.vx_opt[i].output_flag[i_dmap] != STATOutputType_None) { + conf_info.vx_opt[i].output_flag[i_dmap] != STATOutputType::None) { // Allocate memory in one big chunk based on grid size DataPlane fcst_dp_dmap, obs_dp_dmap; @@ -1419,7 +1419,7 @@ void process_scores() { pd.f_na, pd.o_na, pd_thr.f_na, pd_thr.o_na); // Write out DMAP - if(conf_info.vx_opt[i].output_flag[i_dmap] != STATOutputType_None && + if(conf_info.vx_opt[i].output_flag[i_dmap] != STATOutputType::None && dmap_info.total > 0) { write_dmap_row(shc, dmap_info, @@ -1438,9 +1438,9 @@ void process_scores() { // Loop through and apply the Neighborhood methods for each of the // neighborhood widths if requested in the config file if(!conf_info.vx_opt[i].fcst_info->is_prob() && - (conf_info.vx_opt[i].output_flag[i_nbrctc] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_nbrcts] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_nbrcnt] != STATOutputType_None)) { + (conf_info.vx_opt[i].output_flag[i_nbrctc] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_nbrcts] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_nbrcnt] != STATOutputType::None)) { // Pointer to current interpolation object NbrhdInfo * nbrhd = &conf_info.vx_opt[i].nbrhd_info; @@ -1451,7 +1451,7 @@ void process_scores() { // Loop through and apply each of the neighborhood widths for(j=0; jwidth.n(); j++) { - shc.set_interp_mthd(InterpMthd_Nbrhd, nbrhd->shape); + shc.set_interp_mthd(InterpMthd::Nbrhd, nbrhd->shape); shc.set_interp_wdth(nbrhd->width[j]); // Loop through and apply each of the raw threshold values @@ -1486,8 +1486,8 @@ void process_scores() { } // Process the forecast data - if(nbrhd->field == FieldType_Fcst || - nbrhd->field == FieldType_Both) { + if(nbrhd->field == FieldType::Fcst || + nbrhd->field == FieldType::Both) { // Compute fractional coverage field, if necessary. if(fcst_dp_smooth.is_empty() || @@ -1526,8 +1526,8 @@ void process_scores() { } // Process the observation data - if(nbrhd->field == FieldType_Obs || - nbrhd->field == FieldType_Both) { + if(nbrhd->field == FieldType::Obs || + nbrhd->field == FieldType::Both) { // Compute fractional coverage field, if necessary. if(obs_dp_smooth.is_empty() || @@ -1569,13 +1569,13 @@ void process_scores() { mask_bad_data(mask_mp, fcst_dp_smooth); mask_bad_data(mask_mp, obs_dp_smooth); - if(nbrhd->field == FieldType_Fcst || - nbrhd->field == FieldType_Both) { + if(nbrhd->field == FieldType::Fcst || + nbrhd->field == FieldType::Both) { mask_bad_data(mask_mp, fcst_dp_thresh); } - if(nbrhd->field == FieldType_Obs || - nbrhd->field == FieldType_Both) { + if(nbrhd->field == FieldType::Obs || + nbrhd->field == FieldType::Both) { mask_bad_data(mask_mp, obs_dp_thresh); } @@ -1611,8 +1611,8 @@ void process_scores() { if(pd.f_na.n() == 0) continue; // Compute NBRCTS scores - if(conf_info.vx_opt[i].output_flag[i_nbrctc] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_nbrcts] != STATOutputType_None) { + if(conf_info.vx_opt[i].output_flag[i_nbrctc] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_nbrcts] != STATOutputType::None) { // Initialize for(n=0; n 0) { // Write out NBRCTC - if(conf_info.vx_opt[i].output_flag[i_nbrctc] != STATOutputType_None) { + if(conf_info.vx_opt[i].output_flag[i_nbrctc] != STATOutputType::None) { write_nbrctc_row(shc, nbrcts_info[n], conf_info.vx_opt[i].output_flag[i_nbrctc], @@ -1637,7 +1637,7 @@ void process_scores() { } // Write out NBRCTS - if(conf_info.vx_opt[i].output_flag[i_nbrcts] != STATOutputType_None) { + if(conf_info.vx_opt[i].output_flag[i_nbrcts] != STATOutputType::None) { write_nbrcts_row(shc, nbrcts_info[n], conf_info.vx_opt[i].output_flag[i_nbrcts], @@ -1649,7 +1649,7 @@ void process_scores() { } // end compute NBRCTS // Compute NBRCNT scores - if(conf_info.vx_opt[i].output_flag[i_nbrcnt] != STATOutputType_None) { + if(conf_info.vx_opt[i].output_flag[i_nbrcnt] != STATOutputType::None) { // Initialize nbrcnt_info.clear(); @@ -1658,7 +1658,7 @@ void process_scores() { // Write out NBRCNT if(nbrcnt_info.sl1l2_info.scount > 0 && - conf_info.vx_opt[i].output_flag[i_nbrcnt]) { + (STATOutputType::None!=conf_info.vx_opt[i].output_flag[i_nbrcnt])) { write_nbrcnt_row(shc, nbrcnt_info, conf_info.vx_opt[i].output_flag[i_nbrcnt], @@ -1677,12 +1677,12 @@ void process_scores() { } // end for m // If not computing fractional coverage, all finished with thresholds - if(nbrhd->field == FieldType_None) break; + if(nbrhd->field == FieldType::None) break; } // end for k // If not computing fractional coverage, all finished with neighborhood widths - if(nbrhd->field == FieldType_None) break; + if(nbrhd->field == FieldType::None) break; } // end for j } // end if @@ -1734,7 +1734,7 @@ void process_scores() { cs << "-" << conf_info.vx_opt[i].wave_1d_end[j]; } - shc.set_interp_mthd(cs, GridTemplateFactory::GridTemplate_None); + shc.set_interp_mthd(cs, GridTemplateFactory::GridTemplates::None); shc.set_interp_pnts(bad_data_int); // Loop through the masks to be applied @@ -1775,9 +1775,9 @@ void process_scores() { // Compute CNT, SL1L2, and SAL1L2 scores if(!conf_info.vx_opt[i].fcst_info->is_prob() && - (conf_info.vx_opt[i].output_flag[i_cnt] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_sl1l2] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_sal1l2] != STATOutputType_None)) { + (conf_info.vx_opt[i].output_flag[i_cnt] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_sl1l2] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_sal1l2] != STATOutputType::None)) { do_cnt_sl1l2(conf_info.vx_opt[i], &pd); } @@ -1785,9 +1785,9 @@ void process_scores() { if(!conf_info.vx_opt[i].fcst_info->is_prob() && conf_info.vx_opt[i].fcst_info->is_v_wind() && conf_info.vx_opt[i].fcst_info->uv_index() >= 0 && - (conf_info.vx_opt[i].output_flag[i_vl1l2] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_val1l2] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_vcnt] != STATOutputType_None)) { + (conf_info.vx_opt[i].output_flag[i_vl1l2] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_val1l2] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_vcnt] != STATOutputType::None)) { // Store the forecast variable name shc.set_fcst_var(ugrd_vgrd_abbr_str); @@ -1857,7 +1857,7 @@ void process_scores() { for(m=0; m 0) { write_vl1l2_row(shc, vl1l2_info[m], conf_info.vx_opt[i].output_flag[i_vl1l2], @@ -1866,7 +1866,7 @@ void process_scores() { } // Write out VAL1L2 - if(conf_info.vx_opt[i].output_flag[i_val1l2] != STATOutputType_None && + if(conf_info.vx_opt[i].output_flag[i_val1l2] != STATOutputType::None && vl1l2_info[m].vacount > 0) { write_val1l2_row(shc, vl1l2_info[m], conf_info.vx_opt[i].output_flag[i_val1l2], @@ -1875,7 +1875,7 @@ void process_scores() { } // Write out VCNT - if(conf_info.vx_opt[i].output_flag[i_vcnt] != STATOutputType_None && + if(conf_info.vx_opt[i].output_flag[i_vcnt] != STATOutputType::None && vl1l2_info[m].vcount > 0) { write_vcnt_row(shc, vl1l2_info[m], conf_info.vx_opt[i].output_flag[i_vcnt], @@ -1901,18 +1901,18 @@ void process_scores() { // Write out the data fields if requested in the config file if(conf_info.vx_opt[i].nc_info.do_raw) { write_nc((string)"FCST", fcst_dp_smooth, i, shc.get_interp_mthd(), - bad_data_int, FieldType_Both); + bad_data_int, FieldType::Both); write_nc((string)"OBS", obs_dp_smooth, i, shc.get_interp_mthd(), - bad_data_int, FieldType_Both); + bad_data_int, FieldType::Both); } if(conf_info.vx_opt[i].nc_info.do_diff) { write_nc((string)"DIFF", subtract(fcst_dp_smooth, obs_dp_smooth), i, shc.get_interp_mthd(), bad_data_int, - FieldType_Both); + FieldType::Both); } if(conf_info.vx_opt[i].nc_info.do_climo && !cmn_dp_smooth.is_empty()) { write_nc((string)"CLIMO_MEAN", cmn_dp_smooth, i, shc.get_interp_mthd(), - bad_data_int, FieldType_Both); + bad_data_int, FieldType::Both); } } // end if @@ -1995,11 +1995,11 @@ void do_cts(CTSInfo *&cts_info, int i_vx, // Compute the counts, stats, normal confidence intervals, and // bootstrap confidence intervals // - if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType_BCA) { + if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType::BCA) { compute_cts_stats_ci_bca(rng_ptr, *pd_ptr, conf_info.vx_opt[i_vx].boot_info.n_rep, cts_info, n_cts, - conf_info.vx_opt[i_vx].output_flag[i_cts] != STATOutputType_None, + conf_info.vx_opt[i_vx].output_flag[i_cts] != STATOutputType::None, conf_info.vx_opt[i_vx].rank_corr_flag, conf_info.tmp_dir.c_str()); } else { @@ -2007,7 +2007,7 @@ void do_cts(CTSInfo *&cts_info, int i_vx, conf_info.vx_opt[i_vx].boot_info.n_rep, conf_info.vx_opt[i_vx].boot_info.rep_prop, cts_info, n_cts, - conf_info.vx_opt[i_vx].output_flag[i_cts] != STATOutputType_None, + conf_info.vx_opt[i_vx].output_flag[i_cts] != STATOutputType::None, conf_info.vx_opt[i_vx].rank_corr_flag, conf_info.tmp_dir.c_str()); } @@ -2044,11 +2044,11 @@ void do_mcts(MCTSInfo &mcts_info, int i_vx, // Compute the counts, stats, normal confidence intervals, and // bootstrap confidence intervals // - if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType_BCA) { + if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType::BCA) { compute_mcts_stats_ci_bca(rng_ptr, *pd_ptr, conf_info.vx_opt[i_vx].boot_info.n_rep, mcts_info, - conf_info.vx_opt[i_vx].output_flag[i_mcts] != STATOutputType_None, + conf_info.vx_opt[i_vx].output_flag[i_mcts] != STATOutputType::None, conf_info.vx_opt[i_vx].rank_corr_flag, conf_info.tmp_dir.c_str()); } else { @@ -2056,7 +2056,7 @@ void do_mcts(MCTSInfo &mcts_info, int i_vx, conf_info.vx_opt[i_vx].boot_info.n_rep, conf_info.vx_opt[i_vx].boot_info.rep_prop, mcts_info, - conf_info.vx_opt[i_vx].output_flag[i_mcts] != STATOutputType_None, + conf_info.vx_opt[i_vx].output_flag[i_mcts] != STATOutputType::None, conf_info.vx_opt[i_vx].rank_corr_flag, conf_info.tmp_dir.c_str()); } @@ -2085,9 +2085,9 @@ void do_cnt_sl1l2(const GridStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { } // Set flags - bool do_sl1l2 = (vx_opt.output_flag[i_sl1l2] != STATOutputType_None || - vx_opt.output_flag[i_sal1l2] != STATOutputType_None); - bool do_cnt = (vx_opt.output_flag[i_cnt] != STATOutputType_None); + bool do_sl1l2 = (vx_opt.output_flag[i_sl1l2] != STATOutputType::None || + vx_opt.output_flag[i_sal1l2] != STATOutputType::None); + bool do_cnt = (vx_opt.output_flag[i_cnt] != STATOutputType::None); bool precip_flag = (vx_opt.fcst_info->is_precipitation() && vx_opt.obs_info->is_precipitation()); @@ -2134,7 +2134,7 @@ void do_cnt_sl1l2(const GridStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Write out SL1L2 if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_sl1l2] != STATOutputType_None && + vx_opt.output_flag[i_sl1l2] != STATOutputType::None && sl1l2_info[j].scount > 0) { write_sl1l2_row(shc, sl1l2_info[j], @@ -2145,7 +2145,7 @@ void do_cnt_sl1l2(const GridStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Write out SAL1L2 if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_sal1l2] != STATOutputType_None && + vx_opt.output_flag[i_sal1l2] != STATOutputType::None && sl1l2_info[j].sacount > 0) { write_sal1l2_row(shc, sl1l2_info[j], @@ -2171,7 +2171,7 @@ void do_cnt_sl1l2(const GridStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Compute the stats, normal confidence intervals, and // bootstrap confidence intervals - if(vx_opt.boot_info.interval == BootIntervalType_BCA) { + if(vx_opt.boot_info.interval == BootIntervalType::BCA) { compute_cnt_stats_ci_bca(rng_ptr, pd, precip_flag, vx_opt.rank_corr_flag, vx_opt.boot_info.n_rep, @@ -2187,7 +2187,7 @@ void do_cnt_sl1l2(const GridStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Write out CNT if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_cnt] != STATOutputType_None && + vx_opt.output_flag[i_cnt] != STATOutputType::None && cnt_info[j].n > 0) { write_cnt_row(shc, cnt_info[j], @@ -2201,14 +2201,14 @@ void do_cnt_sl1l2(const GridStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { if(n_bin > 1) { // Compute SL1L2 climo CDF bin means - if(vx_opt.output_flag[i_sl1l2] != STATOutputType_None || - vx_opt.output_flag[i_sal1l2] != STATOutputType_None) { + if(vx_opt.output_flag[i_sl1l2] != STATOutputType::None || + vx_opt.output_flag[i_sal1l2] != STATOutputType::None) { SL1L2Info sl1l2_mean; compute_sl1l2_mean(sl1l2_info, n_bin, sl1l2_mean); // Write out SL1L2 - if(vx_opt.output_flag[i_sl1l2] != STATOutputType_None && + if(vx_opt.output_flag[i_sl1l2] != STATOutputType::None && sl1l2_mean.scount > 0) { write_sl1l2_row(shc, sl1l2_mean, @@ -2218,7 +2218,7 @@ void do_cnt_sl1l2(const GridStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { } // Write out SAL1L2 - if(vx_opt.output_flag[i_sal1l2] != STATOutputType_None && + if(vx_opt.output_flag[i_sal1l2] != STATOutputType::None && sl1l2_mean.sacount > 0) { write_sal1l2_row(shc, sl1l2_mean, @@ -2229,7 +2229,7 @@ void do_cnt_sl1l2(const GridStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { } // Compute CNT climo CDF bin means - if(vx_opt.output_flag[i_cnt] != STATOutputType_None) { + if(vx_opt.output_flag[i_cnt] != STATOutputType::None) { CNTInfo cnt_mean; compute_cnt_mean(cnt_info, n_bin, cnt_mean); @@ -2346,14 +2346,14 @@ void do_pct(const GridStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { } // Compute the probabilistic counts and statistics - compute_pctinfo(pd, vx_opt.output_flag[i_pstd], pct_info[j]); + compute_pctinfo(pd, ( STATOutputType::None!=vx_opt.output_flag[i_pstd]), pct_info[j]); // Check for no matched pairs to process if(pd.n_obs == 0) continue; // Write out PCT if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_pct] != STATOutputType_None) { + vx_opt.output_flag[i_pct] != STATOutputType::None) { write_pct_row(shc, pct_info[j], vx_opt.output_flag[i_pct], j, n_bin, stat_at, i_stat_row, @@ -2362,7 +2362,7 @@ void do_pct(const GridStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Write out PSTD if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_pstd] != STATOutputType_None) { + vx_opt.output_flag[i_pstd] != STATOutputType::None) { write_pstd_row(shc, pct_info[j], vx_opt.output_flag[i_pstd], j, n_bin, stat_at, i_stat_row, @@ -2371,7 +2371,7 @@ void do_pct(const GridStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Write out PJC if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_pjc] != STATOutputType_None) { + vx_opt.output_flag[i_pjc] != STATOutputType::None) { write_pjc_row(shc, pct_info[j], vx_opt.output_flag[i_pjc], j, n_bin, stat_at, i_stat_row, @@ -2380,7 +2380,7 @@ void do_pct(const GridStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Write out PRC if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_prc] != STATOutputType_None) { + vx_opt.output_flag[i_prc] != STATOutputType::None) { write_prc_row(shc, pct_info[j], vx_opt.output_flag[i_prc], j, n_bin, stat_at, i_stat_row, @@ -2389,7 +2389,7 @@ void do_pct(const GridStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Write out ECLV if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_eclv] != STATOutputType_None) { + vx_opt.output_flag[i_eclv] != STATOutputType::None) { write_eclv_row(shc, pct_info[j], vx_opt.eclv_points, vx_opt.output_flag[i_eclv], j, n_bin, stat_at, i_stat_row, @@ -2404,7 +2404,7 @@ void do_pct(const GridStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { compute_pct_mean(pct_info, n_bin, pct_mean); // Write out PSTD - if(vx_opt.output_flag[i_pstd] != STATOutputType_None) { + if(vx_opt.output_flag[i_pstd] != STATOutputType::None) { write_pstd_row(shc, pct_mean, vx_opt.output_flag[i_pstd], -1, n_bin, stat_at, i_stat_row, @@ -2434,7 +2434,7 @@ void do_nbrcts(NBRCTSInfo *&nbrcts_info, n_nbrcts = conf_info.vx_opt[i_vx].get_n_cov_thresh(); for(i=0; i 1 || - interp_mthd == interpmthd_to_string(InterpMthd_Gaussian)) { + interp_mthd == interpmthd_to_string(InterpMthd::Gaussian)) { interp_str << "_" << interp_mthd << "_" << interp_pnts; } // Append Fourier decomposition info @@ -2633,8 +2633,8 @@ void write_nc(const ConcatString &field_name, const DataPlane &dp, if(field_name == "FCST") { var_name << cs_erase << field_name << "_" << fcst_name << var_suffix << "_" << mask_str; - if(field_type == FieldType_Fcst || - field_type == FieldType_Both) { + if(field_type == FieldType::Fcst || + field_type == FieldType::Both) { var_name << interp_str; } long_att = fcst_long_name; @@ -2644,8 +2644,8 @@ void write_nc(const ConcatString &field_name, const DataPlane &dp, else if(field_name == "OBS") { var_name << cs_erase << field_name << "_" << obs_name << var_suffix << "_" << mask_str; - if(field_type == FieldType_Obs || - field_type == FieldType_Both) { + if(field_type == FieldType::Obs || + field_type == FieldType::Both) { var_name << interp_str; } long_att = obs_long_name; @@ -2712,8 +2712,8 @@ void write_nc(const ConcatString &field_name, const DataPlane &dp, check_reg_exp("FCST_YGRAD_", field_name.c_str())) { var_name << cs_erase << field_name << "_" << fcst_name << var_suffix << "_" << mask_str; - if(field_type == FieldType_Fcst || - field_type == FieldType_Both) { + if(field_type == FieldType::Fcst || + field_type == FieldType::Both) { var_name << interp_str; } long_att << cs_erase @@ -2726,8 +2726,8 @@ void write_nc(const ConcatString &field_name, const DataPlane &dp, check_reg_exp("OBS_YGRAD_", field_name.c_str())) { var_name << cs_erase << field_name << "_" << obs_name << var_suffix << "_" << mask_str; - if(field_type == FieldType_Obs || - field_type == FieldType_Both) { + if(field_type == FieldType::Obs || + field_type == FieldType::Both) { var_name << interp_str; } long_att << cs_erase @@ -2739,8 +2739,8 @@ void write_nc(const ConcatString &field_name, const DataPlane &dp, else if(check_reg_exp("FCST_DMAP_", field_name.c_str())) { var_name << cs_erase << field_name << "_" << fcst_name << var_suffix << "_" << mask_str; - if(field_type == FieldType_Fcst || - field_type == FieldType_Both) { + if(field_type == FieldType::Fcst || + field_type == FieldType::Both) { var_name << interp_str; } long_att << cs_erase @@ -2752,8 +2752,8 @@ void write_nc(const ConcatString &field_name, const DataPlane &dp, else if(check_reg_exp("OBS_DMAP_", field_name.c_str())) { var_name << cs_erase << field_name << "_" << obs_name << var_suffix << "_" << mask_str; - if(field_type == FieldType_Obs || - field_type == FieldType_Both) { + if(field_type == FieldType::Obs || + field_type == FieldType::Both) { var_name << interp_str; } long_att << cs_erase @@ -2766,8 +2766,8 @@ void write_nc(const ConcatString &field_name, const DataPlane &dp, ConcatString seeps_desc; var_name << cs_erase << field_name << "_" << obs_name << var_suffix << "_" << mask_str; - if(field_type == FieldType_Obs || - field_type == FieldType_Both) { + if(field_type == FieldType::Obs || + field_type == FieldType::Both) { var_name << interp_str; } if(strncmp(field_name.c_str(), "SEEPS_MPR_SCORE", 15) == 0) @@ -2889,7 +2889,7 @@ void write_nbrhd_nc(const DataPlane &fcst_dp, const DataPlane &obs_dp, NcVar obs_var; // Get the interpolation strings - mthd_str = interpmthd_to_string(InterpMthd_Nbrhd); + mthd_str = interpmthd_to_string(InterpMthd::Nbrhd); if(wdth > 1) nbrhd_str << "_" << mthd_str << "_" << wdth*wdth; int deflate_level = compress_level; @@ -3049,7 +3049,7 @@ void finish_txt_files() { for(i=0; iis_prob() && - (output_flag[i_mctc] != STATOutputType_None || - output_flag[i_mcts] != STATOutputType_None)) { + (output_flag[i_mctc] != STATOutputType::None || + output_flag[i_mcts] != STATOutputType::None)) { check_mctc_thresh(fcat_ta); check_mctc_thresh(ocat_ta); } @@ -814,9 +814,9 @@ void GridStatVxOpt::process_config( mthd = string_to_interpmthd(interp_info.method[i].c_str()); // Check for unsupported interpolation methods - if(mthd == InterpMthd_DW_Mean || - mthd == InterpMthd_LS_Fit || - mthd == InterpMthd_Bilin) { + if(mthd == InterpMthd::DW_Mean || + mthd == InterpMthd::LS_Fit || + mthd == InterpMthd::Bilin) { mlog << Error << "\nGridStatVxOpt::process_config() -> " << "Interpolation methods DW_MEAN, LS_FIT, and BILIN are " << "not supported in Grid-Stat.\n\n"; @@ -1059,7 +1059,7 @@ int GridStatVxOpt::n_txt_row(int i_txt_row) const { } // Check if this output line type is requested - if(output_flag[i_txt_row] == STATOutputType_None) return 0; + if(output_flag[i_txt_row] == STATOutputType::None) return 0; bool prob_flag = fcst_info->is_prob(); bool vect_flag = (fcst_info->is_u_wind() && obs_info->is_u_wind()); diff --git a/src/tools/core/grid_stat/grid_stat_conf_info.h b/src/tools/core/grid_stat/grid_stat_conf_info.h index 51e480f02a..ca529a27e1 100644 --- a/src/tools/core/grid_stat/grid_stat_conf_info.h +++ b/src/tools/core/grid_stat/grid_stat_conf_info.h @@ -66,34 +66,34 @@ static const int n_txt = 22; // Text file type static const STATLineType txt_file_type[n_txt] = { - stat_fho, // 0 - stat_ctc, // 1 - stat_cts, // 2 - - stat_mctc, // 3 - stat_mcts, // 4 - stat_cnt, // 5 - - stat_sl1l2, // 6 - stat_sal1l2, // 7 - stat_vl1l2, // 8 - - stat_val1l2, // 9 - stat_pct, // 10 - stat_pstd, // 11 - - stat_pjc, // 12 - stat_prc, // 13 - stat_eclv, // 14 - - stat_nbrctc, // 15 - stat_nbrcts, // 16 - stat_nbrcnt, // 17 - - stat_grad, // 18 - stat_vcnt, // 19 - stat_dmap, // 20 - stat_seeps // 21 + STATLineType::fho, // 0 + STATLineType::ctc, // 1 + STATLineType::cts, // 2 + + STATLineType::mctc, // 3 + STATLineType::mcts, // 4 + STATLineType::cnt, // 5 + + STATLineType::sl1l2, // 6 + STATLineType::sal1l2, // 7 + STATLineType::vl1l2, // 8 + + STATLineType::val1l2, // 9 + STATLineType::pct, // 10 + STATLineType::pstd, // 11 + + STATLineType::pjc, // 12 + STATLineType::prc, // 13 + STATLineType::eclv, // 14 + + STATLineType::nbrctc, // 15 + STATLineType::nbrcts, // 16 + STATLineType::nbrcnt, // 17 + + STATLineType::grad, // 18 + STATLineType::vcnt, // 19 + STATLineType::dmap, // 20 + STATLineType::seeps // 21 }; diff --git a/src/tools/core/mode/mode_exec.cc b/src/tools/core/mode/mode_exec.cc index cd79fa029e..578c92acb7 100644 --- a/src/tools/core/mode/mode_exec.cc +++ b/src/tools/core/mode/mode_exec.cc @@ -231,7 +231,7 @@ void ModeExecutive::init_multivar_intensities(const ModeConfInfo &conf) engine.conf_info = conf; // tell the engine which type of data it is - engine.set_data_type(ModeDataType_MvMode_Both); + engine.set_data_type(ModeDataType::MvMode_Both); // check one again for multivar problems engine.conf_info.check_multivar_not_implemented(); @@ -362,14 +362,14 @@ void ModeExecutive::setup_traditional_fcst_obs_data() // Mask out the missing data between fields - if(engine.conf_info.mask_missing_flag == FieldType_Fcst || - engine.conf_info.mask_missing_flag == FieldType_Both) + if(engine.conf_info.mask_missing_flag == FieldType::Fcst || + engine.conf_info.mask_missing_flag == FieldType::Both) mask_bad_data(Fcst_sd.data, Obs_sd.data); // Mask out the missing data between fields - if(engine.conf_info.mask_missing_flag == FieldType_Obs || - engine.conf_info.mask_missing_flag == FieldType_Both) + if(engine.conf_info.mask_missing_flag == FieldType::Obs || + engine.conf_info.mask_missing_flag == FieldType::Both) mask_bad_data(Obs_sd.data, Fcst_sd.data); // Parse the grid and/or polyline masks from the configuration @@ -426,7 +426,7 @@ void ModeExecutive::setup_verification_grid(const ModeInputData &fcst, // set this local conf to point to forecast 0, so that that regrid info // can be accessed and it can be decided if we are to use fcst or obs // input - engine.conf_info.set_data_type(ModeDataType_MvMode_Fcst); + engine.conf_info.set_data_type(ModeDataType::MvMode_Fcst); engine.conf_info.set_field_index(0); grid = parse_vx_grid(engine.conf_info.Fcst->var_info->regrid(), &fcst._grid, &obs._grid); @@ -915,7 +915,7 @@ void ModeExecutive::do_conv_thresh_multivar_simple(Processing_t p) // string what; - if (conf.data_type == ModeDataType_MvMode_Obs) { + if (conf.data_type == ModeDataType::MvMode_Obs) { what = "observation field"; } else { what = "forecast field"; @@ -984,9 +984,9 @@ void ModeExecutive::do_merging_multivar(const ShapeData &f_merge, // set the merge flag and merge_thresh appropriately ModeConfInfo & conf = engine.conf_info; SingleThresh s("ne-9999"); - conf.set_fcst_merge_flag(MergeType_Thresh); + conf.set_fcst_merge_flag(MergeType::Thresh); conf.set_fcst_merge_thresh(s); - conf.set_obs_merge_flag(MergeType_Thresh); + conf.set_obs_merge_flag(MergeType::Thresh); conf.set_obs_merge_thresh(s); } else if (p != MULTIVAR_INTENSITY) { mlog << Error << "\nModeExecutive::do_merging(shapedata, shapedata, p) -> " @@ -1069,7 +1069,7 @@ void ModeExecutive::process_masks(ShapeData & fcst_sd, ShapeData & obs_sd) << "Processing masking regions.\n"; // Parse the grid mask into a ShapeData object - if(engine.conf_info.mask_grid_flag != FieldType_None) { + if(engine.conf_info.mask_grid_flag != FieldType::None) { mlog << Debug(3) << "Processing grid mask: " << engine.conf_info.mask_grid_name << "\n"; @@ -1078,7 +1078,7 @@ void ModeExecutive::process_masks(ShapeData & fcst_sd, ShapeData & obs_sd) } // Parse the poly mask into a ShapeData object - if(engine.conf_info.mask_poly_flag != FieldType_None) { + if(engine.conf_info.mask_poly_flag != FieldType::None) { mlog << Debug(3) << "Processing poly mask: " << engine.conf_info.mask_poly_name << "\n"; @@ -1087,26 +1087,26 @@ void ModeExecutive::process_masks(ShapeData & fcst_sd, ShapeData & obs_sd) } // Apply the grid mask to the forecast field if requested - if(engine.conf_info.mask_grid_flag == FieldType_Fcst || - engine.conf_info.mask_grid_flag == FieldType_Both) { + if(engine.conf_info.mask_grid_flag == FieldType::Fcst || + engine.conf_info.mask_grid_flag == FieldType::Both) { apply_mask(fcst_sd, grid_mask_sd); } // Apply the grid mask to the observation field if requested - if(engine.conf_info.mask_grid_flag == FieldType_Obs || - engine.conf_info.mask_grid_flag == FieldType_Both) { + if(engine.conf_info.mask_grid_flag == FieldType::Obs || + engine.conf_info.mask_grid_flag == FieldType::Both) { apply_mask(obs_sd, grid_mask_sd); } // Apply the polyline mask to the forecast field if requested - if(engine.conf_info.mask_poly_flag == FieldType_Fcst || - engine.conf_info.mask_poly_flag == FieldType_Both) { + if(engine.conf_info.mask_poly_flag == FieldType::Fcst || + engine.conf_info.mask_poly_flag == FieldType::Both) { apply_mask(fcst_sd, poly_mask_sd); } // Apply the polyline mask to the observation field if requested - if(engine.conf_info.mask_poly_flag == FieldType_Obs || - engine.conf_info.mask_poly_flag == FieldType_Both) { + if(engine.conf_info.mask_poly_flag == FieldType::Obs || + engine.conf_info.mask_poly_flag == FieldType::Both) { apply_mask(obs_sd, poly_mask_sd); } @@ -1125,7 +1125,7 @@ void ModeExecutive::process_fcst_masks(ShapeData & fcst_sd) mlog << Debug(3) << "Processing masking regions.\n"; // Parse the grid mask into a ShapeData object - if(engine.conf_info.mask_grid_flag != FieldType_None) { + if(engine.conf_info.mask_grid_flag != FieldType::None) { mlog << Debug(3) << "Processing grid mask: " << engine.conf_info.mask_grid_name << "\n"; @@ -1134,7 +1134,7 @@ void ModeExecutive::process_fcst_masks(ShapeData & fcst_sd) } // Parse the poly mask into a ShapeData object - if(engine.conf_info.mask_poly_flag != FieldType_None) { + if(engine.conf_info.mask_poly_flag != FieldType::None) { mlog << Debug(3) << "Processing poly mask: " << engine.conf_info.mask_poly_name << "\n"; @@ -1143,14 +1143,14 @@ void ModeExecutive::process_fcst_masks(ShapeData & fcst_sd) } // Apply the grid mask to the forecast field if requested - if(engine.conf_info.mask_grid_flag == FieldType_Fcst || - engine.conf_info.mask_grid_flag == FieldType_Both) { + if(engine.conf_info.mask_grid_flag == FieldType::Fcst || + engine.conf_info.mask_grid_flag == FieldType::Both) { apply_mask(fcst_sd, grid_mask_sd); } // Apply the polyline mask to the forecast field if requested - if(engine.conf_info.mask_poly_flag == FieldType_Fcst || - engine.conf_info.mask_poly_flag == FieldType_Both) { + if(engine.conf_info.mask_poly_flag == FieldType::Fcst || + engine.conf_info.mask_poly_flag == FieldType::Both) { apply_mask(fcst_sd, poly_mask_sd); } @@ -1170,7 +1170,7 @@ void ModeExecutive::process_obs_masks(ShapeData & obs_sd) << "Processing masking regions.\n"; // Parse the grid mask into a ShapeData object - if(engine.conf_info.mask_grid_flag != FieldType_None) { + if(engine.conf_info.mask_grid_flag != FieldType::None) { mlog << Debug(3) << "Processing grid mask: " << engine.conf_info.mask_grid_name << "\n"; @@ -1179,7 +1179,7 @@ void ModeExecutive::process_obs_masks(ShapeData & obs_sd) } // Parse the poly mask into a ShapeData object - if(engine.conf_info.mask_poly_flag != FieldType_None) { + if(engine.conf_info.mask_poly_flag != FieldType::None) { mlog << Debug(3) << "Processing poly mask: " << engine.conf_info.mask_poly_name << "\n"; @@ -1188,14 +1188,14 @@ void ModeExecutive::process_obs_masks(ShapeData & obs_sd) } // Apply the grid mask to the observation field if requested - if(engine.conf_info.mask_grid_flag == FieldType_Obs || - engine.conf_info.mask_grid_flag == FieldType_Both) { + if(engine.conf_info.mask_grid_flag == FieldType::Obs || + engine.conf_info.mask_grid_flag == FieldType::Both) { apply_mask(obs_sd, grid_mask_sd); } // Apply the polyline mask to the observation field if requested - if(engine.conf_info.mask_poly_flag == FieldType_Obs || - engine.conf_info.mask_poly_flag == FieldType_Both) { + if(engine.conf_info.mask_poly_flag == FieldType::Obs || + engine.conf_info.mask_poly_flag == FieldType::Both) { apply_mask(obs_sd, poly_mask_sd); } @@ -1548,8 +1548,8 @@ void ModeExecutive::write_obj_stats() out.close(); - if(engine.conf_info.Fcst->merge_flag == MergeType_Both || - engine.conf_info.Fcst->merge_flag == MergeType_Engine) { + if(engine.conf_info.Fcst->merge_flag == MergeType::Both || + engine.conf_info.Fcst->merge_flag == MergeType::Engine) { // // Create output stats file for forecast merging @@ -1580,8 +1580,8 @@ void ModeExecutive::write_obj_stats() out.close(); } - if(engine.conf_info.Obs->merge_flag == MergeType_Both || - engine.conf_info.Obs->merge_flag == MergeType_Engine) { + if(engine.conf_info.Obs->merge_flag == MergeType::Both || + engine.conf_info.Obs->merge_flag == MergeType::Engine) { // // Create output stats file for observation merging @@ -1624,7 +1624,7 @@ MultiVarData *ModeExecutive::get_multivar_data(ModeDataType dtype) switch (dtype) { - case ModeDataType_MvMode_Obs: + case ModeDataType::MvMode_Obs: obs_magic_string = engine.conf_info.Obs->var_info->magic_str().c_str(); // replace forward slashes with underscores to prevent new directories replace(obs_magic_string.begin(), obs_magic_string.end(), '/', '_'); @@ -1636,7 +1636,7 @@ MultiVarData *ModeExecutive::get_multivar_data(ModeDataType dtype) mvd->set_conv_thresh_array(engine.conf_info.Obs->conv_thresh_array, simple); mvd->set_merge_thresh_array(engine.conf_info.Obs->merge_thresh_array, simple); break; - case ModeDataType_MvMode_Fcst: + case ModeDataType::MvMode_Fcst: fcst_magic_string = engine.conf_info.Fcst->var_info->magic_str().c_str(); // replace forward slashes with underscores to prevent new directories replace(fcst_magic_string.begin(), fcst_magic_string.end(), '/', '_'); @@ -1664,14 +1664,14 @@ void ModeExecutive::add_multivar_merge_data(MultiVarData *mvd, ModeDataType dtyp bool simple = false; switch (dtype) { - case ModeDataType_MvMode_Obs: + case ModeDataType::MvMode_Obs: mvd->set_obj(engine.obs_split, simple); mvd->set_raw(engine.obs_raw, simple); mvd->set_shapedata(Obs_sd, simple); mvd->set_conv_thresh_array(engine.conf_info.Obs->conv_thresh_array, simple); mvd->set_merge_thresh_array(engine.conf_info.Obs->merge_thresh_array, simple); break; - case ModeDataType_MvMode_Fcst: + case ModeDataType::MvMode_Fcst: mvd->set_obj(engine.fcst_split, simple); mvd->set_raw(engine.fcst_raw, simple); mvd->set_shapedata(Fcst_sd, simple); @@ -2155,16 +2155,16 @@ void ModeExecutive::write_poly_netcdf(NcFile * f_out) // present. // if(engine.n_fcst > 0) { - write_poly_netcdf(f_out, FcstSimpBdyPoly); - write_poly_netcdf(f_out, FcstSimpHullPoly); + write_poly_netcdf(f_out, ObjPolyType::FcstSimpBdy); + write_poly_netcdf(f_out, ObjPolyType::FcstSimpHull); } if(engine.n_obs > 0) { - write_poly_netcdf(f_out, ObsSimpBdyPoly); - write_poly_netcdf(f_out, ObsSimpHullPoly); + write_poly_netcdf(f_out, ObjPolyType::ObsSimpBdy); + write_poly_netcdf(f_out, ObjPolyType::ObsSimpHull); } if(engine.n_clus > 0) { - write_poly_netcdf(f_out, FcstClusHullPoly); - write_poly_netcdf(f_out, ObsClusHullPoly); + write_poly_netcdf(f_out, ObjPolyType::FcstClusHull); + write_poly_netcdf(f_out, ObjPolyType::ObsClusHull); } return; @@ -2217,7 +2217,7 @@ void ModeExecutive::write_poly_netcdf(NcFile *f_out, ObjPolyType poly_type) // and set up strings switch(poly_type) { - case FcstSimpBdyPoly: + case ObjPolyType::FcstSimpBdy: n_poly = engine.n_fcst; field_name = "fcst"; field_long = "Forecast"; @@ -2225,7 +2225,7 @@ void ModeExecutive::write_poly_netcdf(NcFile *f_out, ObjPolyType poly_type) poly_long = "Simple Boundary"; break; - case ObsSimpBdyPoly: + case ObjPolyType::ObsSimpBdy: n_poly = engine.n_obs; field_name = "obs"; field_long = "Observation"; @@ -2233,7 +2233,7 @@ void ModeExecutive::write_poly_netcdf(NcFile *f_out, ObjPolyType poly_type) poly_long = "Simple Boundary"; break; - case FcstSimpHullPoly: + case ObjPolyType::FcstSimpHull: n_poly = engine.n_fcst; field_name = "fcst"; field_long = "Forecast"; @@ -2241,7 +2241,7 @@ void ModeExecutive::write_poly_netcdf(NcFile *f_out, ObjPolyType poly_type) poly_long = "Simple Convex Hull"; break; - case ObsSimpHullPoly: + case ObjPolyType::ObsSimpHull: n_poly = engine.n_obs; field_name = "obs"; field_long = "Observation"; @@ -2249,7 +2249,7 @@ void ModeExecutive::write_poly_netcdf(NcFile *f_out, ObjPolyType poly_type) poly_long = "Simple Convex Hull"; break; - case FcstClusHullPoly: + case ObjPolyType::FcstClusHull: n_poly = engine.n_clus; field_name = "fcst"; field_long = "Forecast"; @@ -2257,7 +2257,7 @@ void ModeExecutive::write_poly_netcdf(NcFile *f_out, ObjPolyType poly_type) poly_long = "Cluster Convex Hull"; break; - case ObsClusHullPoly: + case ObjPolyType::ObsClusHull: n_poly = engine.n_clus; field_name = "obs"; field_long = "Observation"; @@ -2270,8 +2270,8 @@ void ModeExecutive::write_poly_netcdf(NcFile *f_out, ObjPolyType poly_type) } // Setup dimension name strings - if(poly_type == FcstClusHullPoly || - poly_type == ObsClusHullPoly) { + if(poly_type == ObjPolyType::FcstClusHull || + poly_type == ObjPolyType::ObsClusHull) { obj_dim_name << cs_erase << field_name << "_clus"; } else { @@ -2301,27 +2301,27 @@ void ModeExecutive::write_poly_netcdf(NcFile *f_out, ObjPolyType poly_type) switch(poly_type) { - case FcstSimpBdyPoly: + case ObjPolyType::FcstSimpBdy: poly[i] = &engine.fcst_single[i].boundary[0]; break; - case ObsSimpBdyPoly: + case ObjPolyType::ObsSimpBdy: poly[i] = &engine.obs_single[i].boundary[0]; break; - case FcstSimpHullPoly: + case ObjPolyType::FcstSimpHull: poly[i] = &engine.fcst_single[i].convex_hull; break; - case ObsSimpHullPoly: + case ObjPolyType::ObsSimpHull: poly[i] = &engine.obs_single[i].convex_hull; break; - case FcstClusHullPoly: + case ObjPolyType::FcstClusHull: poly[i] = &engine.fcst_cluster[i].convex_hull; break; - case ObsClusHullPoly: + case ObjPolyType::ObsClusHull: poly[i] = &engine.obs_cluster[i].convex_hull; break; diff --git a/src/tools/core/mode/mode_exec.h b/src/tools/core/mode/mode_exec.h index e2ad110dda..184a2e0a74 100644 --- a/src/tools/core/mode/mode_exec.h +++ b/src/tools/core/mode/mode_exec.h @@ -51,13 +51,13 @@ static const int n_cts = 2; //////////////////////////////////////////////////////////////////////// -enum ObjPolyType { - FcstSimpBdyPoly = 0, - ObsSimpBdyPoly = 1, - FcstSimpHullPoly = 2, - ObsSimpHullPoly = 3, - FcstClusHullPoly = 4, - ObsClusHullPoly = 5 +enum class ObjPolyType { + FcstSimpBdy = 0, + ObsSimpBdy = 1, + FcstSimpHull = 2, + ObsSimpHull = 3, + FcstClusHull = 4, + ObsClusHull = 5 }; diff --git a/src/tools/core/mode/mode_ps_file.cc b/src/tools/core/mode/mode_ps_file.cc index dd80209b01..3daa7427ae 100644 --- a/src/tools/core/mode/mode_ps_file.cc +++ b/src/tools/core/mode/mode_ps_file.cc @@ -552,29 +552,29 @@ void ModePsFile::make_plot(bool isMultivarSuper) << ConfInfo->Obs->var_info->level_attr(); } - plot_engine(*Engine, FOEng, s.c_str()); + plot_engine(*Engine, EngineType::FOEng, s.c_str()); - if ( (fcst_merge_flag == MergeType_Both) || (fcst_merge_flag == MergeType_Thresh) ) { + if ( (fcst_merge_flag == MergeType::Both) || (fcst_merge_flag == MergeType::Thresh) ) { plot_threshold_merging(*Engine, "Forecast: Threshold Merging", 1); } - if ( (fcst_merge_flag == MergeType_Both) || (fcst_merge_flag == MergeType_Engine) ) { + if ( (fcst_merge_flag == MergeType::Both) || (fcst_merge_flag == MergeType::Engine) ) { - plot_engine(*(Engine->fcst_engine), FFEng, "Forecast: ModeFuzzyEngine Merging"); + plot_engine(*(Engine->fcst_engine), EngineType::FFEng, "Forecast: ModeFuzzyEngine Merging"); } - if ( (obs_merge_flag == MergeType_Both) || (obs_merge_flag == MergeType_Thresh) ) { + if ( (obs_merge_flag == MergeType::Both) || (obs_merge_flag == MergeType::Thresh) ) { plot_threshold_merging(*Engine, "Observation: Threshold Merging", 0); } - if ( (obs_merge_flag == MergeType_Both) || (obs_merge_flag == MergeType_Engine) ) { + if ( (obs_merge_flag == MergeType::Both) || (obs_merge_flag == MergeType::Engine) ) { - plot_engine(*(Engine->obs_engine), OOEng, "Observation: ModeFuzzyEngine Merging"); + plot_engine(*(Engine->obs_engine), EngineType::OOEng, "Observation: ModeFuzzyEngine Merging"); } @@ -633,12 +633,12 @@ void ModePsFile::plot_threshold_merging (ModeFuzzyEngine & eng, const char * tit if ( fcst ) { comment("threshold merging page: fcst raw"); - render_ppm(eng, FOEng, *(eng.fcst_raw), fcst, 0); + render_ppm(eng, EngineType::FOEng, *(eng.fcst_raw), fcst, 0); } else { comment("threshold merging page: obs raw"); - render_ppm(eng, FOEng, *(eng.obs_raw), fcst, 0); + render_ppm(eng, EngineType::FOEng, *(eng.obs_raw), fcst, 0); } @@ -661,12 +661,12 @@ void ModePsFile::plot_threshold_merging (ModeFuzzyEngine & eng, const char * tit if ( fcst ) { comment("threshold merging page: fcst raw"); - render_ppm(eng, FOEng, *(eng.fcst_split), fcst, 2); + render_ppm(eng, EngineType::FOEng, *(eng.fcst_split), fcst, 2); } else { comment("threshold merging page: obs split"); - render_ppm(eng, FOEng, *(eng.obs_split), fcst, 2); + render_ppm(eng, EngineType::FOEng, *(eng.obs_split), fcst, 2); } @@ -1021,17 +1021,17 @@ void ModePsFile::render_ppm(ModeFuzzyEngine & eng, EngineType eng_type, const Sh // Set up pointers to the appropriate colortable and fill color values // - if ( eng_type == FFEng ) { + if ( eng_type == EngineType::FFEng ) { ct = &FcstRawCtable; fill_color = FcstFillColor; - } else if ( eng_type == OOEng ) { + } else if ( eng_type == EngineType::OOEng ) { ct = &ObsRawCtable; fill_color = ObsFillColor; - } else { // eng_type == FOEng + } else { // eng_type == EngineType::FOEng if ( fcst ) { diff --git a/src/tools/core/mode/mode_ps_file.h b/src/tools/core/mode/mode_ps_file.h index 6b9318a827..284a45484b 100644 --- a/src/tools/core/mode/mode_ps_file.h +++ b/src/tools/core/mode/mode_ps_file.h @@ -36,7 +36,7 @@ static const bool use_zlib = true; //////////////////////////////////////////////////////////////////////// -enum EngineType { +enum class EngineType { NoEng = 0, FOEng = 1, FFEng = 2, diff --git a/src/tools/core/mode/multivar_data.cc b/src/tools/core/mode/multivar_data.cc index 3bcfa136f7..b0979e3b45 100644 --- a/src/tools/core/mode/multivar_data.cc +++ b/src/tools/core/mode/multivar_data.cc @@ -138,7 +138,7 @@ void MultiVarData1::_print_summary(const string &name, int *data, const ShapeDat } MultiVarData::MultiVarData() : - _dataType(ModeDataType_MvMode_Both), + _dataType(ModeDataType::MvMode_Both), _simple(0), _merge(0), _name("notset"), diff --git a/src/tools/core/mode/multivar_frontend.cc b/src/tools/core/mode/multivar_frontend.cc index efffb4deaa..baa0537791 100644 --- a/src/tools/core/mode/multivar_frontend.cc +++ b/src/tools/core/mode/multivar_frontend.cc @@ -70,14 +70,14 @@ int MultivarFrontEnd::run(const StringArray & Argv) GrdFileType ft, ot; ft = config.file_type_for_field(true, i); ot = parse_conf_file_type(config.conf.lookup_dictionary(conf_key_obs)); - read_input(fcst_filenames[i], i, ModeDataType_MvMode_Fcst, ft, ot, shift); + read_input(fcst_filenames[i], i, ModeDataType::MvMode_Fcst, ft, ot, shift); } for (int i=0; idata_plane(*(config.Fcst->var_info), dp); fcstInput.push_back(ModeInputData(name, dp, g)); @@ -350,14 +350,14 @@ MultivarFrontEnd::create_intensity_comparisons(int findex, int oindex, // from pass1 conf.Fcst->var_info->set_level_name(mvdf._level.c_str()); conf.Fcst->var_info->set_units(mvdf._units.c_str()); - if (fsuper._hasUnion && conf.Fcst->merge_flag == MergeType_Thresh) { + if (fsuper._hasUnion && conf.Fcst->merge_flag == MergeType::Thresh) { mlog << Warning << "\nModeFrontEnd::multivar_intensity_comparisons() -> " << "Logic includes union '||' along with 'merge_flag=THRESH' " << ". This can lead to bad results\n\n"; } conf.Obs->var_info->set_level_name(mvdo._level.c_str()); conf.Obs->var_info->set_units(mvdo._units.c_str()); - if (osuper._hasUnion && conf.Obs->merge_flag == MergeType_Thresh) { + if (osuper._hasUnion && conf.Obs->merge_flag == MergeType::Thresh) { mlog << Warning << "\nModeFrontEnd::multivar_intensity_comparisons() -> " << "Logic includes union '||' along with 'merge_flag=THRESH' " << ". This can lead to bad results\n\n"; @@ -395,8 +395,8 @@ void MultivarFrontEnd::process_superobjects(ModeSuperObject &fsuper, ModeConfInfo & conf = mode_exec->engine.conf_info; if ((fsuper._hasUnion || osuper._hasUnion) && - (conf.Fcst->merge_flag == MergeType_Thresh || - conf.Obs->merge_flag == MergeType_Thresh)) { + (conf.Fcst->merge_flag == MergeType::Thresh || + conf.Obs->merge_flag == MergeType::Thresh)) { mlog << Warning << "\nModeFrontEnd::run_super() -> " << "Logic includes union '||' along with 'merge_flag=THRESH' " << ". This can lead to bad results\n\n"; @@ -637,7 +637,7 @@ void MultivarFrontEnd::_simple_objects(ModeExecutive::Processing_t p, int j, int n_files, const string &filename, const ModeInputData &input) { - if (dtype == ModeDataType_MvMode_Fcst) { + if (dtype == ModeDataType::MvMode_Fcst) { _init_exec(p, filename, "None"); mode_exec->init_multivar_simple(j, n_files, dtype, config); mode_exec->setup_multivar_fcst_data(verification_grid, input); diff --git a/src/tools/core/mode/page_1.cc b/src/tools/core/mode/page_1.cc index 5a87e97424..9c1f3d0079 100644 --- a/src/tools/core/mode/page_1.cc +++ b/src/tools/core/mode/page_1.cc @@ -576,8 +576,8 @@ void ModePsFile::do_page_1(ModeFuzzyEngine & eng, EngineType eng_type, const cha Htab_b = Htab_a + 5.0*TextSep; Htab_c = Htab_a + 10.0*TextSep; - if ( eng_type == FOEng ) do_page_1_FOEng (eng, eng_type, title); - else do_page_1_other (eng, eng_type, title); + if ( eng_type == EngineType::FOEng ) do_page_1_FOEng (eng, eng_type, title); + else do_page_1_other (eng, eng_type, title); showpage(); @@ -690,26 +690,26 @@ void ModePsFile::do_page_1_FOEng(ModeFuzzyEngine & eng, EngineType eng_type, con // Mask missing, grid, and polyline Flags // // write_centered_text(1, 1, Htab_a, text_y, 0.0, 0.5, "Mask M/G/P:"); - if(eng.conf_info.mask_missing_flag == FieldType_Both || - eng.conf_info.mask_missing_flag == FieldType_Fcst) tmp1_str = "on"; + if(eng.conf_info.mask_missing_flag == FieldType::Both || + eng.conf_info.mask_missing_flag == FieldType::Fcst) tmp1_str = "on"; else tmp1_str = "off"; - if(eng.conf_info.mask_grid_flag == FieldType_Both || - eng.conf_info.mask_grid_flag == FieldType_Fcst) tmp2_str = "on"; + if(eng.conf_info.mask_grid_flag == FieldType::Both || + eng.conf_info.mask_grid_flag == FieldType::Fcst) tmp2_str = "on"; else tmp2_str = "off"; - if(eng.conf_info.mask_grid_flag == FieldType_Both || - eng.conf_info.mask_grid_flag == FieldType_Fcst) tmp3_str = "on"; + if(eng.conf_info.mask_grid_flag == FieldType::Both || + eng.conf_info.mask_grid_flag == FieldType::Fcst) tmp3_str = "on"; else tmp3_str = "off"; label << cs_erase << tmp1_str << '/' << tmp2_str << '/' << tmp3_str; t.write_xy1_to_cell(r, 1, dx, dy, 0.0, 0.0, label.c_str()); - if(eng.conf_info.mask_missing_flag == FieldType_Both || - eng.conf_info.mask_missing_flag == FieldType_Obs) tmp1_str = "on"; + if(eng.conf_info.mask_missing_flag == FieldType::Both || + eng.conf_info.mask_missing_flag == FieldType::Obs) tmp1_str = "on"; else tmp1_str = "off"; - if(eng.conf_info.mask_grid_flag == FieldType_Both || - eng.conf_info.mask_grid_flag == FieldType_Obs) tmp2_str = "on"; + if(eng.conf_info.mask_grid_flag == FieldType::Both || + eng.conf_info.mask_grid_flag == FieldType::Obs) tmp2_str = "on"; else tmp2_str = "off"; - if(eng.conf_info.mask_grid_flag == FieldType_Both || - eng.conf_info.mask_grid_flag == FieldType_Obs) tmp3_str = "on"; + if(eng.conf_info.mask_grid_flag == FieldType::Both || + eng.conf_info.mask_grid_flag == FieldType::Obs) tmp3_str = "on"; else tmp3_str = "off"; label << cs_erase << tmp1_str << '/' << tmp2_str << '/' << tmp3_str; t.write_xy1_to_cell(r, 2, dx, dy, 0.0, 0.0, label.c_str()); @@ -792,15 +792,15 @@ void ModePsFile::do_page_1_FOEng(ModeFuzzyEngine & eng, EngineType eng_type, con // Merging flag // - if(eng.conf_info.Fcst->merge_flag == MergeType_Thresh) label = "thresh"; - else if(eng.conf_info.Fcst->merge_flag == MergeType_Engine) label = "engine"; - else if(eng.conf_info.Fcst->merge_flag == MergeType_Both) label = "thresh/engine"; + if(eng.conf_info.Fcst->merge_flag == MergeType::Thresh) label = "thresh"; + else if(eng.conf_info.Fcst->merge_flag == MergeType::Engine) label = "engine"; + else if(eng.conf_info.Fcst->merge_flag == MergeType::Both) label = "thresh/engine"; else label = "none"; t.write_xy1_to_cell(r, 1, dx, dy, 0.0, 0.0, label.c_str()); - if(eng.conf_info.Obs->merge_flag == MergeType_Thresh) label = "thresh"; - else if(eng.conf_info.Obs->merge_flag == MergeType_Engine) label = "engine"; - else if(eng.conf_info.Obs->merge_flag == MergeType_Both) label = "thresh/engine"; + if(eng.conf_info.Obs->merge_flag == MergeType::Thresh) label = "thresh"; + else if(eng.conf_info.Obs->merge_flag == MergeType::Engine) label = "engine"; + else if(eng.conf_info.Obs->merge_flag == MergeType::Both) label = "thresh/engine"; else label = "none"; t.write_xy1_to_cell(r, 2, dx, dy, 0.0, 0.0, label.c_str()); @@ -811,9 +811,9 @@ void ModePsFile::do_page_1_FOEng(ModeFuzzyEngine & eng, EngineType eng_type, con // Matching scheme // - if(eng.conf_info.match_flag == MatchType_MergeBoth) label = "match/merge"; - else if(eng.conf_info.match_flag == MatchType_MergeFcst) label = "match/fcst merge"; - else if(eng.conf_info.match_flag == MatchType_NoMerge) label = "match/no merge"; + if(eng.conf_info.match_flag == MatchType::MergeBoth) label = "match/merge"; + else if(eng.conf_info.match_flag == MatchType::MergeFcst) label = "match/fcst merge"; + else if(eng.conf_info.match_flag == MatchType::NoMerge) label = "match/no merge"; else label = "none"; t.write_xy1_to_cell(r, 2, 0.0, dy, 0.5, 0.0, label.c_str()); diff --git a/src/tools/core/mode/plot_engine.cc b/src/tools/core/mode/plot_engine.cc index 5a92e5643c..50a839a869 100644 --- a/src/tools/core/mode/plot_engine.cc +++ b/src/tools/core/mode/plot_engine.cc @@ -38,21 +38,21 @@ void ModePsFile::plot_engine(ModeFuzzyEngine & eng, EngineType eng_type, const c // setup fcst & obs strings // - if ( eng_type == FOEng ) { // Plot forecast versus observation + if ( eng_type == EngineType::FOEng ) { // Plot forecast versus observation FcstString = "Forecast"; FcstShortString = "Fcst"; ObsString = "Observation"; ObsShortString = "Obs"; - } else if ( eng_type == FFEng ) { // Plot forecast versus forecast + } else if ( eng_type == EngineType::FFEng ) { // Plot forecast versus forecast FcstString = "Forecast"; FcstShortString = "Fcst"; ObsString = "Forecast"; ObsShortString = "Fcst"; - } else if ( eng_type == OOEng ) { // Plot observation versus observation + } else if ( eng_type == EngineType::OOEng ) { // Plot observation versus observation FcstString = "Observation"; FcstShortString = "Obs"; @@ -67,11 +67,11 @@ void ModePsFile::plot_engine(ModeFuzzyEngine & eng, EngineType eng_type, const c do_page_1(eng, eng_type, title); - if ( (eng_type == FOEng) || (eng_type == FFEng) ) do_fcst_enlarge_page(eng, eng_type, title); + if ( (eng_type == EngineType::FOEng) || (eng_type == EngineType::FFEng) ) do_fcst_enlarge_page(eng, eng_type, title); - if ( (eng_type == FOEng) || (eng_type == OOEng) ) do_obs_enlarge_page(eng, eng_type, title); + if ( (eng_type == EngineType::FOEng) || (eng_type == EngineType::OOEng) ) do_obs_enlarge_page(eng, eng_type, title); - if ( eng_type == FOEng ) { + if ( eng_type == EngineType::FOEng ) { do_overlap_page(eng, eng_type, title); do_cluster_page(eng, eng_type, title); diff --git a/src/tools/core/pcp_combine/pcp_combine.cc b/src/tools/core/pcp_combine/pcp_combine.cc index 7adf584e07..8ff4742b68 100644 --- a/src/tools/core/pcp_combine/pcp_combine.cc +++ b/src/tools/core/pcp_combine/pcp_combine.cc @@ -119,10 +119,10 @@ static const char derive_options [] = "sum, min, max, range, mean, stdev, vld_count"; // Run Command enumeration -enum RunCommand { sum = 0, add = 1, sub = 2, der = 3 }; +enum class RunCommand { sum = 0, add = 1, sub = 2, der = 3 }; // Variables for top-level command line arguments -static RunCommand run_command = sum; +static RunCommand run_command = RunCommand::sum; // Variables common to all commands static int n_files; @@ -232,8 +232,8 @@ int met_main(int argc, char *argv[]) { // Perform the requested run or subtract command. // Derive handles add and derive. // - if(run_command == sum) do_sum_command(); - else if(run_command == sub) do_sub_command(); + if(run_command == RunCommand::sum) do_sum_command(); + else if(run_command == RunCommand::sub) do_sub_command(); else do_derive_command(); } @@ -264,7 +264,7 @@ void process_command_line(int argc, char **argv) { // // Default to running the sum command // - run_command = sum; + run_command = RunCommand::sum; derive_list.add("sum"); // @@ -305,8 +305,8 @@ void process_command_line(int argc, char **argv) { // // Process the specific command arguments. // - if(run_command == sum) process_sum_args(cline); - else process_add_sub_derive_args(cline); + if(run_command == RunCommand::sum) process_sum_args(cline); + else process_add_sub_derive_args(cline); // // If -field not set, set to a list of length 1 with an empty string. @@ -1295,21 +1295,21 @@ void open_nc(const Grid &grid) { // Add global attributes. write_netcdf_global(nc_out, out_filename.c_str(), program_name.c_str()); - if(run_command == sum) { + if(run_command == RunCommand::sum) { command_str << cs_erase << "Sum: " << n_files << " files with accumulations of " << sec_to_hhmmss(in_accum) << '.'; - } else if(run_command == add) { + } else if(run_command == RunCommand::add) { command_str << cs_erase << "Addition: " << n_files << " files."; } - else if(run_command == sub) { + else if(run_command == RunCommand::sub) { command_str << cs_erase << "Subtraction: " << file_list[0] << " minus " << file_list[1]; } - else { // run_command = der + else { // run_command = RunCommand::der command_str << cs_erase << "Derive: " << write_css(derive_list) << " of " << n_files << " files."; @@ -1391,7 +1391,7 @@ void write_nc_data(unixtime nc_init, unixtime nc_valid, int nc_accum, // // Append the derivation string. // - if(run_command == der) var_str << "_" << derive_str; + if(run_command == RunCommand::der) var_str << "_" << derive_str; } mlog << Debug(2) @@ -1408,8 +1408,8 @@ void write_nc_data(unixtime nc_init, unixtime nc_valid, int nc_accum, // Add variable attributes. add_att(&nc_var, "name", var_str.c_str()); - if(run_command == der) cs = long_name_prefix; - else cs.clear(); + if(run_command == RunCommand::der) cs = long_name_prefix; + else cs.clear(); cs << var_info->long_name_attr(); add_att(&nc_var, "long_name", cs.c_str()); @@ -1624,7 +1624,7 @@ void usage() { //////////////////////////////////////////////////////////////////////// void set_sum(const StringArray &) { - run_command = sum; + run_command = RunCommand::sum; derive_list.clear(); derive_list.add("sum"); } @@ -1632,7 +1632,7 @@ void set_sum(const StringArray &) { //////////////////////////////////////////////////////////////////////// void set_add(const StringArray &) { - run_command = add; + run_command = RunCommand::add; derive_list.clear(); derive_list.add("sum"); } @@ -1640,7 +1640,7 @@ void set_add(const StringArray &) { //////////////////////////////////////////////////////////////////////// void set_subtract(const StringArray &) { - run_command = sub; + run_command = RunCommand::sub; derive_list.clear(); derive_list.add("diff"); } @@ -1648,7 +1648,7 @@ void set_subtract(const StringArray &) { //////////////////////////////////////////////////////////////////////// void set_derive(const StringArray & a) { - run_command = der; + run_command = RunCommand::der; derive_list.clear(); StringArray sa; diff --git a/src/tools/core/point_stat/point_stat.cc b/src/tools/core/point_stat/point_stat.cc index b5460f9a01..313db804b8 100644 --- a/src/tools/core/point_stat/point_stat.cc +++ b/src/tools/core/point_stat/point_stat.cc @@ -448,7 +448,7 @@ void setup_txt_files() { for(int i=0; iseeps); write_seeps_row(shc, &pd_ptr->seeps, conf_info.vx_opt[i].output_flag[i_seeps], @@ -1102,10 +1102,10 @@ void process_scores() { // Compute CTS scores if(!conf_info.vx_opt[i].vx_pd.fcst_info->is_prob() && conf_info.vx_opt[i].fcat_ta.n() > 0 && - (conf_info.vx_opt[i].output_flag[i_fho] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_ctc] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_cts] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_eclv] != STATOutputType_None)) { + (conf_info.vx_opt[i].output_flag[i_fho] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_ctc] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_cts] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_eclv] != STATOutputType::None)) { // Initialize for(m=0; mis_prob() && conf_info.vx_opt[i].fcat_ta.n() > 1 && - (conf_info.vx_opt[i].output_flag[i_mctc] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_mcts] != STATOutputType_None)) { + (conf_info.vx_opt[i].output_flag[i_mctc] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_mcts] != STATOutputType::None)) { // Initialize mcts_info.clear(); @@ -1165,7 +1165,7 @@ void process_scores() { do_mcts(mcts_info, i, pd_ptr); // Write out MCTC - if(conf_info.vx_opt[i].output_flag[i_mctc] != STATOutputType_None && + if(conf_info.vx_opt[i].output_flag[i_mctc] != STATOutputType::None && mcts_info.cts.total() > 0) { write_mctc_row(shc, mcts_info, @@ -1175,7 +1175,7 @@ void process_scores() { } // Write out MCTS - if(conf_info.vx_opt[i].output_flag[i_mcts] != STATOutputType_None && + if(conf_info.vx_opt[i].output_flag[i_mcts] != STATOutputType::None && mcts_info.cts.total() > 0) { write_mcts_row(shc, mcts_info, @@ -1187,9 +1187,9 @@ void process_scores() { // Compute CNT, SL1L2, and SAL1L2 scores if(!conf_info.vx_opt[i].vx_pd.fcst_info->is_prob() && - (conf_info.vx_opt[i].output_flag[i_cnt] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_sl1l2] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_sal1l2] != STATOutputType_None)) { + (conf_info.vx_opt[i].output_flag[i_cnt] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_sl1l2] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_sal1l2] != STATOutputType::None)) { do_cnt_sl1l2(conf_info.vx_opt[i], pd_ptr); } @@ -1197,9 +1197,9 @@ void process_scores() { if(!conf_info.vx_opt[i].vx_pd.fcst_info->is_prob() && conf_info.vx_opt[i].vx_pd.fcst_info->is_v_wind() && conf_info.vx_opt[i].vx_pd.fcst_info->uv_index() >= 0 && - (conf_info.vx_opt[i].output_flag[i_vl1l2] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_val1l2] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_vcnt] != STATOutputType_None)) { + (conf_info.vx_opt[i].output_flag[i_vl1l2] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_val1l2] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_vcnt] != STATOutputType::None)) { // Store the forecast variable name shc.set_fcst_var(ugrd_vgrd_abbr_str); @@ -1239,7 +1239,7 @@ void process_scores() { for(m=0; m 0) { write_vl1l2_row(shc, vl1l2_info[m], conf_info.vx_opt[i].output_flag[i_vl1l2], @@ -1248,7 +1248,7 @@ void process_scores() { } // Write out VAL1L2 - if(conf_info.vx_opt[i].output_flag[i_val1l2] != STATOutputType_None && + if(conf_info.vx_opt[i].output_flag[i_val1l2] != STATOutputType::None && vl1l2_info[m].vacount > 0) { write_val1l2_row(shc, vl1l2_info[m], conf_info.vx_opt[i].output_flag[i_val1l2], @@ -1257,7 +1257,7 @@ void process_scores() { } // Write out VCNT - if(conf_info.vx_opt[i].output_flag[i_vcnt] != STATOutputType_None && + if(conf_info.vx_opt[i].output_flag[i_vcnt] != STATOutputType::None && vl1l2_info[m].vcount > 0) { write_vcnt_row(shc, vl1l2_info[m], conf_info.vx_opt[i].output_flag[i_vcnt], @@ -1277,11 +1277,11 @@ void process_scores() { // Compute PCT counts and scores if(conf_info.vx_opt[i].vx_pd.fcst_info->is_prob() && - (conf_info.vx_opt[i].output_flag[i_pct] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_pstd] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_pjc] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_prc] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_eclv] != STATOutputType_None)) { + (conf_info.vx_opt[i].output_flag[i_pct] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_pstd] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_pjc] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_prc] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_eclv] != STATOutputType::None)) { do_pct(conf_info.vx_opt[i], pd_ptr); } @@ -1293,8 +1293,8 @@ void process_scores() { // Apply HiRA ensemble verification logic if(!conf_info.vx_opt[i].vx_pd.fcst_info->is_prob() && conf_info.vx_opt[i].hira_info.flag && - (conf_info.vx_opt[i].output_flag[i_ecnt] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_rps] != STATOutputType_None)) { + (conf_info.vx_opt[i].output_flag[i_ecnt] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_rps] != STATOutputType::None)) { pd_ptr = &conf_info.vx_opt[i].vx_pd.pd[j][k][0]; @@ -1309,11 +1309,11 @@ void process_scores() { // Apply HiRA probabilistic verification logic if(!conf_info.vx_opt[i].vx_pd.fcst_info->is_prob() && conf_info.vx_opt[i].hira_info.flag && - (conf_info.vx_opt[i].output_flag[i_mpr] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_pct] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_pstd] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_pjc] != STATOutputType_None || - conf_info.vx_opt[i].output_flag[i_prc] != STATOutputType_None)) { + (conf_info.vx_opt[i].output_flag[i_mpr] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_pct] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_pstd] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_pjc] != STATOutputType::None || + conf_info.vx_opt[i].output_flag[i_prc] != STATOutputType::None)) { pd_ptr = &conf_info.vx_opt[i].vx_pd.pd[j][k][0]; @@ -1371,11 +1371,11 @@ void do_cts(CTSInfo *&cts_info, int i_vx, const PairDataPoint *pd_ptr) { // Compute the stats, normal confidence intervals, and bootstrap // bootstrap confidence intervals // - if(conf_info.vx_opt[i_vx].boot_info.interval == boot_bca_flag) { + if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType::BCA) { compute_cts_stats_ci_bca(rng_ptr, *pd_ptr, conf_info.vx_opt[i_vx].boot_info.n_rep, cts_info, n_cat, - conf_info.vx_opt[i_vx].output_flag[i_cts] != STATOutputType_None, + conf_info.vx_opt[i_vx].output_flag[i_cts] != STATOutputType::None, conf_info.vx_opt[i_vx].rank_corr_flag, conf_info.tmp_dir.c_str()); } @@ -1384,7 +1384,7 @@ void do_cts(CTSInfo *&cts_info, int i_vx, const PairDataPoint *pd_ptr) { conf_info.vx_opt[i_vx].boot_info.n_rep, conf_info.vx_opt[i_vx].boot_info.rep_prop, cts_info, n_cat, - conf_info.vx_opt[i_vx].output_flag[i_cts] != STATOutputType_None, + conf_info.vx_opt[i_vx].output_flag[i_cts] != STATOutputType::None, conf_info.vx_opt[i_vx].rank_corr_flag, conf_info.tmp_dir.c_str()); } @@ -1422,11 +1422,11 @@ void do_mcts(MCTSInfo &mcts_info, int i_vx, const PairDataPoint *pd_ptr) { // Compute the stats, normal confidence intervals, and bootstrap // bootstrap confidence intervals // - if(conf_info.vx_opt[i_vx].boot_info.interval == boot_bca_flag) { + if(conf_info.vx_opt[i_vx].boot_info.interval == BootIntervalType::BCA) { compute_mcts_stats_ci_bca(rng_ptr, *pd_ptr, conf_info.vx_opt[i_vx].boot_info.n_rep, mcts_info, - conf_info.vx_opt[i_vx].output_flag[i_mcts] != STATOutputType_None, + conf_info.vx_opt[i_vx].output_flag[i_mcts] != STATOutputType::None, conf_info.vx_opt[i_vx].rank_corr_flag, conf_info.tmp_dir.c_str()); } @@ -1435,7 +1435,7 @@ void do_mcts(MCTSInfo &mcts_info, int i_vx, const PairDataPoint *pd_ptr) { conf_info.vx_opt[i_vx].boot_info.n_rep, conf_info.vx_opt[i_vx].boot_info.rep_prop, mcts_info, - conf_info.vx_opt[i_vx].output_flag[i_mcts] != STATOutputType_None, + conf_info.vx_opt[i_vx].output_flag[i_mcts] != STATOutputType::None, conf_info.vx_opt[i_vx].rank_corr_flag, conf_info.tmp_dir.c_str()); } @@ -1464,9 +1464,9 @@ void do_cnt_sl1l2(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { } // Set flags - bool do_sl1l2 = (vx_opt.output_flag[i_sl1l2] != STATOutputType_None || - vx_opt.output_flag[i_sal1l2] != STATOutputType_None); - bool do_cnt = (vx_opt.output_flag[i_cnt] != STATOutputType_None); + bool do_sl1l2 = (vx_opt.output_flag[i_sl1l2] != STATOutputType::None || + vx_opt.output_flag[i_sal1l2] != STATOutputType::None); + bool do_cnt = (vx_opt.output_flag[i_cnt] != STATOutputType::None); bool precip_flag = (vx_opt.vx_pd.fcst_info->is_precipitation() && vx_opt.vx_pd.obs_info->is_precipitation()); @@ -1513,7 +1513,7 @@ void do_cnt_sl1l2(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Write out SL1L2 if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_sl1l2] != STATOutputType_None && + vx_opt.output_flag[i_sl1l2] != STATOutputType::None && sl1l2_info[j].scount > 0) { write_sl1l2_row(shc, sl1l2_info[j], @@ -1524,7 +1524,7 @@ void do_cnt_sl1l2(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Write out SAL1L2 if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_sal1l2] != STATOutputType_None && + vx_opt.output_flag[i_sal1l2] != STATOutputType::None && sl1l2_info[j].sacount > 0) { write_sal1l2_row(shc, sl1l2_info[j], @@ -1550,7 +1550,7 @@ void do_cnt_sl1l2(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Compute the stats, normal confidence intervals, and // bootstrap confidence intervals - if(vx_opt.boot_info.interval == BootIntervalType_BCA) { + if(vx_opt.boot_info.interval == BootIntervalType::BCA) { compute_cnt_stats_ci_bca(rng_ptr, pd, precip_flag, vx_opt.rank_corr_flag, vx_opt.boot_info.n_rep, @@ -1566,7 +1566,7 @@ void do_cnt_sl1l2(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Write out CNT if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_cnt] != STATOutputType_None && + vx_opt.output_flag[i_cnt] != STATOutputType::None && cnt_info[j].n > 0) { write_cnt_row(shc, cnt_info[j], @@ -1580,14 +1580,14 @@ void do_cnt_sl1l2(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { if(n_bin > 1) { // Compute SL1L2 climo CDF bin means - if(vx_opt.output_flag[i_sl1l2] != STATOutputType_None || - vx_opt.output_flag[i_sal1l2] != STATOutputType_None) { + if(vx_opt.output_flag[i_sl1l2] != STATOutputType::None || + vx_opt.output_flag[i_sal1l2] != STATOutputType::None) { SL1L2Info sl1l2_mean; compute_sl1l2_mean(sl1l2_info, n_bin, sl1l2_mean); // Write out SL1L2 - if(vx_opt.output_flag[i_sl1l2] != STATOutputType_None && + if(vx_opt.output_flag[i_sl1l2] != STATOutputType::None && sl1l2_mean.scount > 0) { write_sl1l2_row(shc, sl1l2_mean, @@ -1597,7 +1597,7 @@ void do_cnt_sl1l2(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { } // Write out SAL1L2 - if(vx_opt.output_flag[i_sal1l2] != STATOutputType_None && + if(vx_opt.output_flag[i_sal1l2] != STATOutputType::None && sl1l2_mean.sacount > 0) { write_sal1l2_row(shc, sl1l2_mean, @@ -1608,7 +1608,7 @@ void do_cnt_sl1l2(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { } // Compute CNT climo CDF bin means - if(vx_opt.output_flag[i_cnt] != STATOutputType_None) { + if(vx_opt.output_flag[i_cnt] != STATOutputType::None) { CNTInfo cnt_mean; compute_cnt_mean(cnt_info, n_bin, cnt_mean); @@ -1726,14 +1726,14 @@ void do_pct(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { } // Compute the probabilistic counts and statistics - compute_pctinfo(pd, vx_opt.output_flag[i_pstd], pct_info[j]); + compute_pctinfo(pd, (STATOutputType::None!=vx_opt.output_flag[i_pstd]), pct_info[j]); // Check for no matched pairs to process if(pd.n_obs == 0) continue; // Write out PCT if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_pct] != STATOutputType_None) { + vx_opt.output_flag[i_pct] != STATOutputType::None) { write_pct_row(shc, pct_info[j], vx_opt.output_flag[i_pct], j, n_bin, stat_at, i_stat_row, @@ -1742,7 +1742,7 @@ void do_pct(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Write out PSTD if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_pstd] != STATOutputType_None) { + vx_opt.output_flag[i_pstd] != STATOutputType::None) { write_pstd_row(shc, pct_info[j], vx_opt.output_flag[i_pstd], j, n_bin, stat_at, i_stat_row, @@ -1751,7 +1751,7 @@ void do_pct(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Write out PJC if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_pjc] != STATOutputType_None) { + vx_opt.output_flag[i_pjc] != STATOutputType::None) { write_pjc_row(shc, pct_info[j], vx_opt.output_flag[i_pjc], j, n_bin, stat_at, i_stat_row, @@ -1760,7 +1760,7 @@ void do_pct(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Write out PRC if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_prc] != STATOutputType_None) { + vx_opt.output_flag[i_prc] != STATOutputType::None) { write_prc_row(shc, pct_info[j], vx_opt.output_flag[i_prc], j, n_bin, stat_at, i_stat_row, @@ -1769,7 +1769,7 @@ void do_pct(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { // Write out ECLV if((n_bin == 1 || vx_opt.cdf_info.write_bins) && - vx_opt.output_flag[i_eclv] != STATOutputType_None) { + vx_opt.output_flag[i_eclv] != STATOutputType::None) { write_eclv_row(shc, pct_info[j], vx_opt.eclv_points, vx_opt.output_flag[i_eclv], j, n_bin, stat_at, i_stat_row, @@ -1784,7 +1784,7 @@ void do_pct(const PointStatVxOpt &vx_opt, const PairDataPoint *pd_ptr) { compute_pct_mean(pct_info, n_bin, pct_mean); // Write out PSTD - if(vx_opt.output_flag[i_pstd] != STATOutputType_None) { + if(vx_opt.output_flag[i_pstd] != STATOutputType::None) { write_pstd_row(shc, pct_mean, vx_opt.output_flag[i_pstd], -1, n_bin, stat_at, i_stat_row, @@ -1811,7 +1811,7 @@ void do_hira_ens(int i_vx, const PairDataPoint *pd_ptr) { bool spfh_flag = conf_info.vx_opt[i_vx].vx_pd.fcst_info->is_specific_humidity() && conf_info.vx_opt[i_vx].vx_pd.obs_info->is_specific_humidity(); - shc.set_interp_mthd(InterpMthd_Nbrhd, + shc.set_interp_mthd(InterpMthd::Nbrhd, conf_info.vx_opt[i_vx].hira_info.shape); // Loop over the HiRA widths @@ -1847,7 +1847,7 @@ void do_hira_ens(int i_vx, const PairDataPoint *pd_ptr) { // Get the nearby forecast values get_interp_points(conf_info.vx_opt[i_vx].vx_pd.fcst_dpa, pd_ptr->x_na[j], pd_ptr->y_na[j], - InterpMthd_Nbrhd, conf_info.vx_opt[i_vx].hira_info.width[i], + InterpMthd::Nbrhd, conf_info.vx_opt[i_vx].hira_info.width[i], conf_info.vx_opt[i_vx].hira_info.shape, grid.wrap_lon(), conf_info.vx_opt[i_vx].hira_info.vld_thresh, spfh_flag, conf_info.vx_opt[i_vx].vx_pd.fcst_info->level().type(), @@ -1899,7 +1899,7 @@ void do_hira_ens(int i_vx, const PairDataPoint *pd_ptr) { hira_pd.compute_pair_vals(rng_ptr); // Write out the ECNT line - if(conf_info.vx_opt[i_vx].output_flag[i_ecnt] != STATOutputType_None) { + if(conf_info.vx_opt[i_vx].output_flag[i_ecnt] != STATOutputType::None) { // Compute ensemble statistics ECNTInfo ecnt_info; @@ -1912,7 +1912,7 @@ void do_hira_ens(int i_vx, const PairDataPoint *pd_ptr) { } // end if ECNT // Write out the ORANK line - if(conf_info.vx_opt[i_vx].output_flag[i_orank] != STATOutputType_None) { + if(conf_info.vx_opt[i_vx].output_flag[i_orank] != STATOutputType::None) { write_orank_row(shc, &hira_pd, conf_info.vx_opt[i_vx].output_flag[i_orank], @@ -1925,7 +1925,7 @@ void do_hira_ens(int i_vx, const PairDataPoint *pd_ptr) { } // end if ORANK // Write out the RPS line - if(conf_info.vx_opt[i_vx].output_flag[i_rps] != STATOutputType_None) { + if(conf_info.vx_opt[i_vx].output_flag[i_rps] != STATOutputType::None) { // Store ensemble RPS thresholds RPSInfo rps_info; @@ -1994,7 +1994,7 @@ void do_hira_prob(int i_vx, const PairDataPoint *pd_ptr) { bool precip_flag = conf_info.vx_opt[i_vx].vx_pd.fcst_info->is_precipitation() && conf_info.vx_opt[i_vx].vx_pd.obs_info->is_precipitation(); - shc.set_interp_mthd(InterpMthd_Nbrhd, + shc.set_interp_mthd(InterpMthd::Nbrhd, conf_info.vx_opt[i_vx].hira_info.shape); // Loop over categorical thresholds and HiRA widths @@ -2025,7 +2025,7 @@ void do_hira_prob(int i_vx, const PairDataPoint *pd_ptr) { f_cov = compute_interp(conf_info.vx_opt[i_vx].vx_pd.fcst_dpa, pd_ptr->x_na[k], pd_ptr->y_na[k], pd_ptr->o_na[k], pd_ptr->cmn_na[k], pd_ptr->csd_na[k], - InterpMthd_Nbrhd, conf_info.vx_opt[i_vx].hira_info.width[j], + InterpMthd::Nbrhd, conf_info.vx_opt[i_vx].hira_info.width[j], conf_info.vx_opt[i_vx].hira_info.shape, grid.wrap_lon(), conf_info.vx_opt[i_vx].hira_info.vld_thresh, spfh_flag, conf_info.vx_opt[i_vx].vx_pd.fcst_info->level().type(), @@ -2044,7 +2044,7 @@ void do_hira_prob(int i_vx, const PairDataPoint *pd_ptr) { cmn_cov = compute_interp(conf_info.vx_opt[i_vx].vx_pd.climo_mn_dpa, pd_ptr->x_na[k], pd_ptr->y_na[k], pd_ptr->o_na[k], pd_ptr->cmn_na[k], pd_ptr->csd_na[k], - InterpMthd_Nbrhd, conf_info.vx_opt[i_vx].hira_info.width[j], + InterpMthd::Nbrhd, conf_info.vx_opt[i_vx].hira_info.width[j], conf_info.vx_opt[i_vx].hira_info.shape, grid.wrap_lon(), conf_info.vx_opt[i_vx].hira_info.vld_thresh, spfh_flag, conf_info.vx_opt[i_vx].vx_pd.fcst_info->level().type(), @@ -2091,17 +2091,17 @@ void do_hira_prob(int i_vx, const PairDataPoint *pd_ptr) { } // Compute the probabilistic counts and statistics - compute_pctinfo(hira_pd, conf_info.vx_opt[i_vx].output_flag[i_pstd], + compute_pctinfo(hira_pd, (STATOutputType::None!=conf_info.vx_opt[i_vx].output_flag[i_pstd]), pct_info, &cmn_cov_na); // Set the contents of the output threshold columns shc.set_fcst_thresh (conf_info.vx_opt[i_vx].fcat_ta[i]); shc.set_obs_thresh (conf_info.vx_opt[i_vx].ocat_ta[i]); - shc.set_thresh_logic(SetLogic_None); + shc.set_thresh_logic(SetLogic::None); shc.set_cov_thresh (na_str); // Write out the MPR lines - if(conf_info.vx_opt[i_vx].output_flag[i_mpr] != STATOutputType_None) { + if(conf_info.vx_opt[i_vx].output_flag[i_mpr] != STATOutputType::None) { write_mpr_row(shc, &hira_pd, conf_info.vx_opt[i_vx].output_flag[i_mpr], stat_at, i_stat_row, @@ -2116,7 +2116,7 @@ void do_hira_prob(int i_vx, const PairDataPoint *pd_ptr) { shc.set_cov_thresh(conf_info.vx_opt[i_vx].hira_info.cov_ta); // Write out PCT - if(conf_info.vx_opt[i_vx].output_flag[i_pct] != STATOutputType_None) { + if(conf_info.vx_opt[i_vx].output_flag[i_pct] != STATOutputType::None) { write_pct_row(shc, pct_info, conf_info.vx_opt[i_vx].output_flag[i_pct],1, 1, stat_at, i_stat_row, @@ -2124,7 +2124,7 @@ void do_hira_prob(int i_vx, const PairDataPoint *pd_ptr) { } // Write out PSTD - if(conf_info.vx_opt[i_vx].output_flag[i_pstd] != STATOutputType_None) { + if(conf_info.vx_opt[i_vx].output_flag[i_pstd] != STATOutputType::None) { write_pstd_row(shc, pct_info, conf_info.vx_opt[i_vx].output_flag[i_pstd], 1, 1, stat_at, i_stat_row, @@ -2132,7 +2132,7 @@ void do_hira_prob(int i_vx, const PairDataPoint *pd_ptr) { } // Write out PJC - if(conf_info.vx_opt[i_vx].output_flag[i_pjc] != STATOutputType_None) { + if(conf_info.vx_opt[i_vx].output_flag[i_pjc] != STATOutputType::None) { write_pjc_row(shc, pct_info, conf_info.vx_opt[i_vx].output_flag[i_pjc], 1, 1, stat_at, i_stat_row, @@ -2140,7 +2140,7 @@ void do_hira_prob(int i_vx, const PairDataPoint *pd_ptr) { } // Write out PRC - if(conf_info.vx_opt[i_vx].output_flag[i_prc] != STATOutputType_None) { + if(conf_info.vx_opt[i_vx].output_flag[i_prc] != STATOutputType::None) { write_prc_row(shc, pct_info, conf_info.vx_opt[i_vx].output_flag[i_prc], 1, 1, stat_at, i_stat_row, @@ -2169,7 +2169,7 @@ void finish_txt_files() { for(i=0; iis_prob() && - (output_flag[i_mctc] != STATOutputType_None || - output_flag[i_mcts] != STATOutputType_None)) { + (output_flag[i_mctc] != STATOutputType::None || + output_flag[i_mcts] != STATOutputType::None)) { check_mctc_thresh(fcat_ta); check_mctc_thresh(ocat_ta); } @@ -1178,8 +1178,8 @@ void PointStatVxOpt::set_vx_pd(PointStatConfInfo *conf_info) { vx_pd.set_duplicate_flag(duplicate_flag); vx_pd.set_obs_summary(obs_summary); vx_pd.set_obs_perc_value(obs_perc); - if (output_flag[i_seeps_mpr] != STATOutputType_None - || output_flag[i_seeps] != STATOutputType_None) { + if (output_flag[i_seeps_mpr] != STATOutputType::None + || output_flag[i_seeps] != STATOutputType::None) { vx_pd.load_seeps_climo(); vx_pd.set_seeps_thresh(seeps_p1_thresh); } @@ -1233,7 +1233,7 @@ int PointStatVxOpt::n_txt_row(int i_txt_row) const { } // Check if this output line type is requested - if(output_flag[i_txt_row] == STATOutputType_None) return 0; + if(output_flag[i_txt_row] == STATOutputType::None) return 0; bool prob_flag = vx_pd.fcst_info->is_prob(); bool vect_flag = vx_pd.fcst_info->is_v_wind() && diff --git a/src/tools/core/point_stat/point_stat_conf_info.h b/src/tools/core/point_stat/point_stat_conf_info.h index 2385f66b84..befde20349 100644 --- a/src/tools/core/point_stat/point_stat_conf_info.h +++ b/src/tools/core/point_stat/point_stat_conf_info.h @@ -59,32 +59,32 @@ static const int n_txt = 22; // Text file type static const STATLineType txt_file_type[n_txt] = { - stat_fho, // 0 - stat_ctc, // 1 - stat_cts, // 2 - stat_mctc, // 3 - stat_mcts, // 4 - - stat_cnt, // 5 - stat_sl1l2, // 6 - stat_sal1l2, // 7 - stat_vl1l2, // 8 - stat_val1l2, // 9 - - stat_pct, // 10 - stat_pstd, // 11 - stat_pjc, // 12 - stat_prc, // 13 - stat_ecnt, // 14 - - stat_orank, // 15 - stat_rps, // 16 - stat_eclv, // 17 - stat_mpr, // 18 - stat_vcnt, // 19 - - stat_seeps_mpr, // 20 - stat_seeps // 21 + STATLineType::fho, // 0 + STATLineType::ctc, // 1 + STATLineType::cts, // 2 + STATLineType::mctc, // 3 + STATLineType::mcts, // 4 + + STATLineType::cnt, // 5 + STATLineType::sl1l2, // 6 + STATLineType::sal1l2, // 7 + STATLineType::vl1l2, // 8 + STATLineType::val1l2, // 9 + + STATLineType::pct, // 10 + STATLineType::pstd, // 11 + STATLineType::pjc, // 12 + STATLineType::prc, // 13 + STATLineType::ecnt, // 14 + + STATLineType::orank, // 15 + STATLineType::rps, // 16 + STATLineType::eclv, // 17 + STATLineType::mpr, // 18 + STATLineType::vcnt, // 19 + + STATLineType::seeps_mpr, // 20 + STATLineType::seeps // 21 }; //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/core/series_analysis/series_analysis.cc b/src/tools/core/series_analysis/series_analysis.cc index e7a05ad78a..ebbb43e27a 100644 --- a/src/tools/core/series_analysis/series_analysis.cc +++ b/src/tools/core/series_analysis/series_analysis.cc @@ -59,6 +59,7 @@ #include "vx_nc_util.h" #include "vx_regrid.h" #include "vx_log.h" +#include "enum_as_int.hpp" using namespace std; using namespace netCDF; @@ -262,35 +263,35 @@ void process_command_line(int argc, char **argv) { // - Forecast file list // - Observation file list if(conf_info.get_n_fcst() > 1) { - series_type = SeriesType_Fcst_Conf; + series_type = SeriesType::Fcst_Conf; n_series = conf_info.get_n_fcst(); mlog << Debug(1) << "Series defined by the \"fcst.field\" configuration entry " << "of length " << n_series << ".\n"; } else if(conf_info.get_n_obs() > 1) { - series_type = SeriesType_Obs_Conf; + series_type = SeriesType::Obs_Conf; n_series = conf_info.get_n_obs(); mlog << Debug(1) << "Series defined by the \"obs.field\" configuration entry " << "of length " << n_series << ".\n"; } else if(fcst_files.n() > 1) { - series_type = SeriesType_Fcst_Files; + series_type = SeriesType::Fcst_Files; n_series = fcst_files.n(); mlog << Debug(1) << "Series defined by the forecast file list of length " << n_series << ".\n"; } else if(obs_files.n() > 1) { - series_type = SeriesType_Obs_Files; + series_type = SeriesType::Obs_Files; n_series = obs_files.n(); mlog << Debug(1) << "Series defined by the observation file list of length " << n_series << ".\n"; } else { - series_type = SeriesType_Fcst_Conf; + series_type = SeriesType::Fcst_Conf; n_series = 1; mlog << Debug(1) << "The \"fcst.field\" and \"obs.field\" configuration entries " @@ -424,7 +425,7 @@ void get_series_data(int i_series, // Switch on the series type switch(series_type) { - case SeriesType_Fcst_Conf: + case SeriesType::Fcst_Conf: get_series_entry(i_series, fcst_info, fcst_files, ftype, found_fcst_files, fcst_dp, fcst_grid); if(conf_info.get_n_obs() == 1) { @@ -438,7 +439,7 @@ void get_series_data(int i_series, otype, found_obs_files, obs_dp, obs_grid); break; - case SeriesType_Obs_Conf: + case SeriesType::Obs_Conf: get_series_entry(i_series, obs_info, obs_files, otype, found_obs_files, obs_dp, obs_grid); if(conf_info.get_n_fcst() == 1) { @@ -452,7 +453,7 @@ void get_series_data(int i_series, ftype, found_fcst_files, fcst_dp, fcst_grid); break; - case SeriesType_Fcst_Files: + case SeriesType::Fcst_Files: found_fcst_files.set(i_series, fcst_files[i_series]); get_series_entry(i_series, fcst_info, fcst_files, ftype, found_fcst_files, fcst_dp, fcst_grid); @@ -470,7 +471,7 @@ void get_series_data(int i_series, otype, found_obs_files, obs_dp, obs_grid); break; - case SeriesType_Obs_Files: + case SeriesType::Obs_Files: found_obs_files.set(i_series, obs_files[i_series]); get_series_entry(i_series, obs_info, obs_files, otype, found_obs_files, obs_dp, obs_grid); @@ -491,7 +492,7 @@ void get_series_data(int i_series, default: mlog << Error << "\nget_series_data() -> " << "unexpected SeriesType value: " - << series_type << "\n\n"; + << enum_class_as_int(series_type) << "\n\n"; exit(1); } @@ -819,38 +820,38 @@ void process_scores() { // Compute contingency table counts and statistics if(!conf_info.fcst_info[0]->is_prob() && - (conf_info.output_stats[stat_fho].n() + - conf_info.output_stats[stat_ctc].n() + - conf_info.output_stats[stat_cts].n()) > 0) { + (conf_info.output_stats[STATLineType::fho].n() + + conf_info.output_stats[STATLineType::ctc].n() + + conf_info.output_stats[STATLineType::cts].n()) > 0) { do_cts(i_point+i, &pd_ptr[i]); } // Compute multi-category contingency table counts and statistics if(!conf_info.fcst_info[0]->is_prob() && - (conf_info.output_stats[stat_mctc].n() + - conf_info.output_stats[stat_mcts].n()) > 0) { + (conf_info.output_stats[STATLineType::mctc].n() + + conf_info.output_stats[STATLineType::mcts].n()) > 0) { do_mcts(i_point+i, &pd_ptr[i]); } // Compute continuous statistics if(!conf_info.fcst_info[0]->is_prob() && - conf_info.output_stats[stat_cnt].n() > 0) { + conf_info.output_stats[STATLineType::cnt].n() > 0) { do_cnt(i_point+i, &pd_ptr[i]); } // Compute partial sums if(!conf_info.fcst_info[0]->is_prob() && - (conf_info.output_stats[stat_sl1l2].n() > 0 || - conf_info.output_stats[stat_sal1l2].n() > 0)) { + (conf_info.output_stats[STATLineType::sl1l2].n() > 0 || + conf_info.output_stats[STATLineType::sal1l2].n() > 0)) { do_sl1l2(i_point+i, &pd_ptr[i]); } // Compute probabilistics counts and statistics if(conf_info.fcst_info[0]->is_prob() && - (conf_info.output_stats[stat_pct].n() + - conf_info.output_stats[stat_pstd].n() + - conf_info.output_stats[stat_pjc].n() + - conf_info.output_stats[stat_prc].n()) > 0) { + (conf_info.output_stats[STATLineType::pct].n() + + conf_info.output_stats[STATLineType::pstd].n() + + conf_info.output_stats[STATLineType::pjc].n() + + conf_info.output_stats[STATLineType::prc].n()) > 0) { do_pct(i_point+i, &pd_ptr[i]); } } // end for i @@ -930,7 +931,7 @@ void do_cts(int n, const PairDataPoint *pd_ptr) { // Compute the counts, stats, normal confidence intervals, and // bootstrap confidence intervals - if(conf_info.boot_interval == BootIntervalType_BCA) { + if(conf_info.boot_interval == BootIntervalType::BCA) { compute_cts_stats_ci_bca(rng_ptr, *pd_ptr, conf_info.n_boot_rep, cts_info, n_cts, true, @@ -947,20 +948,20 @@ void do_cts(int n, const PairDataPoint *pd_ptr) { for(i=0; iis_precipitation() && conf_info.obs_info[0]->is_precipitation()); - if(conf_info.boot_interval == BootIntervalType_BCA) { + if(conf_info.boot_interval == BootIntervalType::BCA) { compute_cnt_stats_ci_bca(rng_ptr, pd, precip_flag, conf_info.rank_corr_flag, conf_info.n_boot_rep, @@ -1074,8 +1075,8 @@ void do_cnt(int n, const PairDataPoint *pd_ptr) { } // Add statistic value for each possible CNT column - for(j=0; j 0; - bool do_cnt = (output_stats[stat_sl1l2].n() + - output_stats[stat_sal1l2].n() + - output_stats[stat_cnt].n()) > 0; + bool do_cat = (output_stats[STATLineType::fho].n() + + output_stats[STATLineType::ctc].n() + + output_stats[STATLineType::cts].n() + + output_stats[STATLineType::mctc].n() + + output_stats[STATLineType::mcts].n() + + output_stats[STATLineType::pct].n() + + output_stats[STATLineType::pstd].n() + + output_stats[STATLineType::pjc].n() + + output_stats[STATLineType::prc].n()) > 0; + bool do_cnt = (output_stats[STATLineType::sl1l2].n() + + output_stats[STATLineType::sal1l2].n() + + output_stats[STATLineType::cnt].n()) > 0; // Conf: fcst.field and obs.field fdict = conf.lookup_array(conf_key_fcst_field); @@ -384,8 +384,8 @@ void SeriesAnalysisConfInfo::process_config(GrdFileType ftype, // Verifying with multi-category contingency tables if(!fcst_info[0]->is_prob() && - (output_stats[stat_mctc].n() > 0 || - output_stats[stat_mcts].n() > 0)) { + (output_stats[STATLineType::mctc].n() > 0 || + output_stats[STATLineType::mcts].n() > 0)) { check_mctc_thresh(fcat_ta); check_mctc_thresh(ocat_ta); } diff --git a/src/tools/core/stat_analysis/aggr_stat_line.cc b/src/tools/core/stat_analysis/aggr_stat_line.cc index 3ca4cfcaff..7f3c16af10 100644 --- a/src/tools/core/stat_analysis/aggr_stat_line.cc +++ b/src/tools/core/stat_analysis/aggr_stat_line.cc @@ -783,18 +783,18 @@ void aggr_summary_lines(LineDataFile &f, STATAnalysisJob &job, // // Derive categorical statistics // - if(do_cts && line.type() == stat_fho) { + if(do_cts && line.type() == STATLineType::fho) { parse_fho_ctable(line, cts_info.cts); } - else if(do_cts && line.type() == stat_ctc) { + else if(do_cts && line.type() == STATLineType::ctc) { parse_ctc_ctable(line, cts_info.cts); } // // Derive continuous statistics // - else if(do_cnt && (line.type() == stat_sl1l2 || - line.type() == stat_sal1l2)) { + else if(do_cnt && (line.type() == STATLineType::sl1l2 || + line.type() == STATLineType::sal1l2)) { parse_sl1l2_line(line, sl1l2_info); compute_cntinfo(sl1l2_info, 0, cnt_info); } @@ -802,7 +802,7 @@ void aggr_summary_lines(LineDataFile &f, STATAnalysisJob &job, // // Derive vector continuous statistics // - else if(do_vcnt && line.type() == stat_vl1l2) { + else if(do_vcnt && line.type() == STATLineType::vl1l2) { parse_vl1l2_line(line, vl1l2_info); } @@ -819,20 +819,20 @@ void aggr_summary_lines(LineDataFile &f, STATAnalysisJob &job, // // Retrieve the column value, checking dervied stats // - if((line.type() == stat_fho || - line.type() == stat_ctc) && lty == stat_cts) { + if((line.type() == STATLineType::fho || + line.type() == STATLineType::ctc) && lty == STATLineType::cts) { v = cts_info.get_stat(req_col[i].c_str()); w = cts_info.cts.n(); } - else if(line.type() == stat_sl1l2 && lty == stat_cnt) { + else if(line.type() == STATLineType::sl1l2 && lty == STATLineType::cnt) { v = cnt_info.get_stat(req_col[i].c_str()); w = cnt_info.n; } - else if(line.type() == stat_sal1l2 && lty == stat_cnt) { + else if(line.type() == STATLineType::sal1l2 && lty == STATLineType::cnt) { v = cnt_info.get_stat(req_col[i].c_str()); w = cnt_info.n; } - else if(line.type() == stat_vl1l2 && lty == stat_vcnt) { + else if(line.type() == STATLineType::vl1l2 && lty == STATLineType::vcnt) { v = vl1l2_info.get_stat(req_col[i].c_str()); w = vl1l2_info.vcount; } @@ -923,15 +923,15 @@ void aggr_ctc_lines(LineDataFile &f, STATAnalysisJob &job, // switch(line.type()) { - case(stat_fho): + case STATLineType::fho: parse_fho_ctable(line, cur.cts); break; - case(stat_ctc): + case STATLineType::ctc: parse_ctc_ctable(line, cur.cts); break; - case(stat_nbrctc): + case STATLineType::nbrctc: parse_nbrctc_ctable(line, cur.cts); break; @@ -1126,7 +1126,7 @@ void aggr_mctc_lines(LineDataFile &f, STATAnalysisJob &job, // // Check for expected line type // - if(line.type() != stat_mctc) { + if(line.type() != STATLineType::mctc) { mlog << Error << "\naggr_mctc_lines() -> " << "should only encounter multi-category contingency table count " << "(MCTC) line types.\n" @@ -1306,7 +1306,7 @@ void aggr_pct_lines(LineDataFile &f, STATAnalysisJob &job, // // Check for expected line type // - if(line.type() != stat_pct) { + if(line.type() != STATLineType::pct) { mlog << Error << "\naggr_pct_lines() -> " << "should only encounter probability contingency table (PCT) " << "line types.\n" @@ -1523,23 +1523,23 @@ void aggr_psum_lines(LineDataFile &f, STATAnalysisJob &job, // switch(line.type()) { - case(stat_sl1l2): + case STATLineType::sl1l2: parse_sl1l2_line(line, cur_sl1l2); break; - case(stat_sal1l2): + case STATLineType::sal1l2: parse_sal1l2_line(line, cur_sl1l2); break; - case(stat_vl1l2): + case STATLineType::vl1l2: parse_vl1l2_line(line, cur_vl1l2); break; - case(stat_val1l2): + case STATLineType::val1l2: parse_val1l2_line(line, cur_vl1l2); break; - case(stat_nbrcnt): + case STATLineType::nbrcnt: parse_nbrcnt_line(line, cur_nbrcnt); break; @@ -1584,7 +1584,7 @@ void aggr_psum_lines(LineDataFile &f, STATAnalysisJob &job, // // Keep track of scores for each time step for VIF // - if(line.type() == stat_sl1l2 && job.vif_flag) { + if(line.type() == STATLineType::sl1l2 && job.vif_flag) { // // Cannot compute VIF when the times are not unique @@ -1701,7 +1701,7 @@ void aggr_grad_lines(LineDataFile &f, STATAnalysisJob &job, job.dump_stat_line(line); - if(line.type() != stat_grad) { + if(line.type() != STATLineType::grad) { mlog << Error << "\naggr_grad_lines() -> " << "should only encounter gradient (GRAD) line types.\n" << "ERROR occurred on STAT line:\n" << line << "\n\n"; @@ -1809,13 +1809,13 @@ void aggr_wind_lines(LineDataFile &f, STATAnalysisJob &job, // switch(line.type()) { - case(stat_vl1l2): + case STATLineType::vl1l2: parse_vl1l2_line(line, cur); convert_u_v_to_unit(cur.uf_bar, cur.vf_bar, uf, vf); convert_u_v_to_unit(cur.uo_bar, cur.vo_bar, uo, vo); break; - case(stat_val1l2): + case STATLineType::val1l2: parse_val1l2_line(line, cur); convert_u_v_to_unit(cur.ufa_bar, cur.vfa_bar, uf, vf); convert_u_v_to_unit(cur.uoa_bar, cur.voa_bar, uo, vo); @@ -2228,7 +2228,7 @@ void aggr_mpr_lines(LineDataFile &f, STATAnalysisJob &job, // // Check for expected line type // - if(line.type() != stat_mpr) { + if(line.type() != STATLineType::mpr) { mlog << Error << "\naggr_mpr_lines() -> " << "should only encounter matched pair (MPR) line types.\n" << "ERROR occurred on STAT line:\n" << line << "\n\n"; @@ -2351,7 +2351,7 @@ void aggr_isc_lines(LineDataFile &ldf, STATAnalysisJob &job, job.dump_stat_line(line); - if(line.type() != stat_isc) { + if(line.type() != STATLineType::isc) { mlog << Error << "\naggr_isc_lines() -> " << "should only encounter intensity-scale " << "(ISC) line types.\n" @@ -2609,7 +2609,7 @@ void aggr_ecnt_lines(LineDataFile &f, STATAnalysisJob &job, job.dump_stat_line(line); - if(line.type() != stat_ecnt) { + if(line.type() != STATLineType::ecnt) { mlog << Error << "\naggr_ecnt_lines() -> " << "should only encounter ensemble continuous statistics " << "(ECNT) line types.\n" @@ -2760,7 +2760,7 @@ void aggr_rps_lines(LineDataFile &f, STATAnalysisJob &job, // // Check for expected line type // - if(line.type() != stat_rps) { + if(line.type() != STATLineType::rps) { mlog << Error << "\naggr_rps_lines() -> " << "should only encounter ranked probability score " << "(RPS) line types.\n" @@ -2852,7 +2852,7 @@ void aggr_rhist_lines(LineDataFile &f, STATAnalysisJob &job, job.dump_stat_line(line); - if(line.type() != stat_rhist) { + if(line.type() != STATLineType::rhist) { mlog << Error << "\naggr_rhist_lines() -> " << "should only encounter ranked histogram " << "(RHIST) line types.\n" @@ -2942,7 +2942,7 @@ void aggr_phist_lines(LineDataFile &f, STATAnalysisJob &job, job.dump_stat_line(line); - if(line.type() != stat_phist) { + if(line.type() != STATLineType::phist) { mlog << Error << "\naggr_phist_lines() -> " << "should only encounter probability integral " << "transform histogram (PHIST) line types.\n" @@ -3033,7 +3033,7 @@ void aggr_relp_lines(LineDataFile &f, STATAnalysisJob &job, job.dump_stat_line(line); - if(line.type() != stat_relp) { + if(line.type() != STATLineType::relp) { mlog << Error << "\naggr_relp_lines() -> " << "should only encounter relative position (RELP) " << "line types.\n" @@ -3125,7 +3125,7 @@ void aggr_orank_lines(LineDataFile &f, STATAnalysisJob &job, job.dump_stat_line(line); - if(line.type() != stat_orank) { + if(line.type() != STATLineType::orank) { mlog << Error << "\naggr_orank_lines() -> " << "should only encounter observation rank " << "(ORANK) line types.\n" @@ -3314,7 +3314,7 @@ void aggr_ssvar_lines(LineDataFile &f, STATAnalysisJob &job, job.dump_stat_line(line); - if(line.type() != stat_ssvar) { + if(line.type() != STATLineType::ssvar) { mlog << Error << "\naggr_ssvar_lines() -> " << "should only encounter spread-skill variance " << "(SSVAR) line types.\n" @@ -3419,7 +3419,7 @@ void aggr_seeps_lines(LineDataFile &f, STATAnalysisJob &job, job.dump_stat_line(line); - if(line.type() != stat_seeps) { + if(line.type() != STATLineType::seeps) { mlog << Error << "\naggr_seeps_lines() -> " << "should only encounter SEEPS line types.\n" << "ERROR occurred on STAT line:\n" << line << "\n\n"; @@ -3503,7 +3503,7 @@ void aggr_seeps_mpr_lines(LineDataFile &f, STATAnalysisJob &job, job.dump_stat_line(line); - if(line.type() != stat_seeps_mpr) { + if(line.type() != STATLineType::seeps_mpr) { mlog << Error << "\naggr_seeps_mpr_lines() -> " << "should only encounter SEEPS_MPR line types.\n" << "ERROR occurred on STAT line:\n" << line << "\n\n"; @@ -3769,7 +3769,7 @@ void aggr_ss_index(LineDataFile &f, STATAnalysisJob &job, // and set the type to aggregation // fcst_term = job; - fcst_term.set_job_type(stat_job_aggr); + fcst_term.set_job_type(STATJobType::aggr); // // line_type @@ -3778,7 +3778,7 @@ void aggr_ss_index(LineDataFile &f, STATAnalysisJob &job, fcst_term.line_type.set(job.line_type[i]); STATLineType lt = string_to_statlinetype(job.line_type[i].c_str()); - if(lt != stat_sl1l2 && lt != stat_ctc) { + if(lt != STATLineType::sl1l2 && lt != STATLineType::ctc) { mlog << Error << "\naggr_ss_index() -> " << "a skill score index can only be computed using " << "statistics derived from SL1L2 or CTC line types." @@ -3927,7 +3927,7 @@ void mpr_to_cts(STATAnalysisJob &job, const AggrMPRInfo &info, // bootstrap confidence intervals // cts_info_ptr = &cts_info; - if(job.boot_interval == boot_bca_flag) { + if(job.boot_interval == BootIntervalType::BCA) { compute_cts_stats_ci_bca(rng_ptr, info.pd, job.n_boot_rep, cts_info_ptr, 1, 1, @@ -3997,7 +3997,7 @@ void mpr_to_mcts(STATAnalysisJob &job, const AggrMPRInfo &info, // Compute the counts, stats, normal confidence intervals, and // bootstrap confidence intervals // - if(job.boot_interval == boot_bca_flag) { + if(job.boot_interval == BootIntervalType::BCA) { compute_mcts_stats_ci_bca(rng_ptr, info.pd, job.n_boot_rep, mcts_info, 1, @@ -4064,14 +4064,12 @@ void mpr_to_cnt(STATAnalysisJob &job, const AggrMPRInfo &info, // Compute the stats, normal confidence intervals, and // bootstrap confidence intervals // - if(job.boot_interval == boot_bca_flag) { - + if(job.boot_interval == BootIntervalType::BCA) { compute_cnt_stats_ci_bca(rng_ptr, pd_thr, precip_flag, job.rank_corr_flag, job.n_boot_rep, cnt_info, tmp_dir); } else { - compute_cnt_stats_ci_perc(rng_ptr, pd_thr, precip_flag, job.rank_corr_flag, job.n_boot_rep, job.boot_rep_prop, cnt_info, tmp_dir); diff --git a/src/tools/core/stat_analysis/skill_score_index_job.cc b/src/tools/core/stat_analysis/skill_score_index_job.cc index c82d71763d..9651e50a0d 100644 --- a/src/tools/core/stat_analysis/skill_score_index_job.cc +++ b/src/tools/core/stat_analysis/skill_score_index_job.cc @@ -187,12 +187,12 @@ bool SSIndexJobInfo::add(STATLine &line) { n_fcst_lines.inc(i, 1); // Aggregate SL1L2 - if(job_lt[i] == stat_sl1l2) { + if(job_lt[i] == STATLineType::sl1l2) { parse_sl1l2_line(line, sl1l2); fcst_sl1l2[i] += sl1l2; } // Aggregate CTC - else if(job_lt[i] == stat_ctc) { + else if(job_lt[i] == STATLineType::ctc) { parse_ctc_ctable(line, ctc); fcst_cts[i].cts += ctc; } @@ -204,12 +204,12 @@ bool SSIndexJobInfo::add(STATLine &line) { n_ref_lines.inc(i, 1); // Aggregate SL1L2 - if(job_lt[i] == stat_sl1l2) { + if(job_lt[i] == STATLineType::sl1l2) { parse_sl1l2_line(line, sl1l2); ref_sl1l2[i] += sl1l2; } // Aggregate CTC - else if(job_lt[i] == stat_ctc) { + else if(job_lt[i] == STATLineType::ctc) { parse_ctc_ctable(line, ctc); ref_cts[i].cts += ctc; } @@ -244,14 +244,14 @@ SSIDXData SSIndexJobInfo::compute_ss_index() { for(i=0, n_vld=0, n_diff=0, ss_sum=weight_sum=0.0; i> line) { // Continue if the line is not a valid STAT line. // - if(line.type() == no_stat_line_type) continue; + if(line.type() == STATLineType::none) continue; // // Pass header lines through to the output @@ -677,14 +677,14 @@ void process_job(const char * jobstring, int n_job) { // // Special processing for the GO Index and CBS Index jobs. // - if(job.job_type == stat_job_go_index || - job.job_type == stat_job_cbs_index) { + if(job.job_type == STATJobType::go_index || + job.job_type == STATJobType::cbs_index) { MetConfig ss_index_conf; STATAnalysisJob ss_index_job; ConcatString config_file = - (job.job_type == stat_job_go_index ? + (job.job_type == STATJobType::go_index ? replace_path(go_index_config_file) : replace_path(cbs_index_config_file)); diff --git a/src/tools/core/stat_analysis/stat_analysis_job.cc b/src/tools/core/stat_analysis/stat_analysis_job.cc index da0807f2ec..5c22c39d5a 100644 --- a/src/tools/core/stat_analysis/stat_analysis_job.cc +++ b/src/tools/core/stat_analysis/stat_analysis_job.cc @@ -201,13 +201,13 @@ void do_job(const ConcatString &jobstring, STATAnalysisJob &job, // Print warning for by_column option // if(job.by_column.n() > 0 && - job.job_type != stat_job_summary && - job.job_type != stat_job_aggr && - job.job_type != stat_job_aggr_stat && - job.job_type != stat_job_ramp && - job.job_type != stat_job_go_index && - job.job_type != stat_job_cbs_index && - job.job_type != stat_job_ss_index) { + job.job_type != STATJobType::summary && + job.job_type != STATJobType::aggr && + job.job_type != STATJobType::aggr_stat && + job.job_type != STATJobType::ramp && + job.job_type != STATJobType::go_index && + job.job_type != STATJobType::cbs_index && + job.job_type != STATJobType::ss_index) { mlog << Warning << "\nThe -by option is ignored for the \"" << statjobtype_to_string(job.job_type) << "\" job type.\n\n"; } @@ -216,8 +216,8 @@ void do_job(const ConcatString &jobstring, STATAnalysisJob &job, // Set up the random number generator and seed value // for the summary and aggregate stat jobs. // - if(job.job_type == stat_job_summary || - job.job_type == stat_job_aggr_stat) { + if(job.job_type == STATJobType::summary || + job.job_type == STATJobType::aggr_stat) { rng_set(rng_ptr, job.boot_rng, job.boot_seed); } @@ -226,29 +226,29 @@ void do_job(const ConcatString &jobstring, STATAnalysisJob &job, // switch(job.job_type) { - case(stat_job_filter): + case STATJobType::filter: do_job_filter(jobstring, f, job, n_in, n_out, sa_out); break; - case(stat_job_summary): + case STATJobType::summary: do_job_summary(jobstring, f, job, n_in, n_out, sa_out, rng_ptr); break; - case(stat_job_aggr): + case STATJobType::aggr: do_job_aggr(jobstring, f, job, n_in, n_out, sa_out); break; - case(stat_job_aggr_stat): + case STATJobType::aggr_stat: do_job_aggr_stat(jobstring, f, job, n_in, n_out, sa_out, tmp_dir, rng_ptr); break; - case(stat_job_go_index): - case(stat_job_cbs_index): - case(stat_job_ss_index): + case STATJobType::go_index: + case STATJobType::cbs_index: + case STATJobType::ss_index: do_job_ss_index(jobstring, f, job, n_in, n_out, sa_out); break; - case(stat_job_ramp): + case STATJobType::ramp: do_job_ramp(jobstring, f, job, n_in, n_out, sa_out); break; @@ -444,16 +444,16 @@ void do_job_aggr(const ConcatString &jobstring, LineDataFile &f, // // Check that a valid line type has been selected // - if(lt != stat_fho && lt != stat_ctc && - lt != stat_mctc && lt != stat_sl1l2 && - lt != stat_sal1l2 && lt != stat_vl1l2 && - lt != stat_val1l2 && lt != stat_pct && - lt != stat_nbrctc && lt != stat_nbrcnt && - lt != stat_grad && lt != stat_ecnt && - lt != stat_rps && lt != stat_rhist && - lt != stat_phist && lt != stat_relp && - lt != stat_ssvar && lt != stat_isc && - lt != stat_seeps) { + if(lt != STATLineType::fho && lt != STATLineType::ctc && + lt != STATLineType::mctc && lt != STATLineType::sl1l2 && + lt != STATLineType::sal1l2 && lt != STATLineType::vl1l2 && + lt != STATLineType::val1l2 && lt != STATLineType::pct && + lt != STATLineType::nbrctc && lt != STATLineType::nbrcnt && + lt != STATLineType::grad && lt != STATLineType::ecnt && + lt != STATLineType::rps && lt != STATLineType::rhist && + lt != STATLineType::phist && lt != STATLineType::relp && + lt != STATLineType::ssvar && lt != STATLineType::isc && + lt != STATLineType::seeps) { mlog << Error << "\ndo_job_aggr() -> " << "the \"-line_type\" option must be set to one of:\n" << "\tFHO, CTC, MCTC,\n" @@ -472,9 +472,9 @@ void do_job_aggr(const ConcatString &jobstring, LineDataFile &f, // Sum up the contingency table type lines: // FHO, CTC, NBRCTC // - if(lt == stat_fho || - lt == stat_ctc || - lt == stat_nbrctc) { + if(lt == STATLineType::fho || + lt == STATLineType::ctc || + lt == STATLineType::nbrctc) { aggr_ctc_lines(f, job, ctc_map, n_in, n_out); write_job_aggr_ctc(job, lt, ctc_map, out_at); } @@ -483,7 +483,7 @@ void do_job_aggr(const ConcatString &jobstring, LineDataFile &f, // Sum up the multi-category contingency table type lines: // MCTC // - else if(lt == stat_mctc) { + else if(lt == STATLineType::mctc) { aggr_mctc_lines(f, job, mctc_map, n_in, n_out); write_job_aggr_mctc(job, lt, mctc_map, out_at); } @@ -492,7 +492,7 @@ void do_job_aggr(const ConcatString &jobstring, LineDataFile &f, // Sum up the Nx2 contingency table lines: // PCT // - else if(lt == stat_pct) { + else if(lt == STATLineType::pct) { aggr_pct_lines(f, job, pct_map, n_in, n_out); write_job_aggr_pct(job, lt, pct_map, out_at); } @@ -501,11 +501,11 @@ void do_job_aggr(const ConcatString &jobstring, LineDataFile &f, // Sum the partial sum line types: // SL1L2, SAL1L2, VL1L2, VAL1L2, NBRCNT // - else if(lt == stat_sl1l2 || - lt == stat_sal1l2 || - lt == stat_vl1l2 || - lt == stat_val1l2 || - lt == stat_nbrcnt) { + else if(lt == STATLineType::sl1l2 || + lt == STATLineType::sal1l2 || + lt == STATLineType::vl1l2 || + lt == STATLineType::val1l2 || + lt == STATLineType::nbrcnt) { aggr_psum_lines(f, job, psum_map, n_in, n_out); write_job_aggr_psum(job, lt, psum_map, out_at); } @@ -514,7 +514,7 @@ void do_job_aggr(const ConcatString &jobstring, LineDataFile &f, // Sum the gradient line type: // GRAD // - else if(lt == stat_grad) { + else if(lt == STATLineType::grad) { aggr_grad_lines(f, job, grad_map, n_in, n_out); write_job_aggr_grad(job, lt, grad_map, out_at); } @@ -522,7 +522,7 @@ void do_job_aggr(const ConcatString &jobstring, LineDataFile &f, // // Sum the ISC line types // - else if(lt == stat_isc) { + else if(lt == STATLineType::isc) { aggr_isc_lines(f, job, isc_map, n_in, n_out); write_job_aggr_isc(job, lt, isc_map, out_at); } @@ -530,7 +530,7 @@ void do_job_aggr(const ConcatString &jobstring, LineDataFile &f, // // Sum the ECNT line types // - else if(lt == stat_ecnt) { + else if(lt == STATLineType::ecnt) { aggr_ecnt_lines(f, job, ens_map, n_in, n_out); write_job_aggr_ecnt(job, lt, ens_map, out_at); } @@ -538,7 +538,7 @@ void do_job_aggr(const ConcatString &jobstring, LineDataFile &f, // // Sum the RPS line types // - else if(lt == stat_rps) { + else if(lt == STATLineType::rps) { aggr_rps_lines(f, job, rps_map, n_in, n_out); write_job_aggr_rps(job, lt, rps_map, out_at); } @@ -546,7 +546,7 @@ void do_job_aggr(const ConcatString &jobstring, LineDataFile &f, // // Sum the RHIST line types // - else if(lt == stat_rhist) { + else if(lt == STATLineType::rhist) { aggr_rhist_lines(f, job, ens_map, n_in, n_out); write_job_aggr_rhist(job, lt, ens_map, out_at); } @@ -554,7 +554,7 @@ void do_job_aggr(const ConcatString &jobstring, LineDataFile &f, // // Sum the PHIST line types // - else if(lt == stat_phist) { + else if(lt == STATLineType::phist) { aggr_phist_lines(f, job, ens_map, n_in, n_out); write_job_aggr_phist(job, lt, ens_map, out_at); } @@ -562,7 +562,7 @@ void do_job_aggr(const ConcatString &jobstring, LineDataFile &f, // // Sum the RELP line types // - else if(lt == stat_relp) { + else if(lt == STATLineType::relp) { aggr_relp_lines(f, job, ens_map, n_in, n_out); write_job_aggr_relp(job, lt, ens_map, out_at); } @@ -570,7 +570,7 @@ void do_job_aggr(const ConcatString &jobstring, LineDataFile &f, // // Sum the SSVAR line types // - else if(lt == stat_ssvar) { + else if(lt == STATLineType::ssvar) { aggr_ssvar_lines(f, job, ssvar_map, n_in, n_out); write_job_aggr_ssvar(job, lt, ssvar_map, out_at); } @@ -578,7 +578,7 @@ void do_job_aggr(const ConcatString &jobstring, LineDataFile &f, // // Sum the SEEPS line types // - else if(lt == stat_seeps) { + else if(lt == STATLineType::seeps) { aggr_seeps_lines(f, job, seeps_map, n_in, n_out); write_job_aggr_seeps(job, lt, seeps_map, out_at); } @@ -679,12 +679,12 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, // FHO, CTC -> CTS, ECLV // NBRCTC -> NBRCTS // - if(((in_lt == stat_fho || - in_lt == stat_ctc) && - (has_line_type(out_lt, stat_cts) || - has_line_type(out_lt, stat_eclv))) || - (in_lt == stat_nbrctc && - has_line_type(out_lt, stat_nbrcts))) { + if(((in_lt == STATLineType::fho || + in_lt == STATLineType::ctc) && + (has_line_type(out_lt, STATLineType::cts) || + has_line_type(out_lt, STATLineType::eclv))) || + (in_lt == STATLineType::nbrctc && + has_line_type(out_lt, STATLineType::nbrcts))) { aggr_ctc_lines(f, job, ctc_map, n_in, n_out); for(it=out_lt.begin(); it!=out_lt.end(); it++) { write_job_aggr_ctc(job, *it, ctc_map, out_at); @@ -696,8 +696,8 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, // Sum up the multi-category contingency table type lines: // MCTC -> MCTS // - else if(in_lt == stat_mctc && - has_line_type(out_lt, stat_mcts)) { + else if(in_lt == STATLineType::mctc && + has_line_type(out_lt, STATLineType::mcts)) { aggr_mctc_lines(f, job, mctc_map, n_in, n_out); for(it=out_lt.begin(); it!=out_lt.end(); it++) { write_job_aggr_mctc(job, *it, mctc_map, out_at); @@ -709,11 +709,11 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, // Sum up the Nx2 contingency table lines: // PCT -> PSTD, PJC, PRC, ECLV // - else if(in_lt == stat_pct && - (has_line_type(out_lt, stat_pstd) || - has_line_type(out_lt, stat_pjc) || - has_line_type(out_lt, stat_prc) || - has_line_type(out_lt, stat_eclv))) { + else if(in_lt == STATLineType::pct && + (has_line_type(out_lt, STATLineType::pstd) || + has_line_type(out_lt, STATLineType::pjc) || + has_line_type(out_lt, STATLineType::prc) || + has_line_type(out_lt, STATLineType::eclv))) { aggr_pct_lines(f, job, pct_map, n_in, n_out); for(it=out_lt.begin(); it!=out_lt.end(); it++) { write_job_aggr_pct(job, *it, pct_map, out_at); @@ -726,9 +726,9 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, // SL1L2, SAL1L2 -> CNT // NBRCTC -> NBRCNT // - else if((in_lt == stat_sl1l2 || - in_lt == stat_sal1l2) && - has_line_type(out_lt, stat_cnt)) { + else if((in_lt == STATLineType::sl1l2 || + in_lt == STATLineType::sal1l2) && + has_line_type(out_lt, STATLineType::cnt)) { aggr_psum_lines(f, job, psum_map, n_in, n_out); for(it=out_lt.begin(); it!=out_lt.end(); it++) { write_job_aggr_psum(job, *it, psum_map, out_at); @@ -740,9 +740,9 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, // Sum the vector partial sum line types: // VL1L2, VAL1L2 -> VCNT // - else if((in_lt == stat_vl1l2 || - in_lt == stat_val1l2) && - has_line_type(out_lt, stat_vcnt)) { + else if((in_lt == STATLineType::vl1l2 || + in_lt == STATLineType::val1l2) && + has_line_type(out_lt, STATLineType::vcnt)) { aggr_psum_lines(f, job, psum_map, n_in, n_out); for(it=out_lt.begin(); it!=out_lt.end(); it++) { write_job_aggr_psum(job, *it, psum_map, out_at); @@ -754,9 +754,9 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, // Sum the vector partial sum line types: // VL1L2, VAL1L2 -> WDIR // - else if((in_lt == stat_vl1l2 || - in_lt == stat_val1l2) && - has_line_type(out_lt, stat_wdir)) { + else if((in_lt == STATLineType::vl1l2 || + in_lt == STATLineType::val1l2) && + has_line_type(out_lt, STATLineType::wdir)) { aggr_wind_lines(f, job, wind_map, n_in, n_out); write_job_aggr_wind(job, in_lt, wind_map, out_at); if(!job.stat_out) write_table(out_at, sa_out); @@ -766,10 +766,10 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, // Sum the UGRD and VGRD matched pair lines: // MPR -> WDIR // - else if(in_lt == stat_mpr && - (has_line_type(out_lt, stat_wdir) || - has_line_type(out_lt, stat_vl1l2) || - has_line_type(out_lt, stat_vcnt))) { + else if(in_lt == STATLineType::mpr && + (has_line_type(out_lt, STATLineType::wdir) || + has_line_type(out_lt, STATLineType::vl1l2) || + has_line_type(out_lt, STATLineType::vcnt))) { mlog << Debug(4) << "do_job_aggr_stat() -> " << "For MPR wind aggregation, searching for UGRD and VGRD MPR lines.\n"; @@ -780,7 +780,7 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, aggr_mpr_wind_lines(f, job, wind_map, n_in, n_out); for(it=out_lt.begin(); it!=out_lt.end(); it++) { - if(*it == stat_wdir) { + if(*it == STATLineType::wdir) { write_job_aggr_wind(job, in_lt, wind_map, out_at); if(!job.stat_out) write_table(out_at, sa_out); } @@ -795,18 +795,18 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, // Sum the observation rank line types: // ORANK -> ECNT, RPS, RHIST, PHIST, RELP, SSVAR // - else if(in_lt == stat_orank && - (has_line_type(out_lt, stat_ecnt) || - has_line_type(out_lt, stat_rps) || - has_line_type(out_lt, stat_rhist) || - has_line_type(out_lt, stat_phist) || - has_line_type(out_lt, stat_relp) || - has_line_type(out_lt, stat_ssvar))) { + else if(in_lt == STATLineType::orank && + (has_line_type(out_lt, STATLineType::ecnt) || + has_line_type(out_lt, STATLineType::rps) || + has_line_type(out_lt, STATLineType::rhist) || + has_line_type(out_lt, STATLineType::phist) || + has_line_type(out_lt, STATLineType::relp) || + has_line_type(out_lt, STATLineType::ssvar))) { // // Check forecast thresholds for RPS // - if(has_line_type(out_lt, stat_rps)) { + if(has_line_type(out_lt, STATLineType::rps)) { if(job.out_fcst_thresh.n() == 0) { mlog << Error << "\ndo_job_aggr_stat() -> " @@ -828,8 +828,8 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, // Sum the SEEPS_MPR lines: // SEEPS_MPR -> SEEPS // - else if(in_lt == stat_seeps_mpr && - has_line_type(out_lt, stat_seeps)) { + else if(in_lt == STATLineType::seeps_mpr && + has_line_type(out_lt, STATLineType::seeps)) { aggr_seeps_mpr_lines(f, job, seeps_mpr_map, n_in, n_out); for(it=out_lt.begin(); it!=out_lt.end(); it++) { @@ -844,27 +844,27 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, // MPR -> FHO, CTC, CTS, MCTC, MCTS, CNT, // SL1L2, SAL1L2, PCT, PSTD, PJC, PRC, ECLV // - else if(in_lt == stat_mpr && - (has_line_type(out_lt, stat_fho) || - has_line_type(out_lt, stat_ctc) || - has_line_type(out_lt, stat_cts) || - has_line_type(out_lt, stat_mctc) || - has_line_type(out_lt, stat_mcts) || - has_line_type(out_lt, stat_cnt) || - has_line_type(out_lt, stat_sl1l2) || - has_line_type(out_lt, stat_sal1l2) || - has_line_type(out_lt, stat_pct) || - has_line_type(out_lt, stat_pstd) || - has_line_type(out_lt, stat_pjc) || - has_line_type(out_lt, stat_prc) || - has_line_type(out_lt, stat_eclv))) { + else if(in_lt == STATLineType::mpr && + (has_line_type(out_lt, STATLineType::fho) || + has_line_type(out_lt, STATLineType::ctc) || + has_line_type(out_lt, STATLineType::cts) || + has_line_type(out_lt, STATLineType::mctc) || + has_line_type(out_lt, STATLineType::mcts) || + has_line_type(out_lt, STATLineType::cnt) || + has_line_type(out_lt, STATLineType::sl1l2) || + has_line_type(out_lt, STATLineType::sal1l2) || + has_line_type(out_lt, STATLineType::pct) || + has_line_type(out_lt, STATLineType::pstd) || + has_line_type(out_lt, STATLineType::pjc) || + has_line_type(out_lt, STATLineType::prc) || + has_line_type(out_lt, STATLineType::eclv))) { // // Check output thresholds for continuous line types // - if(has_line_type(out_lt, stat_cnt) || - has_line_type(out_lt, stat_sl1l2) || - has_line_type(out_lt, stat_sal1l2)) { + if(has_line_type(out_lt, STATLineType::cnt) || + has_line_type(out_lt, STATLineType::sl1l2) || + has_line_type(out_lt, STATLineType::sal1l2)) { if(job.out_fcst_thresh.n() != job.out_obs_thresh.n()) { mlog << Error << "\ndo_job_aggr_stat() -> " @@ -885,10 +885,10 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, // // Check output threshold values for 2x2 contingency table // - if(has_line_type(out_lt, stat_fho) || - has_line_type(out_lt, stat_ctc) || - has_line_type(out_lt, stat_cts) || - has_line_type(out_lt, stat_eclv)) { + if(has_line_type(out_lt, STATLineType::fho) || + has_line_type(out_lt, STATLineType::ctc) || + has_line_type(out_lt, STATLineType::cts) || + has_line_type(out_lt, STATLineType::eclv)) { if(job.out_fcst_thresh.n() == 0 || job.out_obs_thresh.n() == 0 || @@ -906,8 +906,8 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, // // Check output threshold values for NxN contingency table // - if(has_line_type(out_lt, stat_mctc) || - has_line_type(out_lt, stat_mcts)) { + if(has_line_type(out_lt, STATLineType::mctc) || + has_line_type(out_lt, STATLineType::mcts)) { if(job.out_fcst_thresh.n() <= 1 || job.out_fcst_thresh.n() != job.out_obs_thresh.n()) { @@ -943,10 +943,10 @@ void do_job_aggr_stat(const ConcatString &jobstring, LineDataFile &f, // // Check for output threshold values // - if(has_line_type(out_lt, stat_pct) || - has_line_type(out_lt, stat_pstd) || - has_line_type(out_lt, stat_pjc) || - has_line_type(out_lt, stat_prc)) { + if(has_line_type(out_lt, STATLineType::pct) || + has_line_type(out_lt, STATLineType::pstd) || + has_line_type(out_lt, STATLineType::pjc) || + has_line_type(out_lt, STATLineType::prc)) { if(job.out_obs_thresh.n() != 1) { mlog << Error << "\ndo_job_aggr_stat() -> " @@ -1130,7 +1130,7 @@ void write_job_summary(STATAnalysisJob &job, // // Compute a bootstrap confidence interval for the mean. // - if(job.boot_interval == boot_bca_flag) { + if(job.boot_interval == BootIntervalType::BCA) { compute_mean_stdev_ci_bca(rng_ptr, val_it->second, job.n_boot_rep, job.out_alpha, mean_ci, stdev_ci); @@ -1255,24 +1255,24 @@ void write_job_aggr_ctc(STATAnalysisJob &job, STATLineType lt, // n_row = 1 + m.size(); n_col = 1 + job.by_column.n(); - if(lt == stat_fho) n_col += n_fho_columns; - else if(lt == stat_ctc) n_col += n_ctc_columns; - else if(lt == stat_cts) n_col += n_cts_columns; - else if(lt == stat_eclv) n_col += get_n_eclv_columns(n_pnt); - else if(lt == stat_nbrctc) n_col += n_nbrctc_columns; - else if(lt == stat_nbrcts) n_col += n_nbrcts_columns; + if(lt == STATLineType::fho) n_col += n_fho_columns; + else if(lt == STATLineType::ctc) n_col += n_ctc_columns; + else if(lt == STATLineType::cts) n_col += n_cts_columns; + else if(lt == STATLineType::eclv) n_col += get_n_eclv_columns(n_pnt); + else if(lt == STATLineType::nbrctc) n_col += n_nbrctc_columns; + else if(lt == STATLineType::nbrcts) n_col += n_nbrcts_columns; write_job_aggr_hdr(job, n_row, n_col, at); // // Write the output header row // c = 1 + job.by_column.n(); - if(lt == stat_fho) write_header_row(fho_columns, n_fho_columns, 0, at, 0, c); - else if(lt == stat_ctc) write_header_row(ctc_columns, n_ctc_columns, 0, at, 0, c); - else if(lt == stat_cts) write_header_row(cts_columns, n_cts_columns, 0, at, 0, c); - else if(lt == stat_eclv) write_eclv_header_row( 0, n_pnt, at, 0, c); - else if(lt == stat_nbrctc) write_header_row(nbrctc_columns, n_nbrctc_columns, 0, at, 0, c); - else if(lt == stat_nbrcts) write_header_row(nbrcts_columns, n_nbrcts_columns, 0, at, 0, c); + if(lt == STATLineType::fho) write_header_row(fho_columns, n_fho_columns, 0, at, 0, c); + else if(lt == STATLineType::ctc) write_header_row(ctc_columns, n_ctc_columns, 0, at, 0, c); + else if(lt == STATLineType::cts) write_header_row(cts_columns, n_cts_columns, 0, at, 0, c); + else if(lt == STATLineType::eclv) write_eclv_header_row( 0, n_pnt, at, 0, c); + else if(lt == STATLineType::nbrctc) write_header_row(nbrctc_columns, n_nbrctc_columns, 0, at, 0, c); + else if(lt == STATLineType::nbrcts) write_header_row(nbrcts_columns, n_nbrcts_columns, 0, at, 0, c); // // Setup the output STAT file @@ -1293,7 +1293,7 @@ void write_job_aggr_ctc(STATAnalysisJob &job, STATLineType lt, shc = it->second.hdr.get_shc(it->first, job.by_column, job.hdr_name, job.hdr_value, lt); if(job.stat_out) { - if(lt == stat_cts || lt == stat_nbrcts) shc.set_alpha(job.out_alpha); + if(lt == STATLineType::cts || lt == STATLineType::nbrcts) shc.set_alpha(job.out_alpha); write_header_cols(shc, job.stat_at, job.stat_row); } @@ -1305,7 +1305,7 @@ void write_job_aggr_ctc(STATAnalysisJob &job, STATLineType lt, // // FHO output line // - if(lt == stat_fho) { + if(lt == STATLineType::fho) { if(job.stat_out) { write_fho_cols(it->second.cts_info, job.stat_at, job.stat_row++, n_header_columns); @@ -1319,7 +1319,7 @@ void write_job_aggr_ctc(STATAnalysisJob &job, STATLineType lt, // // CTC output line // - else if(lt == stat_ctc) { + else if(lt == STATLineType::ctc) { if(job.stat_out) { write_ctc_cols(it->second.cts_info, job.stat_at, job.stat_row++, n_header_columns); @@ -1333,7 +1333,7 @@ void write_job_aggr_ctc(STATAnalysisJob &job, STATLineType lt, // // CTS output line // - else if(lt == stat_cts) { + else if(lt == STATLineType::cts) { // // Store the alpha information in the CTSInfo object @@ -1364,7 +1364,7 @@ void write_job_aggr_ctc(STATAnalysisJob &job, STATLineType lt, // // ECLV output line // - else if(lt == stat_eclv) { + else if(lt == STATLineType::eclv) { if(job.stat_out) { write_eclv_cols(it->second.cts_info.cts, job.out_eclv_points, job.stat_at, @@ -1379,7 +1379,7 @@ void write_job_aggr_ctc(STATAnalysisJob &job, STATLineType lt, // // NBRCTC output line // - else if(lt == stat_nbrctc) { + else if(lt == STATLineType::nbrctc) { nbrcts_info.clear(); nbrcts_info.cts_info = it->second.cts_info; @@ -1397,7 +1397,7 @@ void write_job_aggr_ctc(STATAnalysisJob &job, STATLineType lt, // // NBRCTS output line // - else if(lt == stat_nbrcts) { + else if(lt == STATLineType::nbrcts) { nbrcts_info.clear(); nbrcts_info.cts_info = it->second.cts_info; @@ -1463,16 +1463,16 @@ void write_job_aggr_mctc(STATAnalysisJob &job, STATLineType lt, // n_row = 1 + m.size(); n_col = 1 + job.by_column.n(); - if(lt == stat_mctc) n_col += get_n_mctc_columns(n); - else if(lt == stat_mcts) n_col += n_mcts_columns; + if(lt == STATLineType::mctc) n_col += get_n_mctc_columns(n); + else if(lt == STATLineType::mcts) n_col += n_mcts_columns; write_job_aggr_hdr(job, n_row, n_col, at); // // Write the rest of the header row // c = 1 + job.by_column.n(); - if(lt == stat_mctc) write_mctc_header_row(0, n, at, 0, c); - else if(lt == stat_mcts) write_header_row(mcts_columns, n_mcts_columns, 0, at, 0, c); + if(lt == STATLineType::mctc) write_mctc_header_row(0, n, at, 0, c); + else if(lt == STATLineType::mcts) write_header_row(mcts_columns, n_mcts_columns, 0, at, 0, c); // // Setup the output STAT file @@ -1493,7 +1493,7 @@ void write_job_aggr_mctc(STATAnalysisJob &job, STATLineType lt, shc = it->second.hdr.get_shc(it->first, job.by_column, job.hdr_name, job.hdr_value, lt); if(job.stat_out) { - if(lt == stat_mcts) shc.set_alpha(job.out_alpha); + if(lt == STATLineType::mcts) shc.set_alpha(job.out_alpha); write_header_cols(shc, job.stat_at, job.stat_row); } @@ -1505,7 +1505,7 @@ void write_job_aggr_mctc(STATAnalysisJob &job, STATLineType lt, // // MCTC output line // - if(lt == stat_mctc) { + if(lt == STATLineType::mctc) { if(job.stat_out) { write_mctc_cols(it->second.mcts_info, job.stat_at, job.stat_row++, n_header_columns); @@ -1519,7 +1519,7 @@ void write_job_aggr_mctc(STATAnalysisJob &job, STATLineType lt, // // MCTS output line // - else if(lt == stat_mcts) { + else if(lt == STATLineType::mcts) { // // Store the alpha information in the CTSInfo object @@ -1582,31 +1582,31 @@ void write_job_aggr_pct(STATAnalysisJob &job, STATLineType lt, // // Setup the output table // - if(lt == stat_eclv) n_row = 1 + m.size() * n; - else n_row = 1 + m.size(); + if(lt == STATLineType::eclv) n_row = 1 + m.size() * n; + else n_row = 1 + m.size(); n_col = 1 + job.by_column.n(); - if(lt == stat_pct) n_col += get_n_pct_columns(n); - else if(lt == stat_pstd) n_col += get_n_pstd_columns(n); - else if(lt == stat_pjc) n_col += get_n_pjc_columns(n); - else if(lt == stat_prc) n_col += get_n_prc_columns(n); - else if(lt == stat_eclv) n_col += get_n_eclv_columns(n_pnt); + if(lt == STATLineType::pct) n_col += get_n_pct_columns(n); + else if(lt == STATLineType::pstd) n_col += get_n_pstd_columns(n); + else if(lt == STATLineType::pjc) n_col += get_n_pjc_columns(n); + else if(lt == STATLineType::prc) n_col += get_n_prc_columns(n); + else if(lt == STATLineType::eclv) n_col += get_n_eclv_columns(n_pnt); write_job_aggr_hdr(job, n_row, n_col, at); // // Write the rest of the header row // c = 1 + job.by_column.n(); - if(lt == stat_pct) write_pct_header_row (0, n, at, 0, c); - else if(lt == stat_pstd) write_pstd_header_row(0, n, at, 0, c); - else if(lt == stat_pjc) write_pjc_header_row (0, n, at, 0, c); - else if(lt == stat_prc) write_prc_header_row (0, n, at, 0, c); - else if(lt == stat_eclv) write_eclv_header_row(0, n_pnt, at, 0, c); + if(lt == STATLineType::pct) write_pct_header_row (0, n, at, 0, c); + else if(lt == STATLineType::pstd) write_pstd_header_row(0, n, at, 0, c); + else if(lt == STATLineType::pjc) write_pjc_header_row (0, n, at, 0, c); + else if(lt == STATLineType::prc) write_prc_header_row (0, n, at, 0, c); + else if(lt == STATLineType::eclv) write_eclv_header_row(0, n_pnt, at, 0, c); // // Setup the output STAT file // - if(lt == stat_eclv) job.setup_stat_file(n_row, n_pnt); - else job.setup_stat_file(n_row, n); + if(lt == STATLineType::eclv) job.setup_stat_file(n_row, n_pnt); + else job.setup_stat_file(n_row, n); mlog << Debug(2) << "Computing output for " << (int) m.size() << " case(s).\n"; @@ -1622,7 +1622,7 @@ void write_job_aggr_pct(STATAnalysisJob &job, STATLineType lt, shc = it->second.hdr.get_shc(it->first, job.by_column, job.hdr_name, job.hdr_value, lt); if(job.stat_out) { - if(lt == stat_pstd) shc.set_alpha(job.out_alpha); + if(lt == STATLineType::pstd) shc.set_alpha(job.out_alpha); write_header_cols(shc, job.stat_at, job.stat_row); } @@ -1634,7 +1634,7 @@ void write_job_aggr_pct(STATAnalysisJob &job, STATLineType lt, // // PCT output line // - if(lt == stat_pct) { + if(lt == STATLineType::pct) { if(job.stat_out) { write_pct_cols(it->second.pct_info, job.stat_at, job.stat_row++, n_header_columns); @@ -1648,7 +1648,7 @@ void write_job_aggr_pct(STATAnalysisJob &job, STATLineType lt, // // PSTD output line // - else if(lt == stat_pstd) { + else if(lt == STATLineType::pstd) { // // Store the alpha information in the PCTInfo object @@ -1679,7 +1679,7 @@ void write_job_aggr_pct(STATAnalysisJob &job, STATLineType lt, // // PJC output line // - else if(lt == stat_pjc) { + else if(lt == STATLineType::pjc) { if(job.stat_out) { write_pjc_cols(it->second.pct_info, job.stat_at, job.stat_row++, n_header_columns); @@ -1693,7 +1693,7 @@ void write_job_aggr_pct(STATAnalysisJob &job, STATLineType lt, // // PRC output line // - else if(lt == stat_prc) { + else if(lt == STATLineType::prc) { if(job.stat_out) { write_prc_cols(it->second.pct_info, job.stat_at, job.stat_row++, n_header_columns); @@ -1707,7 +1707,7 @@ void write_job_aggr_pct(STATAnalysisJob &job, STATLineType lt, // // ECLV output lines // - else if(lt == stat_eclv) { + else if(lt == STATLineType::eclv) { ThreshArray prob_ta = string_to_prob_thresh(shc.get_fcst_thresh_str().c_str()); for(i=0; isecond.pct_info.pct.nrows(); i++) { if(job.stat_out) { @@ -1753,26 +1753,26 @@ void write_job_aggr_psum(STATAnalysisJob &job, STATLineType lt, // n_row = 1 + m.size(); n_col = 1 + job.by_column.n(); - if(lt == stat_sl1l2) n_col += n_sl1l2_columns; - else if(lt == stat_sal1l2) n_col += n_sal1l2_columns; - else if(lt == stat_vl1l2) n_col += n_vl1l2_columns; - else if(lt == stat_val1l2) n_col += n_val1l2_columns; - else if(lt == stat_cnt) n_col += n_cnt_columns; - else if(lt == stat_vcnt) n_col += n_vcnt_columns; - else if(lt == stat_nbrcnt) n_col += n_nbrcnt_columns; + if(lt == STATLineType::sl1l2) n_col += n_sl1l2_columns; + else if(lt == STATLineType::sal1l2) n_col += n_sal1l2_columns; + else if(lt == STATLineType::vl1l2) n_col += n_vl1l2_columns; + else if(lt == STATLineType::val1l2) n_col += n_val1l2_columns; + else if(lt == STATLineType::cnt) n_col += n_cnt_columns; + else if(lt == STATLineType::vcnt) n_col += n_vcnt_columns; + else if(lt == STATLineType::nbrcnt) n_col += n_nbrcnt_columns; write_job_aggr_hdr(job, n_row, n_col, at); // // Write the rest of the header row // c = 1 + job.by_column.n(); - if(lt == stat_sl1l2) write_header_row(sl1l2_columns, n_sl1l2_columns, 0, at, 0, c); - else if(lt == stat_sal1l2) write_header_row(sal1l2_columns, n_sal1l2_columns, 0, at, 0, c); - else if(lt == stat_vl1l2) write_header_row(vl1l2_columns, n_vl1l2_columns, 0, at, 0, c); - else if(lt == stat_val1l2) write_header_row(val1l2_columns, n_val1l2_columns, 0, at, 0, c); - else if(lt == stat_cnt) write_header_row(cnt_columns, n_cnt_columns, 0, at, 0, c); - else if(lt == stat_vcnt) write_header_row(vcnt_columns, n_vcnt_columns, 0, at, 0, c); - else if(lt == stat_nbrcnt) write_header_row(nbrcnt_columns, n_nbrcnt_columns, 0, at, 0, c); + if(lt == STATLineType::sl1l2) write_header_row(sl1l2_columns, n_sl1l2_columns, 0, at, 0, c); + else if(lt == STATLineType::sal1l2) write_header_row(sal1l2_columns, n_sal1l2_columns, 0, at, 0, c); + else if(lt == STATLineType::vl1l2) write_header_row(vl1l2_columns, n_vl1l2_columns, 0, at, 0, c); + else if(lt == STATLineType::val1l2) write_header_row(val1l2_columns, n_val1l2_columns, 0, at, 0, c); + else if(lt == STATLineType::cnt) write_header_row(cnt_columns, n_cnt_columns, 0, at, 0, c); + else if(lt == STATLineType::vcnt) write_header_row(vcnt_columns, n_vcnt_columns, 0, at, 0, c); + else if(lt == STATLineType::nbrcnt) write_header_row(nbrcnt_columns, n_nbrcnt_columns, 0, at, 0, c); // // Setup the output STAT file @@ -1793,7 +1793,7 @@ void write_job_aggr_psum(STATAnalysisJob &job, STATLineType lt, shc = it->second.hdr.get_shc(it->first, job.by_column, job.hdr_name, job.hdr_value, lt); if(job.stat_out) { - if(lt == stat_cnt || lt == stat_vcnt || lt == stat_nbrcnt) { + if(lt == STATLineType::cnt || lt == STATLineType::vcnt || lt == STATLineType::nbrcnt) { shc.set_alpha(job.out_alpha); } write_header_cols(shc, job.stat_at, job.stat_row); @@ -1807,7 +1807,7 @@ void write_job_aggr_psum(STATAnalysisJob &job, STATLineType lt, // // SL1L2 output line // - if(lt == stat_sl1l2) { + if(lt == STATLineType::sl1l2) { if(job.stat_out) { write_sl1l2_cols(it->second.sl1l2_info, job.stat_at, job.stat_row++, n_header_columns); @@ -1821,7 +1821,7 @@ void write_job_aggr_psum(STATAnalysisJob &job, STATLineType lt, // // SAL1L2 output line // - else if(lt == stat_sal1l2) { + else if(lt == STATLineType::sal1l2) { if(job.stat_out) { write_sal1l2_cols(it->second.sl1l2_info, job.stat_at, job.stat_row++, n_header_columns); @@ -1835,7 +1835,7 @@ void write_job_aggr_psum(STATAnalysisJob &job, STATLineType lt, // // VL1L2 output line // - else if(lt == stat_vl1l2) { + else if(lt == STATLineType::vl1l2) { if(job.stat_out) { write_vl1l2_cols(it->second.vl1l2_info, job.stat_at, job.stat_row++, n_header_columns); @@ -1849,7 +1849,7 @@ void write_job_aggr_psum(STATAnalysisJob &job, STATLineType lt, // // VAL1L2 output line // - else if(lt == stat_val1l2) { + else if(lt == STATLineType::val1l2) { if(job.stat_out) { write_val1l2_cols(it->second.vl1l2_info, job.stat_at, job.stat_row++, n_header_columns); @@ -1863,7 +1863,7 @@ void write_job_aggr_psum(STATAnalysisJob &job, STATLineType lt, // // CNT output line // - else if(lt == stat_cnt) { + else if(lt == STATLineType::cnt) { it->second.cnt_info.clear(); @@ -1894,7 +1894,7 @@ void write_job_aggr_psum(STATAnalysisJob &job, STATLineType lt, // // VCNT output line // - else if(lt == stat_vcnt) { + else if(lt == STATLineType::vcnt) { if(job.stat_out) { write_vcnt_cols(it->second.vl1l2_info, 0, job.stat_at, job.stat_row++, n_header_columns); @@ -1908,7 +1908,7 @@ void write_job_aggr_psum(STATAnalysisJob &job, STATLineType lt, // // NBRCNT output line // - else if(lt == stat_nbrcnt) { + else if(lt == STATLineType::nbrcnt) { // // Allocate space for confidence intervals @@ -2126,14 +2126,14 @@ void write_job_aggr_wind(STATAnalysisJob &job, STATLineType lt, // r++; - if(lt == stat_vl1l2 || lt == stat_mpr) { + if(lt == STATLineType::vl1l2 || lt == STATLineType::mpr) { uf = it->second.vl1l2_info.uf_bar; vf = it->second.vl1l2_info.vf_bar; uo = it->second.vl1l2_info.uo_bar; vo = it->second.vl1l2_info.vo_bar; count = it->second.vl1l2_info.vcount; } - else if(lt == stat_val1l2) { + else if(lt == STATLineType::val1l2) { uf = it->second.vl1l2_info.ufa_bar; vf = it->second.vl1l2_info.vfa_bar; uo = it->second.vl1l2_info.uoa_bar; @@ -2859,10 +2859,10 @@ void write_job_aggr_orank(STATAnalysisJob &job, STATLineType lt, // - Ensemble members for RELP // for(it = m.begin(), n = 0; it != m.end(); it++) { - if(lt == stat_rhist) n = max(it->second.ens_pd.rhist_na.n(), n); - else if(lt == stat_phist) n = max(it->second.ens_pd.phist_na.n(), n); - else if(lt == stat_relp) n = max(it->second.ens_pd.n_ens, n); - else if(lt == stat_ssvar) { + if(lt == STATLineType::rhist) n = max(it->second.ens_pd.rhist_na.n(), n); + else if(lt == STATLineType::phist) n = max(it->second.ens_pd.phist_na.n(), n); + else if(lt == STATLineType::relp) n = max(it->second.ens_pd.n_ens, n); + else if(lt == STATLineType::ssvar) { it->second.ens_pd.compute_ssvar(); if(it->second.ens_pd.ssvar_bins) n += it->second.ens_pd.ssvar_bins[0].n_bin; } @@ -2873,27 +2873,27 @@ void write_job_aggr_orank(STATAnalysisJob &job, STATLineType lt, // n_row = 0; n_col = 1 + job.by_column.n(); - if(lt == stat_ecnt) { + if(lt == STATLineType::ecnt) { n_row = 1 + m.size(); n_col += n_ecnt_columns; } - if(lt == stat_rps) { + if(lt == STATLineType::rps) { n_row = 1 + m.size(); n_col += n_rps_columns; } - else if(lt == stat_rhist) { + else if(lt == STATLineType::rhist) { n_row = 1 + m.size(); n_col += get_n_rhist_columns(n); } - else if(lt == stat_phist) { + else if(lt == STATLineType::phist) { n_row = 1 + m.size(); n_col += get_n_phist_columns(n); } - else if(lt == stat_relp) { + else if(lt == STATLineType::relp) { n_row = 1 + m.size(); n_col += get_n_relp_columns(n); } - else if(lt == stat_ssvar) { + else if(lt == STATLineType::ssvar) { n_row = 1 + n; n_col += n_ssvar_columns; } @@ -2903,22 +2903,22 @@ void write_job_aggr_orank(STATAnalysisJob &job, STATLineType lt, // Write the rest of the header row // c = 1 + job.by_column.n(); - if(lt == stat_ecnt) write_header_row(ecnt_columns, n_ecnt_columns, 0, at, 0, c); - else if(lt == stat_rps) write_header_row(rps_columns, n_rps_columns, 0, at, 0, c); - else if(lt == stat_rhist) write_rhist_header_row(0, n, at, 0, c); - else if(lt == stat_phist) write_phist_header_row(0, n, at, 0, c); - else if(lt == stat_relp) write_relp_header_row (0, n, at, 0, c); - else if(lt == stat_ssvar) write_header_row(ssvar_columns, n_ssvar_columns, 0, at, 0, c); + if(lt == STATLineType::ecnt) write_header_row(ecnt_columns, n_ecnt_columns, 0, at, 0, c); + else if(lt == STATLineType::rps) write_header_row(rps_columns, n_rps_columns, 0, at, 0, c); + else if(lt == STATLineType::rhist) write_rhist_header_row(0, n, at, 0, c); + else if(lt == STATLineType::phist) write_phist_header_row(0, n, at, 0, c); + else if(lt == STATLineType::relp) write_relp_header_row (0, n, at, 0, c); + else if(lt == STATLineType::ssvar) write_header_row(ssvar_columns, n_ssvar_columns, 0, at, 0, c); // // Setup the output STAT file // - if(lt == stat_ecnt) job.setup_stat_file(n_row, 0); - else if(lt == stat_rps) job.setup_stat_file(n_row, 0); - else if(lt == stat_rhist) job.setup_stat_file(n_row, n); - else if(lt == stat_phist) job.setup_stat_file(n_row, n); - else if(lt == stat_relp) job.setup_stat_file(n_row, n); - else if(lt == stat_ssvar) job.setup_stat_file(n_row, 0); + if(lt == STATLineType::ecnt) job.setup_stat_file(n_row, 0); + else if(lt == STATLineType::rps) job.setup_stat_file(n_row, 0); + else if(lt == STATLineType::rhist) job.setup_stat_file(n_row, n); + else if(lt == STATLineType::phist) job.setup_stat_file(n_row, n); + else if(lt == STATLineType::relp) job.setup_stat_file(n_row, n); + else if(lt == STATLineType::ssvar) job.setup_stat_file(n_row, 0); mlog << Debug(2) << "Computing output for " << (int) m.size() << " case(s).\n"; @@ -2937,7 +2937,7 @@ void write_job_aggr_orank(STATAnalysisJob &job, STATLineType lt, // // Set SSVAR alpha value // - if(lt == stat_ssvar) shc.set_alpha(job.out_alpha); + if(lt == STATLineType::ssvar) shc.set_alpha(job.out_alpha); // // Initialize @@ -2947,7 +2947,7 @@ void write_job_aggr_orank(STATAnalysisJob &job, STATLineType lt, // // ECNT output line // - if(lt == stat_ecnt) { + if(lt == STATLineType::ecnt) { ECNTInfo ecnt_info; ecnt_info.set(it->second.ens_pd); @@ -2965,7 +2965,7 @@ void write_job_aggr_orank(STATAnalysisJob &job, STATLineType lt, // // RPS output line // - else if(lt == stat_rps) { + else if(lt == STATLineType::rps) { RPSInfo rps_info; rps_info.fthresh = job.out_fcst_thresh; rps_info.set(it->second.ens_pd); @@ -2985,7 +2985,7 @@ void write_job_aggr_orank(STATAnalysisJob &job, STATLineType lt, // // RHIST output line // - else if(lt == stat_rhist) { + else if(lt == STATLineType::rhist) { it->second.ens_pd.compute_rhist(); if(job.stat_out) { @@ -3002,7 +3002,7 @@ void write_job_aggr_orank(STATAnalysisJob &job, STATLineType lt, // // PHIST output line // - else if(lt == stat_phist) { + else if(lt == STATLineType::phist) { if(job.stat_out) { write_header_cols(shc, job.stat_at, job.stat_row); write_phist_cols(&(it->second.ens_pd), job.stat_at, @@ -3017,7 +3017,7 @@ void write_job_aggr_orank(STATAnalysisJob &job, STATLineType lt, // // RELP output line // - else if(lt == stat_relp) { + else if(lt == STATLineType::relp) { it->second.ens_pd.compute_relp(); if(job.stat_out) { @@ -3034,7 +3034,7 @@ void write_job_aggr_orank(STATAnalysisJob &job, STATLineType lt, // // SSVAR output lines // - else if(lt == stat_ssvar) { + else if(lt == STATLineType::ssvar) { if(!it->second.ens_pd.ssvar_bins) continue; @@ -3160,10 +3160,10 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, // Number of rows n_row = 1; - if(lt == stat_fho || lt == stat_ctc || - lt == stat_cts || lt == stat_eclv || - lt == stat_cnt || lt == stat_sl1l2 || - lt == stat_sal1l2) { + if(lt == STATLineType::fho || lt == STATLineType::ctc || + lt == STATLineType::cts || lt == STATLineType::eclv || + lt == STATLineType::cnt || lt == STATLineType::sl1l2 || + lt == STATLineType::sal1l2) { n_row += job.out_fcst_thresh.n() * m.size(); } else { @@ -3172,44 +3172,44 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, // Number of columns n_col = 1 + job.by_column.n(); - if(lt == stat_fho) { n_col += n_fho_columns; } - else if(lt == stat_ctc) { n_col += n_ctc_columns; } - else if(lt == stat_cts) { n_col += n_cts_columns; } - else if(lt == stat_eclv) { n = job.out_eclv_points.n(); - n_col += get_n_eclv_columns(n); } - else if(lt == stat_mctc) { n = job.out_fcst_thresh.n()+1; - n_col += get_n_mctc_columns(n); } - else if(lt == stat_mcts) { n_col += n_mcts_columns; } - else if(lt == stat_cnt) { n_col += n_cnt_columns; } - else if(lt == stat_sl1l2) { n_col += n_sl1l2_columns; } - else if(lt == stat_sal1l2) { n_col += n_sal1l2_columns; } - else if(lt == stat_pct) { n = job.out_fcst_thresh.n(); - n_col += get_n_pct_columns(n); } - else if(lt == stat_pstd) { n = job.out_fcst_thresh.n(); - n_col += get_n_pstd_columns(n); } - else if(lt == stat_pjc) { n = job.out_fcst_thresh.n(); - n_col += get_n_pjc_columns(n); } - else if(lt == stat_prc) { n = job.out_fcst_thresh.n(); - n_col += get_n_prc_columns(n); } + if(lt == STATLineType::fho) { n_col += n_fho_columns; } + else if(lt == STATLineType::ctc) { n_col += n_ctc_columns; } + else if(lt == STATLineType::cts) { n_col += n_cts_columns; } + else if(lt == STATLineType::eclv) { n = job.out_eclv_points.n(); + n_col += get_n_eclv_columns(n); } + else if(lt == STATLineType::mctc) { n = job.out_fcst_thresh.n()+1; + n_col += get_n_mctc_columns(n); } + else if(lt == STATLineType::mcts) { n_col += n_mcts_columns; } + else if(lt == STATLineType::cnt) { n_col += n_cnt_columns; } + else if(lt == STATLineType::sl1l2) { n_col += n_sl1l2_columns; } + else if(lt == STATLineType::sal1l2) { n_col += n_sal1l2_columns; } + else if(lt == STATLineType::pct) { n = job.out_fcst_thresh.n(); + n_col += get_n_pct_columns(n); } + else if(lt == STATLineType::pstd) { n = job.out_fcst_thresh.n(); + n_col += get_n_pstd_columns(n); } + else if(lt == STATLineType::pjc) { n = job.out_fcst_thresh.n(); + n_col += get_n_pjc_columns(n); } + else if(lt == STATLineType::prc) { n = job.out_fcst_thresh.n(); + n_col += get_n_prc_columns(n); } write_job_aggr_hdr(job, n_row, n_col, at); // // Write the rest of the header row // c = 1 + job.by_column.n(); - if(lt == stat_fho) write_header_row(fho_columns, n_fho_columns, 0, at, 0, c); - else if(lt == stat_ctc) write_header_row(ctc_columns, n_ctc_columns, 0, at, 0, c); - else if(lt == stat_cts) write_header_row(cts_columns, n_cts_columns, 0, at, 0, c); - else if(lt == stat_eclv) write_eclv_header_row(0, n, at, 0, c); - else if(lt == stat_mctc) write_mctc_header_row(0, n, at, 0, c); - else if(lt == stat_mcts) write_header_row(mcts_columns, n_mcts_columns, 0, at, 0, c); - else if(lt == stat_cnt) write_header_row(cnt_columns, n_cnt_columns, 0, at, 0, c); - else if(lt == stat_sl1l2) write_header_row(sl1l2_columns, n_sl1l2_columns, 0, at, 0, c); - else if(lt == stat_sal1l2) write_header_row(sal1l2_columns, n_sal1l2_columns, 0, at, 0, c); - else if(lt == stat_pct) write_pct_header_row (0, n, at, 0, c); - else if(lt == stat_pstd) write_pstd_header_row(0, n, at, 0, c); - else if(lt == stat_pjc) write_pjc_header_row (0, n, at, 0, c); - else if(lt == stat_prc) write_prc_header_row (0, n, at, 0, c); + if(lt == STATLineType::fho) write_header_row(fho_columns, n_fho_columns, 0, at, 0, c); + else if(lt == STATLineType::ctc) write_header_row(ctc_columns, n_ctc_columns, 0, at, 0, c); + else if(lt == STATLineType::cts) write_header_row(cts_columns, n_cts_columns, 0, at, 0, c); + else if(lt == STATLineType::eclv) write_eclv_header_row(0, n, at, 0, c); + else if(lt == STATLineType::mctc) write_mctc_header_row(0, n, at, 0, c); + else if(lt == STATLineType::mcts) write_header_row(mcts_columns, n_mcts_columns, 0, at, 0, c); + else if(lt == STATLineType::cnt) write_header_row(cnt_columns, n_cnt_columns, 0, at, 0, c); + else if(lt == STATLineType::sl1l2) write_header_row(sl1l2_columns, n_sl1l2_columns, 0, at, 0, c); + else if(lt == STATLineType::sal1l2) write_header_row(sal1l2_columns, n_sal1l2_columns, 0, at, 0, c); + else if(lt == STATLineType::pct) write_pct_header_row (0, n, at, 0, c); + else if(lt == STATLineType::pstd) write_pstd_header_row(0, n, at, 0, c); + else if(lt == STATLineType::pjc) write_pjc_header_row (0, n, at, 0, c); + else if(lt == STATLineType::prc) write_prc_header_row (0, n, at, 0, c); // // Setup the output STAT file @@ -3238,7 +3238,7 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, // // FHO output line // - if(lt == stat_fho) { + if(lt == STATLineType::fho) { for(i=0; isecond, i, cts_info); if(job.stat_out) { @@ -3259,7 +3259,7 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, // // CTC output line // - else if(lt == stat_ctc) { + else if(lt == STATLineType::ctc) { for(i=0; isecond, i, cts_info); if(job.stat_out) { @@ -3280,7 +3280,7 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, // // CTS output line // - else if(lt == stat_cts) { + else if(lt == STATLineType::cts) { for(i=0; isecond, i, cts_info, tmp_dir, rng_ptr); if(job.stat_out) { @@ -3302,7 +3302,7 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, // // ECLV output line // - else if(lt == stat_eclv) { + else if(lt == STATLineType::eclv) { for(i=0; isecond, i, cts_info); if(job.stat_out) { @@ -3323,7 +3323,7 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, // // MCTC output line // - else if(lt == stat_mctc) { + else if(lt == STATLineType::mctc) { mpr_to_mctc(job, it->second, mcts_info); if(job.stat_out) { shc.set_fcst_thresh(job.out_fcst_thresh); @@ -3342,7 +3342,7 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, // // MCTS output line // - else if(lt == stat_mcts) { + else if(lt == STATLineType::mcts) { mpr_to_mcts(job, it->second, mcts_info, tmp_dir, rng_ptr); if(job.stat_out) { shc.set_fcst_thresh(job.out_fcst_thresh); @@ -3362,7 +3362,7 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, // // CNT output line // - else if(lt == stat_cnt) { + else if(lt == STATLineType::cnt) { for(i=0; isecond, i, cnt_info, tmp_dir, rng_ptr); if(cnt_info.n == 0) continue; @@ -3386,7 +3386,7 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, // // SL1L2 output line // - else if(lt == stat_sl1l2) { + else if(lt == STATLineType::sl1l2) { for(i=0; isecond, i, sl1l2_info); if(sl1l2_info.scount == 0) continue; @@ -3409,7 +3409,7 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, // // SAL1L2 output line // - else if(lt == stat_sal1l2) { + else if(lt == STATLineType::sal1l2) { for(i=0; isecond, i, sl1l2_info); if(sl1l2_info.sacount == 0) continue; @@ -3432,7 +3432,7 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, // // PCT output line // - else if(lt == stat_pct) { + else if(lt == STATLineType::pct) { mpr_to_pct(job, it->second, pct_info); if(job.stat_out) { shc.set_fcst_thresh(job.out_fcst_thresh); @@ -3451,7 +3451,7 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, // // PSTD output line // - else if(lt == stat_pstd) { + else if(lt == STATLineType::pstd) { mpr_to_pct(job, it->second, pct_info); if(job.stat_out) { shc.set_fcst_thresh(job.out_fcst_thresh); @@ -3471,7 +3471,7 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, // // PJC output line // - else if(lt == stat_pjc) { + else if(lt == STATLineType::pjc) { mpr_to_pct(job, it->second, pct_info); if(job.stat_out) { shc.set_fcst_thresh(job.out_fcst_thresh); @@ -3491,7 +3491,7 @@ void write_job_aggr_mpr(STATAnalysisJob &job, STATLineType lt, // // PRC output line // - else if(lt == stat_prc) { + else if(lt == STATLineType::prc) { mpr_to_pct(job, it->second, pct_info); if(job.stat_out) { shc.set_fcst_thresh(job.out_fcst_thresh); @@ -3541,16 +3541,16 @@ void write_job_aggr_mpr_wind(STATAnalysisJob &job, STATLineType lt, // n_row = 1 + m.size(); n_col = 1 + job.by_column.n(); - if(lt == stat_vl1l2) n_col += n_vl1l2_columns; - else if(lt == stat_vcnt) n_col += n_vcnt_columns; + if(lt == STATLineType::vl1l2) n_col += n_vl1l2_columns; + else if(lt == STATLineType::vcnt) n_col += n_vcnt_columns; write_job_aggr_hdr(job, n_row, n_col, at); // // Write the rest of the header row // c = 1 + job.by_column.n(); - if(lt == stat_vl1l2) write_header_row(vl1l2_columns, n_vl1l2_columns, 0, at, 0, c); - else if(lt == stat_vcnt) write_header_row(vcnt_columns, n_vcnt_columns, 0, at, 0, c); + if(lt == STATLineType::vl1l2) write_header_row(vl1l2_columns, n_vl1l2_columns, 0, at, 0, c); + else if(lt == STATLineType::vcnt) write_header_row(vcnt_columns, n_vcnt_columns, 0, at, 0, c); // // Setup the output STAT file @@ -3571,7 +3571,7 @@ void write_job_aggr_mpr_wind(STATAnalysisJob &job, STATLineType lt, shc = it->second.hdr.get_shc(it->first, job.by_column, job.hdr_name, job.hdr_value, lt); if(job.stat_out) { - if(lt == stat_cnt || lt == stat_nbrcnt) shc.set_alpha(job.out_alpha); + if(lt == STATLineType::cnt || lt == STATLineType::nbrcnt) shc.set_alpha(job.out_alpha); write_header_cols(shc, job.stat_at, job.stat_row); } @@ -3583,7 +3583,7 @@ void write_job_aggr_mpr_wind(STATAnalysisJob &job, STATLineType lt, // // VL1L2 output line // - if(lt == stat_vl1l2) { + if(lt == STATLineType::vl1l2) { if(job.stat_out) { write_vl1l2_cols(it->second.vl1l2_info, job.stat_at, job.stat_row++, n_header_columns); @@ -3597,7 +3597,7 @@ void write_job_aggr_mpr_wind(STATAnalysisJob &job, STATLineType lt, // // VCNT output line // - else if(lt == stat_vcnt) { + else if(lt == STATLineType::vcnt) { if(job.stat_out) { write_vcnt_cols(it->second.vl1l2_info, 0, job.stat_at, job.stat_row++, n_header_columns); @@ -3794,7 +3794,7 @@ void write_job_ramp(STATAnalysisJob &job, vals_part = it->second.f_na.subset(ts.index(beg[i]), ts.index(end[i])); - if(job.ramp_type == TimeSeriesType_DyDt) { + if(job.ramp_type == TimeSeriesType::DyDt) { compute_dydt_ramps(cs.c_str(), vals_part, ts_part, job.ramp_time_fcst, job.ramp_exact_fcst, job.ramp_thresh_fcst, ramp_part, dat_part); @@ -3823,7 +3823,7 @@ void write_job_ramp(STATAnalysisJob &job, vals_part = it->second.o_na.subset(ts.index(beg[i]), ts.index(end[i])); - if(job.ramp_type == TimeSeriesType_DyDt) { + if(job.ramp_type == TimeSeriesType::DyDt) { compute_dydt_ramps(cs.c_str(), vals_part, ts_part, job.ramp_time_obs, job.ramp_exact_obs, job.ramp_thresh_obs, ramp_part, dat_part); @@ -3948,7 +3948,7 @@ void write_job_ramp(STATAnalysisJob &job, mpr_at.set_entry(r_mpr, c++, unix_to_yyyymmdd_hhmmss(init_ut)); mpr_at.set_entry(r_mpr, c++, sec_to_hhmmss((int) valid_ut - init_ut)); mpr_at.set_entry(r_mpr, c++, unix_to_yyyymmdd_hhmmss(valid_ut)); - if(job.ramp_type == TimeSeriesType_DyDt) { + if(job.ramp_type == TimeSeriesType::DyDt) { mpr_at.set_entry(r_mpr, c++, fdat[k]); mpr_at.set_entry(r_mpr, c++, it->second.f_na[k]); mpr_at.set_entry(r_mpr, c++, (is_bad_data(fdat[k]) || is_bad_data(it->second.f_na[k]) ? @@ -3960,7 +3960,7 @@ void write_job_ramp(STATAnalysisJob &job, mpr_at.set_entry(r_mpr, c++, fdat[k]); } mpr_at.set_entry(r_mpr, c++, (is_bad_data(f) ? na_str : bool_to_string(f))); - if(job.ramp_type == TimeSeriesType_DyDt) { + if(job.ramp_type == TimeSeriesType::DyDt) { mpr_at.set_entry(r_mpr, c++, odat[k]); mpr_at.set_entry(r_mpr, c++, it->second.o_na[k]); mpr_at.set_entry(r_mpr, c++, (is_bad_data(odat[k]) || is_bad_data(it->second.o_na[k]) ? @@ -3992,7 +3992,7 @@ void write_job_ramp(STATAnalysisJob &job, // ctc_shc = it->second.hdr.get_shc(it->first, job.by_column, job.hdr_name, job.hdr_value, - stat_ctc); + STATLineType::ctc); // // Compute contingency table statistics, if requested @@ -4000,7 +4000,7 @@ void write_job_ramp(STATAnalysisJob &job, if(job.out_line_type.has(stat_cts_str)) { cts_shc = it->second.hdr.get_shc(it->first, job.by_column, job.hdr_name, job.hdr_value, - stat_cts); + STATLineType::cts); cts_shc.set_alpha(job.out_alpha); cts_info.compute_stats(); cts_info.compute_ci(); @@ -4160,7 +4160,7 @@ void write_job_ss_index(STATAnalysisJob &job, // Format the output STAT header columns // shc = it->second.hdr.get_shc(it->first, job.by_column, - job.hdr_name, job.hdr_value, stat_ssidx); + job.hdr_name, job.hdr_value, STATLineType::ssidx); // // Set FCST/OBS_VAR = skill score index type @@ -4329,8 +4329,8 @@ void do_job_ramp(const ConcatString &jobstring, LineDataFile &f, // // Check the ramp type // - if(job.ramp_type != TimeSeriesType_DyDt && - job.ramp_type != TimeSeriesType_Swing) { + if(job.ramp_type != TimeSeriesType::DyDt && + job.ramp_type != TimeSeriesType::Swing) { mlog << Error << "\ndo_job_ramp() -> " << "unsupported \"-ramp_type\" option: " << jobstring << "\n\n"; @@ -4340,7 +4340,7 @@ void do_job_ramp(const ConcatString &jobstring, LineDataFile &f, // // Check swing_width for the swinging door algorithm // - if(job.ramp_type == TimeSeriesType_Swing && + if(job.ramp_type == TimeSeriesType::Swing && is_bad_data(job.swing_width)) { mlog << Error << "\ndo_job_ramp() -> " << "the \"-swing_width\" option is required for \"-ramp_type SWING\": " diff --git a/src/tools/core/wavelet_stat/wavelet_stat.cc b/src/tools/core/wavelet_stat/wavelet_stat.cc index 827662caf8..27d868d78b 100644 --- a/src/tools/core/wavelet_stat/wavelet_stat.cc +++ b/src/tools/core/wavelet_stat/wavelet_stat.cc @@ -401,13 +401,13 @@ void process_scores() { << " versus " << conf_info.obs_info[i]->magic_str() << ".\n"; // Mask out the missing data between fields - if(conf_info.mask_missing_flag == FieldType_Fcst || - conf_info.mask_missing_flag == FieldType_Both) + if(conf_info.mask_missing_flag == FieldType::Fcst || + conf_info.mask_missing_flag == FieldType::Both) mask_bad_data(fcst_dp, obs_dp); // Mask out the missing data between fields - if(conf_info.mask_missing_flag == FieldType_Obs || - conf_info.mask_missing_flag == FieldType_Both) + if(conf_info.mask_missing_flag == FieldType::Obs || + conf_info.mask_missing_flag == FieldType::Both) mask_bad_data(obs_dp, fcst_dp); // Get the fill data value to be used for each field @@ -426,7 +426,7 @@ void process_scores() { fill_bad_data(obs_dp_fill, obs_fill); // Pad the fields out to the nearest power of two if requested - if(conf_info.grid_decomp_flag == GridDecompType_Pad) { + if(conf_info.grid_decomp_flag == GridDecompType::Pad) { mlog << Debug(2) << "Padding the fields out to the nearest integer " << "power of two.\n"; pad_field(fcst_dp_fill, fcst_fill); @@ -459,7 +459,7 @@ void process_scores() { get_tile(fcst_dp_fill, obs_dp_fill, i, j, f_na, o_na); // Compute Intensity-Scale scores - if(conf_info.output_flag[i_isc] != STATOutputType_None) { + if(conf_info.output_flag[i_isc] != STATOutputType::None) { // Do the intensity-scale decomposition do_intensity_scale(f_na, o_na, isc_info[j], i, j); @@ -599,7 +599,7 @@ void setup_txt_files(unixtime valid_ut, int lead_sec) { // ///////////////////////////////////////////////////////////////////// - if(conf_info.output_flag[i_isc] != STATOutputType_None) { + if(conf_info.output_flag[i_isc] != STATOutputType::None) { // Initialize file stream @@ -1887,7 +1887,7 @@ void close_out_files() { // Write out the contents of the ISC AsciiTable and // close the ISC output files - if(conf_info.output_flag[i_isc] == STATOutputType_Both) { + if(conf_info.output_flag[i_isc] == STATOutputType::Both) { if(isc_out) { *isc_out << isc_at; close_txt_file(isc_out, isc_file.c_str()); @@ -2745,7 +2745,7 @@ void draw_tiles(PSfile *p, Box &dim, for(i=tile_start; i<=tile_end; i++) { // If padding was performed, the tile is the size of the domain - if(conf_info.grid_decomp_flag == GridDecompType_Pad) { + if(conf_info.grid_decomp_flag == GridDecompType::Pad) { tile_bb = dim; } // Find the lower-left and upper-right corners of the tile diff --git a/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc b/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc index 4529fe0423..68b2c670d7 100644 --- a/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc +++ b/src/tools/core/wavelet_stat/wavelet_stat_conf_info.cc @@ -21,6 +21,7 @@ #include "vx_data2d_factory.h" #include "vx_log.h" +#include "enum_as_int.hpp" using namespace std; @@ -72,13 +73,13 @@ void WaveletStatConfInfo::clear() { model.clear(); desc.clear(); obtype.clear(); - mask_missing_flag = FieldType_None; - grid_decomp_flag = GridDecompType_None; + mask_missing_flag = FieldType::None; + grid_decomp_flag = GridDecompType::None; tile_dim = 0; tile_xll.clear(); tile_yll.clear(); pad_bb.set_llwh(0.0, 0.0, 0.0, 0.0); - wvlt_type = WaveletType_None; + wvlt_type = WaveletType::None; // nc_pairs_flag = false; nc_info.set_all_true(); ps_plot_flag = false; @@ -86,7 +87,7 @@ void WaveletStatConfInfo::clear() { output_prefix.clear(); version.clear(); - for(i=0; i " - << "Unsupported wavelet type value of " << wvlt_type << ".\n\n"; + << "Unsupported wavelet type value of " << enum_class_as_int(wvlt_type) << ".\n\n"; exit(1); } @@ -349,8 +350,8 @@ void WaveletStatConfInfo::process_config(GrdFileType ftype, // Check for valid member number switch(wvlt_type) { - case(WaveletType_Haar): - case(WaveletType_Haar_Cntr): + case(WaveletType::Haar): + case(WaveletType::Haar_Cntr): if(wvlt_member != 2) { mlog << Error << "\nWaveletStatConfInfo::process_config() -> " << "For Haar wavelets, \"" << conf_key_wavelet_member @@ -359,8 +360,8 @@ void WaveletStatConfInfo::process_config(GrdFileType ftype, } break; - case(WaveletType_Daub): - case(WaveletType_Daub_Cntr): + case(WaveletType::Daub): + case(WaveletType::Daub_Cntr): if(wvlt_member < 4 || wvlt_member > 20 || wvlt_member%2 == 1) { mlog << Error << "\nWaveletStatConfInfo::process_config() -> " << "For Daubechies wavelets, \"" << conf_key_wavelet_member @@ -369,8 +370,8 @@ void WaveletStatConfInfo::process_config(GrdFileType ftype, } break; - case(WaveletType_BSpline): - case(WaveletType_BSpline_Cntr): + case(WaveletType::BSpline): + case(WaveletType::BSpline_Cntr): if(wvlt_member != 103 && wvlt_member != 105 && wvlt_member != 202 && wvlt_member != 204 && wvlt_member != 206 && wvlt_member != 208 && wvlt_member != 301 && wvlt_member != 303 && wvlt_member != 305 && @@ -383,10 +384,10 @@ void WaveletStatConfInfo::process_config(GrdFileType ftype, } break; - case(WaveletType_None): + case(WaveletType::None): default: mlog << Error << "\nWaveletStatConfInfo::process_config() -> " - << "Unsupported wavelet type value of " << wvlt_type << ".\n\n"; + << "Unsupported wavelet type value of " << enum_class_as_int(wvlt_type) << ".\n\n"; exit(1); } @@ -510,7 +511,7 @@ void WaveletStatConfInfo::process_tiles(const Grid &grid) { // Tile the input data using tiles of dimension n by n where n // is the largest integer power of 2 less than the smallest // dimension of the input data and allowing no overlap. - case(GridDecompType_Auto): + case(GridDecompType::Auto): center_tiles(grid.nx(), grid.ny()); @@ -527,7 +528,7 @@ void WaveletStatConfInfo::process_tiles(const Grid &grid) { break; // Apply the tiles specified in the configuration file - case(GridDecompType_Tile): + case(GridDecompType::Tile): // Number of tiles based on the user-specified locations n_tile = tile_xll.n(); @@ -546,7 +547,7 @@ void WaveletStatConfInfo::process_tiles(const Grid &grid) { // Setup tiles for padding the input fields out to the nearest // integer power of two - case(GridDecompType_Pad): + case(GridDecompType::Pad): pad_tiles(grid.nx(), grid.ny()); @@ -561,11 +562,11 @@ void WaveletStatConfInfo::process_tiles(const Grid &grid) { break; - case(GridDecompType_None): + case(GridDecompType::None): default: mlog << Error << "\nWaveletStatConfInfo::process_tiles() -> " << "Unsupported grid decomposition type of " - << grid_decomp_flag << ".\n\n"; + << enum_class_as_int(grid_decomp_flag) << ".\n\n"; exit(1); } // end switch diff --git a/src/tools/core/wavelet_stat/wavelet_stat_conf_info.h b/src/tools/core/wavelet_stat/wavelet_stat_conf_info.h index 238ec65629..1380ecc6b3 100644 --- a/src/tools/core/wavelet_stat/wavelet_stat_conf_info.h +++ b/src/tools/core/wavelet_stat/wavelet_stat_conf_info.h @@ -34,7 +34,7 @@ static const int n_txt = 1; // Text file type static const STATLineType txt_file_type[n_txt] = { - stat_isc + STATLineType::isc }; //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/dev_utils/pbtime.cc b/src/tools/dev_utils/pbtime.cc index 85a228d41f..fc63f7952f 100644 --- a/src/tools/dev_utils/pbtime.cc +++ b/src/tools/dev_utils/pbtime.cc @@ -78,7 +78,7 @@ int met_main(int argc, char *argv[]) { blk_file = make_temp_file_name("/tmp/tmp_pbtime_blk", nullptr); // Block the PrepBufr file and open it for reading. - pblock(pb_file.c_str(), blk_file.c_str(), block); + pblock(pb_file.c_str(), blk_file.c_str(), Action::block); // Open the blocked temp PrepBufr file for reading openpb_(blk_file.c_str(), &file_unit); diff --git a/src/tools/other/ascii2nc/Makefile.am b/src/tools/other/ascii2nc/Makefile.am index 0647687561..ab69ead9f1 100644 --- a/src/tools/other/ascii2nc/Makefile.am +++ b/src/tools/other/ascii2nc/Makefile.am @@ -30,6 +30,7 @@ ascii2nc_SOURCES = ascii2nc.cc \ airnow_locations.cc airnow_locations.h \ aeronet_handler.cc aeronet_handler.h \ ismn_handler.cc ismn_handler.h \ + iabp_handler.cc iabp_handler.h \ $(OPT_PYTHON_SOURCES) ascii2nc_CPPFLAGS = ${MET_CPPFLAGS} -I../../../basic/vx_log diff --git a/src/tools/other/ascii2nc/Makefile.in b/src/tools/other/ascii2nc/Makefile.in index 4c364feb94..ccc217163a 100644 --- a/src/tools/other/ascii2nc/Makefile.in +++ b/src/tools/other/ascii2nc/Makefile.in @@ -110,8 +110,8 @@ am__ascii2nc_SOURCES_DIST = ascii2nc.cc ascii2nc_conf_info.cc \ airnow_handler.h ndbc_handler.cc ndbc_handler.h \ ndbc_locations.cc ndbc_locations.h airnow_locations.cc \ airnow_locations.h aeronet_handler.cc aeronet_handler.h \ - ismn_handler.cc ismn_handler.h python_handler.h \ - python_handler.cc + ismn_handler.cc ismn_handler.h iabp_handler.cc iabp_handler.h \ + python_handler.h python_handler.cc @ENABLE_PYTHON_TRUE@am__objects_1 = ascii2nc-python_handler.$(OBJEXT) am__objects_2 = $(am__objects_1) am_ascii2nc_OBJECTS = ascii2nc-ascii2nc.$(OBJEXT) \ @@ -126,7 +126,8 @@ am_ascii2nc_OBJECTS = ascii2nc-ascii2nc.$(OBJEXT) \ ascii2nc-ndbc_locations.$(OBJEXT) \ ascii2nc-airnow_locations.$(OBJEXT) \ ascii2nc-aeronet_handler.$(OBJEXT) \ - ascii2nc-ismn_handler.$(OBJEXT) $(am__objects_2) + ascii2nc-ismn_handler.$(OBJEXT) \ + ascii2nc-iabp_handler.$(OBJEXT) $(am__objects_2) ascii2nc_OBJECTS = $(am_ascii2nc_OBJECTS) am__DEPENDENCIES_1 = ascii2nc_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ @@ -155,6 +156,7 @@ am__depfiles_remade = ./$(DEPDIR)/ascii2nc-aeronet_handler.Po \ ./$(DEPDIR)/ascii2nc-ascii2nc.Po \ ./$(DEPDIR)/ascii2nc-ascii2nc_conf_info.Po \ ./$(DEPDIR)/ascii2nc-file_handler.Po \ + ./$(DEPDIR)/ascii2nc-iabp_handler.Po \ ./$(DEPDIR)/ascii2nc-ismn_handler.Po \ ./$(DEPDIR)/ascii2nc-little_r_handler.Po \ ./$(DEPDIR)/ascii2nc-met_handler.Po \ @@ -392,6 +394,7 @@ ascii2nc_SOURCES = ascii2nc.cc \ airnow_locations.cc airnow_locations.h \ aeronet_handler.cc aeronet_handler.h \ ismn_handler.cc ismn_handler.h \ + iabp_handler.cc iabp_handler.h \ $(OPT_PYTHON_SOURCES) ascii2nc_CPPFLAGS = ${MET_CPPFLAGS} -I../../../basic/vx_log @@ -519,6 +522,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ascii2nc-ascii2nc.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ascii2nc-ascii2nc_conf_info.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ascii2nc-file_handler.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ascii2nc-iabp_handler.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ascii2nc-ismn_handler.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ascii2nc-little_r_handler.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ascii2nc-met_handler.Po@am__quote@ # am--include-marker @@ -730,6 +734,20 @@ ascii2nc-ismn_handler.obj: ismn_handler.cc @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ascii2nc_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o ascii2nc-ismn_handler.obj `if test -f 'ismn_handler.cc'; then $(CYGPATH_W) 'ismn_handler.cc'; else $(CYGPATH_W) '$(srcdir)/ismn_handler.cc'; fi` +ascii2nc-iabp_handler.o: iabp_handler.cc +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ascii2nc_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT ascii2nc-iabp_handler.o -MD -MP -MF $(DEPDIR)/ascii2nc-iabp_handler.Tpo -c -o ascii2nc-iabp_handler.o `test -f 'iabp_handler.cc' || echo '$(srcdir)/'`iabp_handler.cc +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/ascii2nc-iabp_handler.Tpo $(DEPDIR)/ascii2nc-iabp_handler.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='iabp_handler.cc' object='ascii2nc-iabp_handler.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ascii2nc_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o ascii2nc-iabp_handler.o `test -f 'iabp_handler.cc' || echo '$(srcdir)/'`iabp_handler.cc + +ascii2nc-iabp_handler.obj: iabp_handler.cc +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ascii2nc_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT ascii2nc-iabp_handler.obj -MD -MP -MF $(DEPDIR)/ascii2nc-iabp_handler.Tpo -c -o ascii2nc-iabp_handler.obj `if test -f 'iabp_handler.cc'; then $(CYGPATH_W) 'iabp_handler.cc'; else $(CYGPATH_W) '$(srcdir)/iabp_handler.cc'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/ascii2nc-iabp_handler.Tpo $(DEPDIR)/ascii2nc-iabp_handler.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='iabp_handler.cc' object='ascii2nc-iabp_handler.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ascii2nc_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o ascii2nc-iabp_handler.obj `if test -f 'iabp_handler.cc'; then $(CYGPATH_W) 'iabp_handler.cc'; else $(CYGPATH_W) '$(srcdir)/iabp_handler.cc'; fi` + ascii2nc-python_handler.o: python_handler.cc @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(ascii2nc_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT ascii2nc-python_handler.o -MD -MP -MF $(DEPDIR)/ascii2nc-python_handler.Tpo -c -o ascii2nc-python_handler.o `test -f 'python_handler.cc' || echo '$(srcdir)/'`python_handler.cc @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/ascii2nc-python_handler.Tpo $(DEPDIR)/ascii2nc-python_handler.Po @@ -877,6 +895,7 @@ distclean: distclean-am -rm -f ./$(DEPDIR)/ascii2nc-ascii2nc.Po -rm -f ./$(DEPDIR)/ascii2nc-ascii2nc_conf_info.Po -rm -f ./$(DEPDIR)/ascii2nc-file_handler.Po + -rm -f ./$(DEPDIR)/ascii2nc-iabp_handler.Po -rm -f ./$(DEPDIR)/ascii2nc-ismn_handler.Po -rm -f ./$(DEPDIR)/ascii2nc-little_r_handler.Po -rm -f ./$(DEPDIR)/ascii2nc-met_handler.Po @@ -936,6 +955,7 @@ maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/ascii2nc-ascii2nc.Po -rm -f ./$(DEPDIR)/ascii2nc-ascii2nc_conf_info.Po -rm -f ./$(DEPDIR)/ascii2nc-file_handler.Po + -rm -f ./$(DEPDIR)/ascii2nc-iabp_handler.Po -rm -f ./$(DEPDIR)/ascii2nc-ismn_handler.Po -rm -f ./$(DEPDIR)/ascii2nc-little_r_handler.Po -rm -f ./$(DEPDIR)/ascii2nc-met_handler.Po diff --git a/src/tools/other/ascii2nc/ascii2nc.cc b/src/tools/other/ascii2nc/ascii2nc.cc index d3ef7062d7..940e12cedf 100644 --- a/src/tools/other/ascii2nc/ascii2nc.cc +++ b/src/tools/other/ascii2nc/ascii2nc.cc @@ -86,6 +86,7 @@ #include "airnow_handler.h" #include "ndbc_handler.h" #include "ismn_handler.h" +#include "iabp_handler.h" #ifdef ENABLE_PYTHON #include "global_python.h" @@ -106,22 +107,23 @@ static const char *DEFAULT_CONFIG_FILENAME = //////////////////////////////////////////////////////////////////////// // Supported input ASCII formats -enum ASCIIFormat { - ASCIIFormat_None, - ASCIIFormat_MET, - ASCIIFormat_Little_R, - ASCIIFormat_SurfRad, - ASCIIFormat_WWSIS, - ASCIIFormat_Airnow_dailyv2, - ASCIIFormat_Airnow_hourlyaqobs, - ASCIIFormat_Airnow_hourly, - ASCIIFormat_NDBC_standard, - ASCIIFormat_ISMN, - ASCIIFormat_Aeronet_v2, - ASCIIFormat_Aeronet_v3, - ASCIIFormat_Python, +enum class ASCIIFormat { + None, + MET, + Little_R, + SurfRad, + WWSIS, + Airnow_dailyv2, + Airnow_hourlyaqobs, + Airnow_hourly, + NDBC_standard, + ISMN, + IABP, + Aeronet_v2, + Aeronet_v3, + Python, }; -static ASCIIFormat ascii_format = ASCIIFormat_None; +static ASCIIFormat ascii_format = ASCIIFormat::None; //////////////////////////////////////////////////////////////////////// @@ -137,6 +139,10 @@ static MaskPlane mask_area; static MaskPoly mask_poly; static StringArray mask_sid; +// Beginning and ending times +static unixtime valid_beg_ut; +static unixtime valid_end_ut; + static int compress_level = -1; //////////////////////////////////////////////////////////////////////// @@ -152,6 +158,8 @@ static void set_mask_grid(const StringArray &); static void set_mask_poly(const StringArray &); static void set_mask_sid(const StringArray &); static void set_compress(const StringArray &); +static void set_valid_beg_time(const StringArray &); +static void set_valid_end_time(const StringArray &); static void setup_wrapper_path(); @@ -166,6 +174,9 @@ int met_main(int argc, char *argv[]) { // if(argc == 1) { usage(); return 0; } + // Initialize time range + valid_beg_ut = valid_end_ut = (unixtime) 0; + // // Parse the command line into tokens // @@ -184,6 +195,8 @@ int met_main(int argc, char *argv[]) { cline.add(set_mask_grid, "-mask_grid", 1); cline.add(set_mask_poly, "-mask_poly", 1); cline.add(set_mask_sid, "-mask_sid", 1); + cline.add(set_valid_beg_time, "-valid_beg", 1); + cline.add(set_valid_end_time, "-valid_end", 1); cline.add(set_compress, "-compress", 1); // @@ -211,6 +224,17 @@ int met_main(int argc, char *argv[]) { << "Config File: " << config_filename << "\n"; config_info.read_config(DEFAULT_CONFIG_FILENAME, config_filename.text()); + // Check that valid_end_ut >= valid_beg_ut + if(valid_beg_ut != (unixtime) 0 && + valid_end_ut != (unixtime) 0 && + valid_beg_ut > valid_end_ut) { + mlog << Error << "\nmet_main() -> " + << "the ending time (" << unix_to_yyyymmdd_hhmmss(valid_end_ut) + << ") must be greater than the beginning time (" + << unix_to_yyyymmdd_hhmmss(valid_beg_ut) << ").\n\n"; + exit(1); + } + // // Create the file handler based on the ascii format specified on // the command line. If one wasn't specified, we'll look in the @@ -225,7 +249,8 @@ int met_main(int argc, char *argv[]) { if(deflate_level > 9) deflate_level = config_info.get_compression_level(); file_handler->setCompressionLevel(deflate_level); file_handler->setSummaryInfo(config_info.getSummaryInfo()); - + file_handler->setValidTimeRange(valid_beg_ut, valid_end_ut); + // // Set the masking grid and polyline, if specified. // @@ -286,63 +311,67 @@ FileHandler *create_file_handler(const ASCIIFormat format, const ConcatString &a // file to guess the format. // switch(format) { - case ASCIIFormat_MET: { + case ASCIIFormat::MET: { return (FileHandler *) new MetHandler(program_name); } - case ASCIIFormat_Little_R: { + case ASCIIFormat::Little_R: { return (FileHandler *) new LittleRHandler(program_name); } - case ASCIIFormat_SurfRad: { + case ASCIIFormat::SurfRad: { return (FileHandler *) new SurfradHandler(program_name); } - case ASCIIFormat_WWSIS: { + case ASCIIFormat::WWSIS: { return (FileHandler *) new WwsisHandler(program_name); } - case ASCIIFormat_Airnow_dailyv2: { + case ASCIIFormat::Airnow_dailyv2: { AirnowHandler *handler = new AirnowHandler(program_name); handler->setFormatVersion(AirnowHandler::AIRNOW_FORMAT_VERSION_DAILYV2); return (FileHandler *) handler; } - case ASCIIFormat_Airnow_hourlyaqobs: { + case ASCIIFormat::Airnow_hourlyaqobs: { AirnowHandler *handler = new AirnowHandler(program_name); handler->setFormatVersion(AirnowHandler::AIRNOW_FORMAT_VERSION_HOURLYAQOBS); return (FileHandler *) handler; } - case ASCIIFormat_Airnow_hourly: { + case ASCIIFormat::Airnow_hourly: { AirnowHandler *handler = new AirnowHandler(program_name); handler->setFormatVersion(AirnowHandler::AIRNOW_FORMAT_VERSION_HOURLY); return (FileHandler *) handler; } - case ASCIIFormat_NDBC_standard: { + case ASCIIFormat::NDBC_standard: { NdbcHandler *handler = new NdbcHandler(program_name); handler->setFormatVersion(NdbcHandler::NDBC_FORMAT_VERSION_STANDARD); return (FileHandler *) handler; } - case ASCIIFormat_ISMN: { + case ASCIIFormat::ISMN: { return (FileHandler *) new IsmnHandler(program_name); } - case ASCIIFormat_Aeronet_v2: { + case ASCIIFormat::IABP: { + return((FileHandler *) new IabpHandler(program_name)); + } + + case ASCIIFormat::Aeronet_v2: { AeronetHandler *handler = new AeronetHandler(program_name); handler->setFormatVersion(2); return (FileHandler *) handler; } - case ASCIIFormat_Aeronet_v3: { + case ASCIIFormat::Aeronet_v3: { AeronetHandler *handler = new AeronetHandler(program_name); handler->setFormatVersion(3); return (FileHandler *) handler; } #ifdef ENABLE_PYTHON - case ASCIIFormat_Python: { + case ASCIIFormat::Python: { setup_wrapper_path(); ph = new PythonHandler(program_name, ascii_filename.text()); return (FileHandler *) ph; @@ -375,6 +404,22 @@ FileHandler *determine_ascii_format(const ConcatString &ascii_filename) { exit(1); } + // + // See if this is an IABP file. + // put this first as it can have the same number of columns as some + // other ones, which look only at the number of columns + // + f_in.rewind(); + IabpHandler *iabp_file = new IabpHandler(program_name); + + if(iabp_file->isFileType(f_in)) { + f_in.close(); + return((FileHandler *) iabp_file); + } + + delete iabp_file; + + // // See if this is a MET file. // @@ -505,6 +550,8 @@ void usage() { << "\t[-mask_sid file|list]\n" << "\t[-log file]\n" << "\t[-v level]\n" + << "\t[-valid_beg time]\n" + << "\t[-valid_end time]\n" << "\t[-compress level]\n\n" << "\twhere\t\"ascii_file\" is the formatted ASCII " @@ -524,6 +571,7 @@ void usage() { << AirnowHandler::getFormatStringHourly() << "\", \"" << NdbcHandler::getFormatStringStandard() << "\", \"" << IsmnHandler::getFormatString() << "\", \"" + << IabpHandler::getFormatString() << "\", \"" << AeronetHandler::getFormatString() << "\", \"" << AeronetHandler::getFormatString_v2() << "\", \"" << AeronetHandler::getFormatString_v3() << "\""; @@ -556,6 +604,12 @@ void usage() { << "\t\t\"-v level\" overrides the default level of logging (" << mlog.verbosity_level() << ") (optional).\n" + << "\t\t\"-valid_beg time\" in YYYYMMDD[_HH[MMSS]] sets the " + << "beginning of the processed data time window (optional).\n" + + << "\t\t\"-valid_end time\" in YYYYMMDD[_HH[MMSS]] sets the " + << "end of the processed data time window (optional).\n" + << "\t\t\"-compress level\" overrides the compression level of NetCDF variable (" << config_info.get_compression_level() << ") (optional).\n\n" @@ -583,42 +637,45 @@ void usage() { void set_format(const StringArray & a) { if(MetHandler::getFormatString() == a[0]) { - ascii_format = ASCIIFormat_MET; + ascii_format = ASCIIFormat::MET; } else if(LittleRHandler::getFormatString() == a[0]) { - ascii_format = ASCIIFormat_Little_R; + ascii_format = ASCIIFormat::Little_R; } else if(SurfradHandler::getFormatString() == a[0]) { - ascii_format = ASCIIFormat_SurfRad; + ascii_format = ASCIIFormat::SurfRad; } else if(WwsisHandler::getFormatString() == a[0]) { - ascii_format = ASCIIFormat_WWSIS; + ascii_format = ASCIIFormat::WWSIS; } else if(AirnowHandler::getFormatStringDailyV2() == a[0]) { - ascii_format = ASCIIFormat_Airnow_dailyv2; + ascii_format = ASCIIFormat::Airnow_dailyv2; } else if(AirnowHandler::getFormatStringHourlyAqObs() == a[0]) { - ascii_format = ASCIIFormat_Airnow_hourlyaqobs; + ascii_format = ASCIIFormat::Airnow_hourlyaqobs; } else if(AirnowHandler::getFormatStringHourly() == a[0]) { - ascii_format = ASCIIFormat_Airnow_hourly; + ascii_format = ASCIIFormat::Airnow_hourly; } else if(NdbcHandler::getFormatStringStandard() == a[0]) { - ascii_format = ASCIIFormat_NDBC_standard; + ascii_format = ASCIIFormat::NDBC_standard; } else if(IsmnHandler::getFormatString() == a[0]) { - ascii_format = ASCIIFormat_ISMN; + ascii_format = ASCIIFormat::ISMN; + } + else if(IabpHandler::getFormatString() == a[0]) { + ascii_format = ASCIIFormat::IABP; } else if(AeronetHandler::getFormatString() == a[0] || AeronetHandler::getFormatString_v2() == a[0]) { - ascii_format = ASCIIFormat_Aeronet_v2; + ascii_format = ASCIIFormat::Aeronet_v2; } else if(AeronetHandler::getFormatString_v3() == a[0]) { - ascii_format = ASCIIFormat_Aeronet_v3; + ascii_format = ASCIIFormat::Aeronet_v3; } #ifdef ENABLE_PYTHON else if(PythonHandler::getFormatString() == a[0]) { - ascii_format = ASCIIFormat_Python; + ascii_format = ASCIIFormat::Python; } #endif else if("python" == a[0]) { @@ -702,6 +759,20 @@ void set_mask_sid(const StringArray & a) { //////////////////////////////////////////////////////////////////////// +void set_valid_beg_time(const StringArray & a) +{ + valid_beg_ut = timestring_to_unix(a[0].c_str()); +} + +//////////////////////////////////////////////////////////////////////// + +void set_valid_end_time(const StringArray & a) +{ + valid_end_ut = timestring_to_unix(a[0].c_str()); +} + +//////////////////////////////////////////////////////////////////////// + void set_compress(const StringArray & a) { compress_level = atoi(a[0].c_str()); } diff --git a/src/tools/other/ascii2nc/file_handler.cc b/src/tools/other/ascii2nc/file_handler.cc index 6e2521f0c8..5495c8b6dc 100644 --- a/src/tools/other/ascii2nc/file_handler.cc +++ b/src/tools/other/ascii2nc/file_handler.cc @@ -57,7 +57,9 @@ FileHandler::FileHandler(const string &program_name) : use_var_id(false), do_monitor(false), deflate_level(DEF_DEFLATE_LEVEL), - _dataSummarized(false) + _dataSummarized(false), + valid_beg_ut((time_t)0), + valid_end_ut((time_t)0) { } @@ -77,6 +79,12 @@ bool FileHandler::readAsciiFiles(const vector< ConcatString > &ascii_filename_li // Loop through the ASCII files, reading in the observations. At the end of // this loop, all of the observations will be in the _observations vector. + // + // debug counts + // + num_observations_in_range = 0; + num_observations_out_of_range = 0; + for (vector< ConcatString >::const_iterator ascii_filename = ascii_filename_list.begin(); ascii_filename != ascii_filename_list.end(); ++ascii_filename) { @@ -103,6 +111,9 @@ bool FileHandler::readAsciiFiles(const vector< ConcatString > &ascii_filename_li ascii_file.close(); } + mlog << Debug(2) << " Kept " << num_observations_in_range + << " observations, rejected (out of range) " << num_observations_out_of_range + << " observations\n"; return true; } @@ -172,6 +183,14 @@ void FileHandler::setSummaryInfo(const TimeSummaryInfo &summary_info) { //////////////////////////////////////////////////////////////////////// +void FileHandler::setValidTimeRange(const time_t &valid_beg, const time_t valid_end) +{ + valid_beg_ut = valid_beg; + valid_end_ut = valid_end; +} + +//////////////////////////////////////////////////////////////////////// + bool FileHandler::summarizeObs(const TimeSummaryInfo &summary_info) { bool result = summary_obs.summarizeObs(summary_info); @@ -275,6 +294,16 @@ bool FileHandler::_addObservations(const Observation &obs) // if(filters.is_filtered_sid(obs.getStationId().c_str())) return false; + // + // Check if valid time is in range + // + if (_keep_valid_time(obs.getValidTime())) { + num_observations_in_range++; + } else { + num_observations_out_of_range++; + return false; + } + // Save obs because the obs vector is sorted after time summary _observations.push_back(obs); if (do_summary) summary_obs.addObservationObj(obs); @@ -334,3 +363,23 @@ void FileHandler::debug_print_observations(vector< Observation > my_observation, } //////////////////////////////////////////////////////////////////////// + +bool FileHandler::_keep_valid_time(const time_t &valid_time) const +{ + bool keep = true; + + // If valid times are both set, check the range + if (valid_beg_ut != (time_t) 0 && valid_end_ut != (time_t) 0) { + if (valid_time < valid_beg_ut || valid_time > valid_end_ut) keep = false; + } + // If only beg set, check the lower bound + else if (valid_beg_ut != (time_t) 0 && valid_end_ut == (time_t) 0) { + if (valid_time < valid_beg_ut) keep = false; + } + // If only end set, check the upper bound + else if (valid_beg_ut == (time_t) 0 && valid_end_ut != (time_t) 0) { + if (valid_time > valid_end_ut) keep = false; + } + return(keep); +} + diff --git a/src/tools/other/ascii2nc/file_handler.h b/src/tools/other/ascii2nc/file_handler.h index af721c008c..07d77e54f3 100644 --- a/src/tools/other/ascii2nc/file_handler.h +++ b/src/tools/other/ascii2nc/file_handler.h @@ -66,7 +66,7 @@ class FileHandler void setCompressionLevel(int compressoion_level); void setSummaryInfo(bool new_do_summary); void setSummaryInfo(const TimeSummaryInfo &summary_info); - + void setValidTimeRange(const time_t &valid_beg, const time_t valid_end); protected: @@ -114,6 +114,10 @@ class FileHandler TimeSummaryInfo _summaryInfo; SummaryObs summary_obs; + time_t valid_beg_ut, valid_end_ut; + int num_observations_in_range; + int num_observations_out_of_range; + /////////////////////// // Protected methods // /////////////////////// @@ -143,6 +147,9 @@ class FileHandler void _closeNetcdf(); bool _openNetcdf(const std::string &nc_filename); void debug_print_observations(std::vector< Observation >, std::string); + + bool _keep_valid_time(const time_t &valid_time) const; + }; inline void FileHandler::setCompressionLevel(int compressoion_level) { deflate_level = compressoion_level; } diff --git a/src/tools/other/ascii2nc/iabp_handler.cc b/src/tools/other/ascii2nc/iabp_handler.cc new file mode 100644 index 0000000000..71ce27f10c --- /dev/null +++ b/src/tools/other/ascii2nc/iabp_handler.cc @@ -0,0 +1,273 @@ +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* +// ** Copyright UCAR (c) 1992 - 2024 +// ** University Corporation for Atmospheric Research (UCAR) +// ** National Center for Atmospheric Research (NCAR) +// ** Research Applications Lab (RAL) +// ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA +// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=* + +//////////////////////////////////////////////////////////////////////// + +using namespace std; + +#include + +#include "vx_log.h" +#include "vx_math.h" +#include "vx_util.h" + +#include "iabp_handler.h" + +const double IabpHandler::IABP_MISSING_VALUE = -999.0; + + +const int IabpHandler::MIN_NUM_HDR_COLS = 8; + +// days in the month +static int daysOfMonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + +static int _lookfor(const DataLine &dl, const string &name); +static int _lookfor(const DataLine &dl, const string &name, const string &ascii_file, bool &ok); +static time_t _time(const string &syear, const string &shour, const string &smin, const string &sdoy); + + +//////////////////////////////////////////////////////////////////////// +// +// Code for class IabpHandler +// +//////////////////////////////////////////////////////////////////////// + +IabpHandler::IabpHandler(const string &program_name) : + FileHandler(program_name) { + use_var_id = true; +} + +//////////////////////////////////////////////////////////////////////// + +IabpHandler::~IabpHandler() { +} + +//////////////////////////////////////////////////////////////////////// + +bool IabpHandler::isFileType(LineDataFile &ascii_file) const { + + // IABP files are identified by having a .dat suffix and + // checking the always present data columns. + // The header look like this: + // BuoyID Year Hour Min DOY POS_DOY Lat Lon [ BP Ts Ta] + + // Initialize using the filename suffix + bool is_file_type = check_prefix_suffix(ascii_file.short_filename(), + nullptr, ".dat"); + + // Read the header line + DataLine dl; + while(dl.n_items() == 0) ascii_file >> dl; + + // Check the minimum number of header columns + if(dl.n_items() < MIN_NUM_HDR_COLS) { + return false; + } + + string line = dl.get_line(); + ConcatString cstring(line); + + StringArray tokens = cstring.split(" "); + if (tokens[0] != "BuoyID") is_file_type = false; + if (tokens[1] != "Year") is_file_type = false; + if (tokens[2] != "Hour") is_file_type = false; + if (tokens[3] != "Min") is_file_type = false; + if (tokens[4] != "DOY") is_file_type = false; + if (tokens[5] != "POS_DOY") is_file_type = false; + if (tokens[6] != "Lat") is_file_type = false; + if (tokens[7] != "Lon") is_file_type = false; + + return(is_file_type); +} + +//////////////////////////////////////////////////////////////////////// +// Private/Protected methods +//////////////////////////////////////////////////////////////////////// + +bool IabpHandler::_readObservations(LineDataFile &ascii_file) +{ + // Read and save the header information + if(!_readHeaderInfo(ascii_file)) return(false); + + string header_type = "IABP_STANDARD"; + + // Process the observation lines + DataLine dl; + while(ascii_file >> dl) { + + // Make sure that the line contains the correct number of tokens + if(dl.n_items() != _numColumns) { + mlog << Error << "\nIabpHandler::_readObervations() -> " + << "unexpected number of columns (" << dl.n_items() + << " != " << _numColumns << ") on line number " + << dl.line_number() << " of IABP file \"" + << ascii_file.filename() << "\"!\n\n"; + return(false); + } + + // Extract the valid time from the data line, using POS_DOY (scientist is most + // interested in location) Use POS_DOY to compute the month and day based on year + // (to handle leap year) + time_t valid_time = _time(dl[_yearPtr], dl[_hourPtr], dl[_minutePtr], dl[_posdoyPtr]); + if(valid_time == 0) { + mlog << Warning << "\nIabpHandler::_readObservations() -> " + << "No valid time computed in file, line number " + << dl.line_number() << " of IABP file \"" + << ascii_file.filename() << "\". Ignore this line\n\n"; + return(false); + } + + double lat = stod(dl[_latPtr]); + double lon = stod(dl[_lonPtr]); + string stationId = dl[_idPtr]; + string quality_flag = na_str; + int grib_code = 0; + double height_m = bad_data_double; + double pres = bad_data_double; + double elev = bad_data_double; + double ts = bad_data_double; + double ta = bad_data_double; + + if (lat == IABP_MISSING_VALUE || lon == IABP_MISSING_VALUE) { + // This is either a rare event or never happens + mlog << Warning << "\nIabpHandler::_readObservations() -> " + << "Latitude/longitude has missing value " << IABP_MISSING_VALUE + << ", line number " << dl.line_number() << " of IABP file \"" + << ascii_file.filename() << "\". Ignore this line\n\n"; + return(false); + } + + if (_bpPtr >= 0) { + // is this the right placeholder for this? To always put it in to the + // fixed slot of an observation? + pres = stod(dl[_bpPtr]); + if (pres == IABP_MISSING_VALUE) { + pres = bad_data_double; + } + } + + // Add a location placeholder observation in case neither of the temps are available + // Otherwise there would be no observations for this entry, and we want to have + // valid entries for every time/lat/lon. + _addObservations(Observation( + header_type, stationId, valid_time, + lat, lon, elev, quality_flag, grib_code, + pres, height_m, 1.0, "Location")); + grib_code++; + + if (_tsPtr >= 0) { + ts = stod(dl[_tsPtr]); + if (ts != IABP_MISSING_VALUE) { + _addObservations(Observation( + header_type, stationId, valid_time, + lat, lon, elev, quality_flag, grib_code, + pres, height_m, ts, "Temp_surface")); + grib_code++; + } + } + if (_taPtr >= 0) { + ta = stod(dl[_taPtr]); + if (ta != IABP_MISSING_VALUE) { + _addObservations(Observation( + header_type, stationId, valid_time, + lat, lon, elev, quality_flag, grib_code, + pres, height_m, ta, "Temp_air")); + } + } + + + + } // end while + + return(true); +} + +// //////////////////////////////////////////////////////////////////////// + +bool IabpHandler::_readHeaderInfo(LineDataFile &ascii_file) { + + DataLine dl; + if (!(ascii_file >> dl)) + { + mlog << Error << "\nIabpHandler::_readHeaderInfo() -> " + << "error reading header line from input ASCII file \"" + << ascii_file.filename() << "\"\n\n"; + return false; + } + + // Check the minimum number of header columns + if(dl.n_items() < MIN_NUM_HDR_COLS) { + mlog << Error << "\nIabpHandler::_readHeaderInfo() -> " + << "unexpected number of header columns (" + << dl.n_items() << " < " << MIN_NUM_HDR_COLS + << ") in IABP file \"" << ascii_file.filename() + << "\"!\n\n"; + return(false); + } + + // Map the header information to column numbers + bool ok = true; + string filename = ascii_file.filename(); + _idPtr = _lookfor(dl, "BuoyID", filename, ok); + _yearPtr = _lookfor(dl, "Year", filename, ok); + _hourPtr = _lookfor(dl, "Hour", filename, ok); + _minutePtr = _lookfor(dl, "Min", filename, ok); + _doyPtr = _lookfor(dl, "DOY", filename, ok); + _posdoyPtr = _lookfor(dl, "POS_DOY", filename, ok); + _latPtr = _lookfor(dl, "Lat", filename, ok); + _lonPtr = _lookfor(dl, "Lon", filename, ok); + _numColumns = MIN_NUM_HDR_COLS; + _bpPtr = _lookfor(dl, "BP"); + if (_bpPtr >= 0) ++_numColumns; + _tsPtr = _lookfor(dl, "Ts"); + if (_tsPtr >= 0) ++_numColumns; + _taPtr = _lookfor(dl, "Ta"); + if (_taPtr >= 0) ++_numColumns; + return ok; +} + +//////////////////////////////////////////////////////////////////////// + +static int _lookfor(const DataLine &dl, const string &name, const string &ascii_file, bool &ok) +{ + for (int i=0; i " + << "reading ASCII file \"" + << ascii_file << "\" did not find expected header item:\"" << name << "\" ignore file\n\n"; + ok = false; + return -1; +} + +//////////////////////////////////////////////////////////////////////// + +static int _lookfor(const DataLine &dl, const string &name) +{ + for (int i=0; i +#include + +#include "file_handler.h" + +//////////////////////////////////////////////////////////////////////// +// +// International Arctic Buoy Programme +// https://iabp.apl.uw.edu/data.html +// Files pulled from: +// https://iabp.apl.uw.edu/WebData/ +// +// +// Dataset file names: +// .dat where is an integer. +// +// Dataset Conents: +// +// Buoy data files are updated daily and made available individually at the WebData URL above. +// Values provided are confined to surface temperature,atmospheric temperature, and barometric pressure when these values are available. +// All buoy files contain at least dates and positions. +// Each file has a header line and one or more data lines. +// +// Header Line example (BP Ts and Ta are not always present, any subset could be there or not): +// +// BuoyID Year Hour Min DOY POS_DOY Lat Lon BP Ts Ta +// +// Record Lines (many per file, typically): +// Each file contains data from all buoys on a given date. +// Data includes: BuoyID, year, hour, minute, Day of Year, Position Day of year, +// latitude, longitude, [Barometric Pressure], [Surface Temp], and [Atmospheric Temp]. +// The last 3 values are optional and depend on the header line. +// +// Record line Example +// +// 5318 2014 02 20 28.0970 28.0930 72.75970 -165.25190 1016.62 -999.00 -13.92 +// +// It looks like the missing data value is -999.0, but this might not always be the case, it seems to not be documented. +// + +//////////////////////////////////////////////////////////////////////// + +class IabpHandler : public FileHandler { + + public: + + IabpHandler(const string &program_name); + virtual ~IabpHandler(); + + virtual bool isFileType(LineDataFile &ascii_file) const; + + static string getFormatString() { return "iabp"; } + + protected: + + ///////////////////////// + // Protected constants + ///////////////////////// + + // The minimum number of columns in the header line in the file. + static const int MIN_NUM_HDR_COLS; + + // a missing data value found in some iabp files + static const double IABP_MISSING_VALUE; + + /////////////////////// + // Protected members + /////////////////////// + + // Store list of unqiue output variable names + StringArray _varNames; + + // pointers based on header content + int _idPtr; + int _yearPtr; + int _hourPtr; + int _minutePtr; + int _doyPtr; + int _posdoyPtr; + int _latPtr; + int _lonPtr; + int _bpPtr; + int _tsPtr; + int _taPtr; + + // depends on which of the optional data types are present in a file + int _numColumns; + + string _buoyId; + time_t _validTime; + double _stationLat; + double _stationLon; + double _stationElv; + double _bp; + double _ts; + double _ta; + + /////////////////////// + // Protected methods + /////////////////////// + + // Read and save the header information from the given file + bool _readHeaderInfo(LineDataFile &ascii_file); + + // Get the valid time from the observation line + // Read the observations and add them to the + // _observations vector + virtual bool _readObservations(LineDataFile &ascii_file); + + // compute the time value from inputs + time_t _time2(const string &syear, const string &shour, const string &smin, const string &sdoy); +}; + +//////////////////////////////////////////////////////////////////////// + +#endif /* __IABP_HANDLER_H__ */ + +//////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/gen_ens_prod/gen_ens_prod.cc b/src/tools/other/gen_ens_prod/gen_ens_prod.cc index 81a28634d2..4de6c2b2b8 100644 --- a/src/tools/other/gen_ens_prod/gen_ens_prod.cc +++ b/src/tools/other/gen_ens_prod/gen_ens_prod.cc @@ -303,12 +303,12 @@ void process_ensemble() { // read climatology separately for each member set_climo_ens_mem_id = (conf_info.ens_member_ids.n() > 1) && - ((*var_it)->normalize == NormalizeType_ClimoAnom || - (*var_it)->normalize == NormalizeType_ClimoStdAnom); + ((*var_it)->normalize == NormalizeType::ClimoAnom || + (*var_it)->normalize == NormalizeType::ClimoStdAnom); // Print out the normalization flag cs << cs_erase; - if((*var_it)->normalize != NormalizeType_None) { + if((*var_it)->normalize != NormalizeType::None) { cs << " with normalize = " << normalizetype_to_string((*var_it)->normalize); } @@ -359,8 +359,8 @@ void process_ensemble() { i_ens, cmn_dp, csd_dp); // Compute the ensemble summary data, if needed - if((*var_it)->normalize == NormalizeType_FcstAnom || - (*var_it)->normalize == NormalizeType_FcstStdAnom) { + if((*var_it)->normalize == NormalizeType::FcstAnom || + (*var_it)->normalize == NormalizeType::FcstStdAnom) { get_ens_mean_stdev((*var_it), emn_dp, esd_dp); } else { @@ -394,7 +394,7 @@ void process_ensemble() { } // Normalize, if requested - if((*var_it)->normalize != NormalizeType_None) { + if((*var_it)->normalize != NormalizeType::None) { normalize_data(ctrl_dp, (*var_it)->normalize, &cmn_dp, &csd_dp, &emn_dp, &esd_dp); } @@ -421,7 +421,7 @@ void process_ensemble() { } // Normalize, if requested - if((*var_it)->normalize != NormalizeType_None) { + if((*var_it)->normalize != NormalizeType::None) { normalize_data(ens_dp, (*var_it)->normalize, &cmn_dp, &csd_dp, &emn_dp, &esd_dp); } @@ -950,7 +950,7 @@ void write_ens_nc(GenEnsProdVarInfo *ens_info, int n_ens_vld, // Loop over the neighborhoods for(j=0; jcat_ta[i].get_abbr_str().contents().c_str(), - interpmthd_to_string(InterpMthd_Nbrhd).c_str(), + interpmthd_to_string(InterpMthd::Nbrhd).c_str(), conf_info.nbrhd_prob.width[j]*conf_info.nbrhd_prob.width[j]); write_ens_data_plane(ens_info, nbrhd_dp, ens_dp, type_str, "Neighborhood Ensemble Probability"); @@ -1001,7 +1001,7 @@ void write_ens_nc(GenEnsProdVarInfo *ens_info, int n_ens_vld, // Write neighborhood maximum ensemble probability snprintf(type_str, sizeof(type_str), "ENS_NMEP_%s_%s%i_%s%i", ens_info->cat_ta[i].get_abbr_str().contents().c_str(), - interpmthd_to_string(InterpMthd_Nbrhd).c_str(), + interpmthd_to_string(InterpMthd::Nbrhd).c_str(), conf_info.nbrhd_prob.width[j]*conf_info.nbrhd_prob.width[j], conf_info.nmep_smooth.method[k].c_str(), conf_info.nmep_smooth.width[k]*conf_info.nmep_smooth.width[k]); diff --git a/src/tools/other/gen_ens_prod/gen_ens_prod_conf_info.cc b/src/tools/other/gen_ens_prod/gen_ens_prod_conf_info.cc index 81209ede28..52281061fd 100644 --- a/src/tools/other/gen_ens_prod/gen_ens_prod_conf_info.cc +++ b/src/tools/other/gen_ens_prod/gen_ens_prod_conf_info.cc @@ -304,9 +304,9 @@ void GenEnsProdConfInfo::process_config(GrdFileType etype, StringArray * ens_fil mthd = string_to_interpmthd(nmep_smooth.method[i].c_str()); // Check for unsupported neighborhood probability smoothing methods - if(mthd == InterpMthd_DW_Mean || - mthd == InterpMthd_LS_Fit || - mthd == InterpMthd_Bilin) { + if(mthd == InterpMthd::DW_Mean || + mthd == InterpMthd::LS_Fit || + mthd == InterpMthd::Bilin) { mlog << Error << "\nGenEnsProdConfInfo::process_config() -> " << "Neighborhood probability smoothing methods DW_MEAN, " << "LS_FIT, and BILIN are not supported for \"" diff --git a/src/tools/other/gen_vx_mask/gen_vx_mask.cc b/src/tools/other/gen_vx_mask/gen_vx_mask.cc index 36e54bb45e..e4c14b557b 100644 --- a/src/tools/other/gen_vx_mask/gen_vx_mask.cc +++ b/src/tools/other/gen_vx_mask/gen_vx_mask.cc @@ -53,6 +53,7 @@ #include "grib_classes.h" +#include "enum_as_int.hpp" #include "vx_log.h" #include "nav.h" #include "vx_math.h" @@ -82,11 +83,11 @@ int met_main(int argc, char *argv[]) { process_mask_file(dp_mask); // Apply combination logic if the current mask is binary - if(mask_type == MaskType_Poly || - mask_type == MaskType_Poly_XY || - mask_type == MaskType_Shape || - mask_type == MaskType_Box || - mask_type == MaskType_Grid || + if(mask_type == MaskType::Poly || + mask_type == MaskType::Poly_XY || + mask_type == MaskType::Shape || + mask_type == MaskType::Box || + mask_type == MaskType::Grid || thresh.get_type() != thresh_na) { dp_out = combine(dp_data, dp_mask, set_logic); } @@ -155,7 +156,7 @@ void process_command_line(int argc, char **argv) { out_filename = cline[2]; // Check for the mask type (from -type string) - if(mask_type == MaskType_None) { + if(mask_type == MaskType::None) { mlog << Error << "\n" << program_name << " -> " << "the -type command line requirement must be set to a specific masking type!\n" << "\t\t \"poly\", \"box\", \"circle\", \"track\", \"grid\", " @@ -223,11 +224,11 @@ void process_mask_file(DataPlane &dp) { solar_ut = (unixtime) 0; // Process the mask file as a lat/lon polyline file - if(mask_type == MaskType_Poly || - mask_type == MaskType_Poly_XY || - mask_type == MaskType_Box || - mask_type == MaskType_Circle || - mask_type == MaskType_Track) { + if(mask_type == MaskType::Poly || + mask_type == MaskType::Poly_XY || + mask_type == MaskType::Box || + mask_type == MaskType::Circle || + mask_type == MaskType::Track) { poly_mask.clear(); poly_mask.load(mask_filename.c_str()); @@ -238,7 +239,7 @@ void process_mask_file(DataPlane &dp) { } // Process the mask from a shapefile - else if(mask_type == MaskType_Shape) { + else if(mask_type == MaskType::Shape) { // If -shape_str was specified, find the matching records if(shape_str_map.size() > 0) get_shapefile_strings(); @@ -272,8 +273,8 @@ void process_mask_file(DataPlane &dp) { } // Nothing to do for Lat/Lon masking types - else if(mask_type == MaskType_Lat || - mask_type == MaskType_Lon) { + else if(mask_type == MaskType::Lat || + mask_type == MaskType::Lon) { } // Otherwise, process the mask file as a named grid, grid specification @@ -282,7 +283,7 @@ void process_mask_file(DataPlane &dp) { // For the grid mask type, support named grids and grid // specification strings - if(mask_type == MaskType_Grid) { + if(mask_type == MaskType::Grid) { // Parse the mask file as a white-space separated string StringArray sa; @@ -311,7 +312,7 @@ void process_mask_file(DataPlane &dp) { // Read the mask grid and data plane, if requested get_data_plane(mask_filename, mask_field_str, - mask_type == MaskType_Data, + mask_type == MaskType::Data, dp, grid_mask); } @@ -320,7 +321,7 @@ void process_mask_file(DataPlane &dp) { << " (" << grid_mask.nx() << " x " << grid_mask.ny() << ")\n"; // Check for matching grids - if(mask_type == MaskType_Data && grid != grid_mask) { + if(mask_type == MaskType::Data && grid != grid_mask) { mlog << Error << "\nprocess_mask_file() -> " << "The input grid and mask grid must be identical for " << "\"data\" masking.\n" @@ -333,7 +334,7 @@ void process_mask_file(DataPlane &dp) { // For solar masking, parse the valid time from gridded data if(is_solar_masktype(mask_type) && solar_ut == (unixtime) 0) { - if(mask_field_str.length() == 0) { + if(mask_field_str.empty()) { mlog << Error << "\nprocess_mask_file() -> " << "use \"-mask_field\" to specify the data whose valid " << "time should be used for \"solar_alt\" and " @@ -348,7 +349,7 @@ void process_mask_file(DataPlane &dp) { } // Check that mask_field has been set for data masking - if(mask_type == MaskType_Data && mask_field_str.length() == 0) { + if(mask_type == MaskType::Data && mask_field_str.empty()) { mlog << Error << "\nprocess_mask_file() -> " << "use \"-mask_field\" to specify the field for " << "\"data\" masking.\n\n"; @@ -361,51 +362,51 @@ void process_mask_file(DataPlane &dp) { // Construct the mask switch(mask_type) { - case MaskType_Poly: + case MaskType::Poly: apply_poly_mask(dp); break; - case MaskType_Poly_XY: + case MaskType::Poly_XY: apply_poly_xy_mask(dp); break; - case MaskType_Box: + case MaskType::Box: apply_box_mask(dp); break; - case MaskType_Circle: + case MaskType::Circle: apply_circle_mask(dp); break; - case MaskType_Track: + case MaskType::Track: apply_track_mask(dp); break; - case MaskType_Grid: + case MaskType::Grid: apply_grid_mask(dp); break; - case MaskType_Data: + case MaskType::Data: apply_data_mask(dp); break; - case MaskType_Solar_Alt: - case MaskType_Solar_Azi: + case MaskType::Solar_Alt: + case MaskType::Solar_Azi: apply_solar_mask(dp); break; - case MaskType_Lat: - case MaskType_Lon: + case MaskType::Lat: + case MaskType::Lon: apply_lat_lon_mask(dp); break; - case MaskType_Shape: + case MaskType::Shape: apply_shape_mask(dp); break; default: mlog << Error << "\nprocess_mask_file() -> " - << "Unxpected MaskType value (" << mask_type << ")\n\n"; + << "Unxpected MaskType value (" << enum_class_as_int(mask_type) << ")\n\n"; exit(1); } @@ -1135,7 +1136,7 @@ void apply_solar_mask(DataPlane &dp) { // Compute the solar altitude and azimuth solar_altaz(solar_ut, lat, lon, alt, azi); - v = (mask_type == MaskType_Solar_Alt ? alt : azi); + v = (mask_type == MaskType::Solar_Alt ? alt : azi); // Apply threshold, if specified if(thresh.get_type() != thresh_na) { @@ -1162,7 +1163,7 @@ void apply_solar_mask(DataPlane &dp) { << masktype_to_string(mask_type) << " mask.\n"; } - const char *mask_str = (mask_type == MaskType_Solar_Alt ? + const char *mask_str = (mask_type == MaskType::Solar_Alt ? "Altitude" : "Azimuth"); // List the number of points inside the mask @@ -1205,7 +1206,7 @@ void apply_lat_lon_mask(DataPlane &dp) { // Lat/Lon value for the current grid point grid.xy_to_latlon(x, y, lat, lon); - v = (mask_type == MaskType_Lat ? lat : + v = (mask_type == MaskType::Lat ? lat : rescale_deg(-1.0*lon, -180.0, 180.0)); // Apply threshold, if specified @@ -1233,7 +1234,7 @@ void apply_lat_lon_mask(DataPlane &dp) { << masktype_to_string(mask_type) << " mask.\n"; } - const char *mask_str = (mask_type == MaskType_Lat ? + const char *mask_str = (mask_type == MaskType::Lat ? "Latitude" : "Longitude"); // List the number of points inside the mask @@ -1347,17 +1348,17 @@ DataPlane combine(const DataPlane &dp_data, const DataPlane &dp_mask, switch(logic) { - case SetLogic_Union: + case SetLogic::Union: if(v_data || v_mask) v = mask_val; else v = 0.0; break; - case SetLogic_Intersection: + case SetLogic::Intersection: if(v_data && v_mask) v = mask_val; else v = 0.0; break; - case SetLogic_SymDiff: + case SetLogic::SymDiff: if((v_data && !v_mask) || (!v_data && v_mask)) v = mask_val; else v = 0.0; break; @@ -1380,10 +1381,10 @@ DataPlane combine(const DataPlane &dp_data, const DataPlane &dp_mask, } // end for x // List the number of points inside the mask - if(logic != SetLogic_None) { + if(logic != SetLogic::None) { mlog << Debug(3) << "Mask " << setlogic_to_string(logic) - << (logic == SetLogic_Intersection ? ":\t" : ":\t\t") + << (logic == SetLogic::Intersection ? ":\t" : ":\t\t") << n_in << " of " << grid.nx() * grid.ny() << " points inside\n"; } @@ -1426,10 +1427,10 @@ void write_netcdf(const DataPlane &dp) { // Set the mask_name, if not already set if(mask_name.length() == 0) { - if(mask_type == MaskType_Poly || - mask_type == MaskType_Poly_XY || - mask_type == MaskType_Circle || - mask_type == MaskType_Track) { + if(mask_type == MaskType::Poly || + mask_type == MaskType::Poly_XY || + mask_type == MaskType::Circle || + mask_type == MaskType::Track) { mask_name = poly_mask.name(); } else { @@ -1495,26 +1496,26 @@ void write_netcdf(const DataPlane &dp) { //////////////////////////////////////////////////////////////////////// bool is_solar_masktype(MaskType t) { - return(t == MaskType_Solar_Alt || t == MaskType_Solar_Azi); + return(t == MaskType::Solar_Alt || t == MaskType::Solar_Azi); } //////////////////////////////////////////////////////////////////////// MaskType string_to_masktype(const char *s) { - MaskType t = MaskType_None; - - if(strcasecmp(s, "poly") == 0) t = MaskType_Poly; - else if(strcasecmp(s, "poly_xy") == 0) t = MaskType_Poly_XY; - else if(strcasecmp(s, "box") == 0) t = MaskType_Box; - else if(strcasecmp(s, "circle") == 0) t = MaskType_Circle; - else if(strcasecmp(s, "track") == 0) t = MaskType_Track; - else if(strcasecmp(s, "grid") == 0) t = MaskType_Grid; - else if(strcasecmp(s, "data") == 0) t = MaskType_Data; - else if(strcasecmp(s, "solar_alt") == 0) t = MaskType_Solar_Alt; - else if(strcasecmp(s, "solar_azi") == 0) t = MaskType_Solar_Azi; - else if(strcasecmp(s, "lat") == 0) t = MaskType_Lat; - else if(strcasecmp(s, "lon") == 0) t = MaskType_Lon; - else if(strcasecmp(s, "shape") == 0) t = MaskType_Shape; + MaskType t = MaskType::None; + + if(strcasecmp(s, "poly") == 0) t = MaskType::Poly; + else if(strcasecmp(s, "poly_xy") == 0) t = MaskType::Poly_XY; + else if(strcasecmp(s, "box") == 0) t = MaskType::Box; + else if(strcasecmp(s, "circle") == 0) t = MaskType::Circle; + else if(strcasecmp(s, "track") == 0) t = MaskType::Track; + else if(strcasecmp(s, "grid") == 0) t = MaskType::Grid; + else if(strcasecmp(s, "data") == 0) t = MaskType::Data; + else if(strcasecmp(s, "solar_alt") == 0) t = MaskType::Solar_Alt; + else if(strcasecmp(s, "solar_azi") == 0) t = MaskType::Solar_Azi; + else if(strcasecmp(s, "lat") == 0) t = MaskType::Lat; + else if(strcasecmp(s, "lon") == 0) t = MaskType::Lon; + else if(strcasecmp(s, "shape") == 0) t = MaskType::Shape; else { mlog << Error << "\nstring_to_masktype() -> " << "unsupported masking type \"" << s << "\"\n\n"; @@ -1530,19 +1531,19 @@ const char * masktype_to_string(const MaskType t) { const char *s = (const char *) nullptr; switch(t) { - case MaskType_Poly: s = "poly"; break; - case MaskType_Poly_XY: s = "poly_xy"; break; - case MaskType_Box: s = "box"; break; - case MaskType_Circle: s = "circle"; break; - case MaskType_Track: s = "track"; break; - case MaskType_Grid: s = "grid"; break; - case MaskType_Data: s = "data"; break; - case MaskType_Solar_Alt: s = "solar_alt"; break; - case MaskType_Solar_Azi: s = "solar_azi"; break; - case MaskType_Lat: s = "lat"; break; - case MaskType_Lon: s = "lon"; break; - case MaskType_Shape: s = "shape"; break; - case MaskType_None: s = na_str; break; + case MaskType::Poly: s = "poly"; break; + case MaskType::Poly_XY: s = "poly_xy"; break; + case MaskType::Box: s = "box"; break; + case MaskType::Circle: s = "circle"; break; + case MaskType::Track: s = "track"; break; + case MaskType::Grid: s = "grid"; break; + case MaskType::Data: s = "data"; break; + case MaskType::Solar_Alt: s = "solar_alt"; break; + case MaskType::Solar_Azi: s = "solar_azi"; break; + case MaskType::Lat: s = "lat"; break; + case MaskType::Lon: s = "lon"; break; + case MaskType::Shape: s = "shape"; break; + case MaskType::None: s = na_str; break; default: s = (const char *) nullptr; break; } @@ -1703,19 +1704,19 @@ void set_complement(const StringArray & a) { //////////////////////////////////////////////////////////////////////// void set_union(const StringArray & a) { - set_logic = SetLogic_Union; + set_logic = SetLogic::Union; } //////////////////////////////////////////////////////////////////////// void set_intersection(const StringArray & a) { - set_logic = SetLogic_Intersection; + set_logic = SetLogic::Intersection; } //////////////////////////////////////////////////////////////////////// void set_symdiff(const StringArray & a) { - set_logic = SetLogic_SymDiff; + set_logic = SetLogic::SymDiff; } //////////////////////////////////////////////////////////////////////// diff --git a/src/tools/other/gen_vx_mask/gen_vx_mask.h b/src/tools/other/gen_vx_mask/gen_vx_mask.h index 8ab03376a7..962693f0c4 100644 --- a/src/tools/other/gen_vx_mask/gen_vx_mask.h +++ b/src/tools/other/gen_vx_mask/gen_vx_mask.h @@ -17,7 +17,7 @@ // 000 12/09/14 Halley Gotway New // 001 06/02/16 Halley Gotway Add box masking type. // 002 11/15/16 Halley Gotway Add solar masking types. -// 003 06/03/21 Seth Linden Changed default mask type to MaskType_None. +// 003 06/03/21 Seth Linden Changed default mask type to MaskType::None. // 004 08/30/21 Halley Gotway MET #1891 fix input and mask fields. // 005 05/05/22 Halley Gotway MET #2152 Add -type poly_xy. // 006 09/29/22 Prestopnik MET #2227 Remove namespace std from header files @@ -47,27 +47,27 @@ static const char *program_name = "gen_vx_mask"; //////////////////////////////////////////////////////////////////////// -enum MaskType { +enum class MaskType { - MaskType_Poly, // Polyline masking in lat/lon space - MaskType_Poly_XY, // Polyline masking in grid x/y space + Poly, // Polyline masking in lat/lon space + Poly_XY, // Polyline masking in grid x/y space - MaskType_Box, // Box masking type - MaskType_Circle, // Circle masking region + Box, // Box masking type + Circle, // Circle masking region - MaskType_Track, // Track masking region - MaskType_Grid, // Grid masking type - MaskType_Data, // Data masking type + Track, // Track masking region + Grid, // Grid masking type + Data, // Data masking type - MaskType_Solar_Alt, // Solar altitude masking type - MaskType_Solar_Azi, // Solar azimuth masking type + Solar_Alt, // Solar altitude masking type + Solar_Azi, // Solar azimuth masking type - MaskType_Lat, // Latitude masking type - MaskType_Lon, // Longitude masking type + Lat, // Latitude masking type + Lon, // Longitude masking type - MaskType_Shape, // Shapefile + Shape, // Shapefile - MaskType_None + None }; @@ -81,7 +81,7 @@ extern const char * masktype_to_string(MaskType); // //////////////////////////////////////////////////////////////////////// -static const MaskType default_mask_type = MaskType_None; +static const MaskType default_mask_type = MaskType::None; static const double default_mask_val = 1.0; //////////////////////////////////////////////////////////////////////// @@ -97,7 +97,7 @@ static bool type_is_set = false; // Optional arguments static ConcatString input_field_str, mask_field_str; -static SetLogic set_logic = SetLogic_None; +static SetLogic set_logic = SetLogic::None; static bool complement = false; static SingleThresh thresh; static int height = bad_data_double; diff --git a/src/tools/other/grid_diag/grid_diag.cc b/src/tools/other/grid_diag/grid_diag.cc index f804116648..87f263b68b 100644 --- a/src/tools/other/grid_diag/grid_diag.cc +++ b/src/tools/other/grid_diag/grid_diag.cc @@ -222,8 +222,8 @@ void process_command_line(int argc, char **argv) { &data_grid, &data_grid); // The regrid.to_grid option cannot be set to FCST or OBS - if(conf_info.data_info[0]->regrid().field == FieldType_Fcst || - conf_info.data_info[0]->regrid().field == FieldType_Obs) { + if(conf_info.data_info[0]->regrid().field == FieldType::Fcst || + conf_info.data_info[0]->regrid().field == FieldType::Obs) { mlog << Error << "\nprocess_command_line() -> " << "the \"regrid.to_grid\" configuration option cannot be set to " << "FCST or OBS!\nSpecify a named grid, grid specification string, " diff --git a/src/tools/other/ioda2nc/ioda2nc.cc b/src/tools/other/ioda2nc/ioda2nc.cc index 9c4233ded4..da466c79d2 100644 --- a/src/tools/other/ioda2nc/ioda2nc.cc +++ b/src/tools/other/ioda2nc/ioda2nc.cc @@ -73,7 +73,7 @@ static const char *qc_postfix = "PreQC"; static const char *obs_group_name = "ObsValue"; static const char *derived_obs_group_name = "DerivedObsValue"; -enum e_ioda_format { ioda_v1, ioda_v2 }; +enum class e_ioda_format { v1, v2 }; //////////////////////////////////////////////////////////////////////// @@ -439,7 +439,7 @@ void process_ioda_file(int i_pb) { StringArray metadata_vars; StringArray obs_value_vars; bool error_out = true; - e_ioda_format ioda_format = ioda_v2; + e_ioda_format ioda_format = e_ioda_format::v2; get_dim_names(f_in, &dim_names); ConcatString nlocs_name = find_meta_name("nlocs", dim_names); @@ -447,9 +447,9 @@ void process_ioda_file(int i_pb) { nvars = bad_data_int ; nstring = string_data_len; - if (! has_nc_group(f_in, obs_group_name)) ioda_format = ioda_v1; + if (! has_nc_group(f_in, obs_group_name)) ioda_format = e_ioda_format::v1; - if ( ioda_format == ioda_v1 ) { + if ( ioda_format == e_ioda_format::v1 ) { StringArray var_names; get_var_names(f_in, &var_names); for(idx=0; idx " @@ -1349,7 +1349,7 @@ bool get_obs_data_float(NcFile *f_in, const ConcatString var_name, if(var_name.length() > 0) { ConcatString qc_name = var_name; ConcatString qc_group = qc_postfix; - if (ioda_format == ioda_v2) { + if (ioda_format == e_ioda_format::v2) { NcGroup nc_grp = get_nc_group(f_in, qc_postfix); if (IS_INVALID_NC(nc_grp)) qc_group = qc_group_name; StringArray qc_names = conf_info.obs_to_qc_map[var_name]; diff --git a/src/tools/other/madis2nc/madis2nc.cc b/src/tools/other/madis2nc/madis2nc.cc index 7e026610b9..2c2c4f3853 100644 --- a/src/tools/other/madis2nc/madis2nc.cc +++ b/src/tools/other/madis2nc/madis2nc.cc @@ -59,6 +59,7 @@ #include "vx_cal.h" #include "vx_math.h" #include "vx_log.h" +#include "enum_as_int.hpp" #include "nc_point_obs_out.h" using namespace std; @@ -300,45 +301,45 @@ void process_madis_file(const char *madis_file) { exit(1); } // If the MADIS type is not already set, try to guess. - if(my_mtype == madis_none) my_mtype = get_madis_type(f_in); + if(my_mtype == MadisType::none) my_mtype = get_madis_type(f_in); // Switch on the MADIS type and process accordingly. switch(my_mtype) { - case(madis_metar): + case(MadisType::metar): process_madis_metar(f_in); break; - case(madis_raob): + case(MadisType::raob): process_madis_raob(f_in); break; - case (madis_profiler): + case (MadisType::profiler): process_madis_profiler(f_in); break; - case(madis_maritime): + case(MadisType::maritime): process_madis_maritime(f_in); break; - case(madis_mesonet): + case(MadisType::mesonet): process_madis_mesonet(f_in); break; - case(madis_acarsProfiles): + case(MadisType::acarsProfiles): process_madis_acarsProfiles(f_in); break; - case(madis_coop): - case(madis_HDW): - case(madis_HDW1h): - case(madis_hydro): - case(madis_POES): - case(madis_acars): - case(madis_radiometer): - case(madis_sao): - case(madis_satrad): - case(madis_snow): - case(madis_none): + case(MadisType::coop): + case(MadisType::HDW): + case(MadisType::HDW1h): + case(MadisType::hydro): + case(MadisType::POES): + case(MadisType::acars): + case(MadisType::radiometer): + case(MadisType::sao): + case(MadisType::satrad): + case(MadisType::snow): + case(MadisType::none): default: mlog << Error << "\nprocess_madis_file() -> " - << "MADIS type (" << my_mtype + << "MADIS type (" << enum_class_as_int(my_mtype) << ") not currently supported.\n\n"; exit(1); } @@ -662,18 +663,18 @@ int process_obs(const int in_gc, const float conversion, //////////////////////////////////////////////////////////////////////// MadisType get_madis_type(NcFile *&f_in) { - MadisType madis_type = madis_none; + MadisType madis_type = MadisType::none; ConcatString attr_value; // // FUTURE WORK: Interrogate the MADIS file and determine it's type. // if (get_global_att(f_in, (string)"id", attr_value)) { - if (attr_value == "MADIS_MARITIME") madis_type = madis_maritime; - else if (attr_value == "MADIS_MESONET") madis_type = madis_mesonet; - else if (attr_value == "MADIS_METAR") madis_type = madis_metar; + if (attr_value == "MADIS_MARITIME") madis_type = MadisType::maritime; + else if (attr_value == "MADIS_MESONET") madis_type = MadisType::mesonet; + else if (attr_value == "MADIS_METAR") madis_type = MadisType::metar; } else if (get_global_att(f_in, (string)"title", attr_value)) { - if (attr_value.contents("MADIS ACARS") != "") madis_type = madis_acarsProfiles; + if (attr_value.contents("MADIS ACARS") != "") madis_type = MadisType::acarsProfiles; } return madis_type; } @@ -3629,22 +3630,22 @@ void set_type(const StringArray & a) // Parse the MADIS type // if(strcasecmp(a[0].c_str(), metar_str) == 0) { - mtype = madis_metar; + mtype = MadisType::metar; } else if(strcasecmp(a[0].c_str(), raob_str) == 0) { - mtype = madis_raob; + mtype = MadisType::raob; } else if(strcasecmp(a[0].c_str(), profiler_str) == 0) { - mtype = madis_profiler; + mtype = MadisType::profiler; } else if(strcasecmp(a[0].c_str(), maritime_str) == 0) { - mtype = madis_maritime; + mtype = MadisType::maritime; } else if(strcasecmp(a[0].c_str(), mesonet_str) == 0) { - mtype = madis_mesonet; + mtype = MadisType::mesonet; } else if(strcasecmp(a[0].c_str(), acarsProfiles_str) == 0) { - mtype = madis_acarsProfiles; + mtype = MadisType::acarsProfiles; } else { mlog << Error << "\nprocess_command_line() -> " diff --git a/src/tools/other/madis2nc/madis2nc.h b/src/tools/other/madis2nc/madis2nc.h index aea7ec5b48..e397d5ba2b 100644 --- a/src/tools/other/madis2nc/madis2nc.h +++ b/src/tools/other/madis2nc/madis2nc.h @@ -47,24 +47,24 @@ // Enumeration of possible MADIS observation types -enum MadisType { - madis_none, - madis_coop, - madis_HDW, - madis_HDW1h, - madis_hydro, - madis_POES, - madis_acars, - madis_acarsProfiles, - madis_maritime, - madis_metar, - madis_mesonet, - madis_profiler, - madis_radiometer, - madis_raob, - madis_sao, - madis_satrad, - madis_snow +enum class MadisType { + none, + coop, + HDW, + HDW1h, + hydro, + POES, + acars, + acarsProfiles, + maritime, + metar, + mesonet, + profiler, + radiometer, + raob, + sao, + satrad, + snow }; // Constants @@ -103,7 +103,7 @@ static const char *in_recNum_str = "recNum"; static ConcatString mdfile; static ConcatString ncfile; -static MadisType mtype = madis_none; +static MadisType mtype = MadisType::none; static StringArray qc_dd_sa; static StringArray lvl_dim_sa; static int rec_beg = 0; diff --git a/src/tools/other/mode_graphics/mode_nc_output_file.cc b/src/tools/other/mode_graphics/mode_nc_output_file.cc index c39ca2465a..3247be997a 100644 --- a/src/tools/other/mode_graphics/mode_nc_output_file.cc +++ b/src/tools/other/mode_graphics/mode_nc_output_file.cc @@ -719,19 +719,19 @@ for (x=0; x " << "When matching is disabled (match_flag = " << matchtype_to_string(match_flag) @@ -458,7 +458,7 @@ void MtdConfigInfo::process_config(GrdFileType ftype, GrdFileType otype) + start_time_delta_wt + end_time_delta_wt; - if(match_flag != MatchType_None && + if(match_flag != MatchType::None && is_eq( sum, 0.0)) { mlog << Error << "\nMtdConfigInfo::process_config() -> " << "When matching is requested, the sum of the fuzzy engine " diff --git a/src/tools/other/pb2nc/pb2nc.cc b/src/tools/other/pb2nc/pb2nc.cc index b4d4456882..2561288484 100644 --- a/src/tools/other/pb2nc/pb2nc.cc +++ b/src/tools/other/pb2nc/pb2nc.cc @@ -930,7 +930,7 @@ void process_pbfile(int i_pb) { // Assume that the input PrepBufr file is unblocked. // Block the PrepBufr file and open it for reading. - pblock(file_name.c_str(), blk_file.c_str(), block); + pblock(file_name.c_str(), blk_file.c_str(), Action::block); // Dump the contents of the PrepBufr file to ASCII files if(dump_flag) { @@ -2140,7 +2140,7 @@ void process_pbfile_metadata(int i_pb) { // Assume that the input PrepBufr file is unblocked. // Block the PrepBufr file and open it for reading. - pblock(file_name.c_str(), blk_file.c_str(), block); + pblock(file_name.c_str(), blk_file.c_str(), Action::block); unit = dump_unit + i_pb + file_unit; if (unit > MAX_FORTRAN_FILE_ID || unit < MIN_FORTRAN_FILE_ID) { diff --git a/src/tools/other/point2grid/point2grid.cc b/src/tools/other/point2grid/point2grid.cc index fe8e7dafe8..d11044dc5f 100644 --- a/src/tools/other/point2grid/point2grid.cc +++ b/src/tools/other/point2grid/point2grid.cc @@ -66,7 +66,7 @@ static const int TYPE_GOES = 5; static const int TYPE_GOES_ADP = 6; static const int TYPE_PYTHON = 7; // MET Point Obs NetCDF from PYTHON -static const InterpMthd DefaultInterpMthd = InterpMthd_UW_Mean; +static const InterpMthd DefaultInterpMthd = InterpMthd::UW_Mean; static const int DefaultInterpWdth = 2; static const double DefaultVldThresh = 0.5; @@ -238,7 +238,7 @@ void process_command_line(int argc, char **argv) { // Set default regridding options RGInfo.enable = true; - RGInfo.field = FieldType_None; + RGInfo.field = FieldType::None; RGInfo.method = DefaultInterpMthd; RGInfo.width = DefaultInterpWdth; RGInfo.vld_thresh = DefaultVldThresh; @@ -995,9 +995,9 @@ void process_point_met_data(MetPointData *met_point_obs, MetConfig &config, VarI int data_count = dataArray.n(); if (0 < data_count) { float to_value; - if (RGInfo.method == InterpMthd_Min) to_value = dataArray.min(); - else if (RGInfo.method == InterpMthd_Max) to_value = dataArray.max(); - else if (RGInfo.method == InterpMthd_Median) { + if (RGInfo.method == InterpMthd::Min) to_value = dataArray.min(); + else if (RGInfo.method == InterpMthd::Max) to_value = dataArray.max(); + else if (RGInfo.method == InterpMthd::Median) { dataArray.sort_array(); to_value = dataArray[data_count/2]; if (0 == data_count % 2) @@ -1486,9 +1486,9 @@ void regrid_nc_variable(NcFile *nc_in, Met2dDataFile *fr_mtddf, float to_value; int data_cnt = dataArray.n(); if (1 == data_cnt) to_value = dataArray[0]; - else if (RGInfo.method == InterpMthd_Min) to_value = dataArray.min(); - else if (RGInfo.method == InterpMthd_Max) to_value = dataArray.max(); - else if (RGInfo.method == InterpMthd_Median) { + else if (RGInfo.method == InterpMthd::Min) to_value = dataArray.min(); + else if (RGInfo.method == InterpMthd::Max) to_value = dataArray.max(); + else if (RGInfo.method == InterpMthd::Median) { dataArray.sort_array(); to_value = dataArray[data_cnt/2]; if (0 == data_cnt % 2) @@ -2600,9 +2600,9 @@ void regrid_goes_variable(NcFile *nc_in, VarInfo *vinfo, if (0 < dataArray.n()) { int data_count = dataArray.n(); float to_value; - if (RGInfo.method == InterpMthd_Min) to_value = dataArray.min(); - else if (RGInfo.method == InterpMthd_Max) to_value = dataArray.max(); - else if (RGInfo.method == InterpMthd_Median) { + if (RGInfo.method == InterpMthd::Min) to_value = dataArray.min(); + else if (RGInfo.method == InterpMthd::Max) to_value = dataArray.max(); + else if (RGInfo.method == InterpMthd::Median) { dataArray.sort_array(); to_value = dataArray[data_count/2]; if (0 == data_count % 2) @@ -2847,9 +2847,9 @@ void set_field(const StringArray &a) { void set_method(const StringArray &a) { InterpMthd method_id = string_to_interpmthd(a[0].c_str()); - if (method_id == InterpMthd_Gaussian || method_id == InterpMthd_MaxGauss ) { + if (method_id == InterpMthd::Gaussian || method_id == InterpMthd::MaxGauss ) { do_gaussian_filter = true; - if (method_id == InterpMthd_MaxGauss) RGInfo.method = InterpMthd_Max; + if (method_id == InterpMthd::MaxGauss) RGInfo.method = InterpMthd::Max; } else RGInfo.method = method_id; opt_override_method = true; diff --git a/src/tools/other/regrid_data_plane/regrid_data_plane.cc b/src/tools/other/regrid_data_plane/regrid_data_plane.cc index de5961ae49..28ec4704ea 100644 --- a/src/tools/other/regrid_data_plane/regrid_data_plane.cc +++ b/src/tools/other/regrid_data_plane/regrid_data_plane.cc @@ -65,7 +65,7 @@ using namespace netCDF; static ConcatString program_name; // Constants -static const InterpMthd DefaultInterpMthd = InterpMthd_Nearest; +static const InterpMthd DefaultInterpMthd = InterpMthd::Nearest; static const int DefaultInterpWdth = 1; static const double DefaultVldThresh = 0.5; @@ -139,14 +139,14 @@ void process_command_line(int argc, char **argv) { // Set default regridding options RGInfo.enable = true; - RGInfo.field = FieldType_None; + RGInfo.field = FieldType::None; RGInfo.method = DefaultInterpMthd; RGInfo.width = DefaultInterpWdth; RGInfo.gaussian.dx = default_gaussian_dx; RGInfo.gaussian.radius = default_gaussian_radius; RGInfo.gaussian.trunc_factor = default_trunc_factor; RGInfo.vld_thresh = DefaultVldThresh; - RGInfo.shape = GridTemplateFactory::GridTemplate_Square; + RGInfo.shape = GridTemplateFactory::GridTemplates::Square; // Check for zero arguments if(argc == 1) usage(); @@ -204,7 +204,7 @@ void process_command_line(int argc, char **argv) { } RGInfo.validate(); - if (RGInfo.method == InterpMthd_Gaussian || RGInfo.method == InterpMthd_MaxGauss) + if (RGInfo.method == InterpMthd::Gaussian || RGInfo.method == InterpMthd::MaxGauss) RGInfo.gaussian.compute(); return; diff --git a/src/tools/other/shift_data_plane/shift_data_plane.cc b/src/tools/other/shift_data_plane/shift_data_plane.cc index b86ec79e76..40e2f742bc 100644 --- a/src/tools/other/shift_data_plane/shift_data_plane.cc +++ b/src/tools/other/shift_data_plane/shift_data_plane.cc @@ -72,9 +72,9 @@ static double ToLon = bad_data_double; static ConcatString InputFilename; static ConcatString OutputFilename; static ConcatString FieldString; -static InterpMthd Method = InterpMthd_DW_Mean; +static InterpMthd Method = InterpMthd::DW_Mean; static int Width = 2; -static GridTemplateFactory::GridTemplates Shape = GridTemplateFactory::GridTemplate_Square; +static GridTemplateFactory::GridTemplates Shape = GridTemplateFactory::GridTemplates::Square; static int compress_level = -1; // Static global variables diff --git a/src/tools/other/wwmca_tool/wwmca_ref.cc b/src/tools/other/wwmca_tool/wwmca_ref.cc index b8c2b2f810..f66515ca99 100644 --- a/src/tools/other/wwmca_tool/wwmca_ref.cc +++ b/src/tools/other/wwmca_tool/wwmca_ref.cc @@ -124,7 +124,7 @@ ConfigFilename.clear(); Width = 0; -Method = InterpMthd_None; +Method = InterpMthd::None; interp_func = 0; @@ -335,7 +335,7 @@ const RegridInfo regrid_info = parse_conf_regrid(Config); Width = regrid_info.width; -Method = InterpMthd_Nearest; +Method = InterpMthd::Nearest; Fraction = regrid_info.vld_thresh; @@ -367,15 +367,15 @@ if ( Width > 1 ) { switch ( Method ) { - case InterpMthd_Min: + case InterpMthd::Min: interp_func = &dp_interp_min; break; - case InterpMthd_Max: + case InterpMthd::Max: interp_func = &dp_interp_max; break; - case InterpMthd_UW_Mean: + case InterpMthd::UW_Mean: interp_func = &dp_interp_uw_mean; break; diff --git a/src/tools/tc_utils/tc_diag/tc_diag.cc b/src/tools/tc_utils/tc_diag/tc_diag.cc index 23478fba79..e5815d30cb 100644 --- a/src/tools/tc_utils/tc_diag/tc_diag.cc +++ b/src/tools/tc_utils/tc_diag/tc_diag.cc @@ -17,6 +17,7 @@ // 000 09/27/22 Halley Gotway New // 001 08/17/23 Halley Gotway MET #2609 handle missing data // 002 10/24/23 Halley Gotway MET #2550 enhance diagnostics +// 003 03/11/24 Halley Gotway MET #2833 range/azimuth grid // //////////////////////////////////////////////////////////////////////// @@ -2203,7 +2204,9 @@ void TmpFileInfo::setup_nc_file(const DomainInfo &di, // Set grid center d.lat_center = pnt_ptr->lat(); d.lon_center = -1.0*pnt_ptr->lon(); // degrees east to west - d.range_max_km = di.delta_range_km * d.range_n; + + // MET #2833 multiply by n-1 since the ranges begin at 0 km + d.range_max_km = di.delta_range_km * (d.range_n - 1); // Instantiate the grid grid_out.set(d); diff --git a/src/tools/tc_utils/tc_gen/tc_gen.cc b/src/tools/tc_utils/tc_gen/tc_gen.cc index 9afc59a3d9..04e0b0c408 100644 --- a/src/tools/tc_utils/tc_gen/tc_gen.cc +++ b/src/tools/tc_utils/tc_gen/tc_gen.cc @@ -705,8 +705,8 @@ void do_genesis_ctc(const TCGenVxOpt &vx_opt, << ") is a dev and ops FALSE ALARM.\n"; // FALSE ALARM for both methods - diff.DevCategory = FYONGenesis; - diff.OpsCategory = FYONGenesis; + diff.DevCategory = GenesisPairCategory::FYON; + diff.OpsCategory = GenesisPairCategory::FYON; } // Unmatched BEST genesis (MISS) @@ -719,8 +719,8 @@ void do_genesis_ctc(const TCGenVxOpt &vx_opt, << ") is a dev and ops MISS.\n"; // MISS for both methods - diff.DevCategory = FNOYGenesis; - diff.OpsCategory = FNOYGenesis; + diff.DevCategory = GenesisPairCategory::FNOY; + diff.OpsCategory = GenesisPairCategory::FNOY; } // Matched genesis pairs (DISCARD, HIT, or FALSE ALARM) @@ -743,8 +743,8 @@ void do_genesis_ctc(const TCGenVxOpt &vx_opt, << " genesis time.\n"; // DISCARD for both methods - diff.DevCategory = DiscardGenesis; - diff.OpsCategory = DiscardGenesis; + diff.DevCategory = GenesisPairCategory::Discard; + diff.OpsCategory = GenesisPairCategory::Discard; } // Check for a HIT else { @@ -769,14 +769,14 @@ void do_genesis_ctc(const TCGenVxOpt &vx_opt, << " is a dev method HIT " << offset_cs; // HIT for the development method - diff.DevCategory = FYOYGenesis; + diff.DevCategory = GenesisPairCategory::FYOY; } else { mlog << Debug(4) << case_cs << " is a dev method FALSE ALARM " << offset_cs; // FALSE ALARM for the development method - diff.DevCategory = FYONGenesis; + diff.DevCategory = GenesisPairCategory::FYON; } // Compute init/genesis time offset @@ -796,14 +796,14 @@ void do_genesis_ctc(const TCGenVxOpt &vx_opt, << " is an ops method HIT " << offset_cs; // HIT for the operational method - diff.OpsCategory = FYOYGenesis; + diff.OpsCategory = GenesisPairCategory::FYOY; } else { mlog << Debug(4) << case_cs << " is an ops method FALSE ALARM " << offset_cs; // FALSE ALARM for the operational method - diff.OpsCategory = FYONGenesis; + diff.OpsCategory = GenesisPairCategory::FYON; } } } @@ -1550,7 +1550,7 @@ void process_edecks(const StringArray &files, if((line.valid_hour() % valid_freq_sec) != 0) continue; // Only process genesis probability lines - if(line.type() == ATCFLineType_ProbGN) { + if(line.type() == ATCFLineType::ProbGN) { dland = conf_info.compute_dland(line.lat(), -1.0*line.lon()); if(probs.add(line, dland, false)) n_lines++; } @@ -1564,7 +1564,7 @@ void process_edecks(const StringArray &files, // Dump out the total number of lines mlog << Debug(3) << "Read a total of " << n_lines << " " - << atcflinetype_to_string(ATCFLineType_ProbGN) + << atcflinetype_to_string(ATCFLineType::ProbGN) << " lines from " << files.n() << " input files.\n"; // Dump out very verbose output @@ -1734,7 +1734,7 @@ void setup_txt_files(int n_model, int max_n_prob, int n_pair) { int i, n_rows, n_cols, stat_rows, stat_cols, n_prob; // Check to see if the stat file stream has already been setup - bool init_from_scratch = (stat_out == (ofstream *) 0); + bool init_from_scratch = (stat_out == (ofstream *) nullptr); // Get the maximum number of probability thresholds n_prob = conf_info.get_max_n_prob_thresh(); @@ -1743,7 +1743,7 @@ void setup_txt_files(int n_model, int max_n_prob, int n_pair) { for(i=0, stat_rows=0, stat_cols=0; iVxMaskName.c_str()); // Write out FHO - if(gci.VxOpt->output_map(stat_fho) != STATOutputType_None) { + if(gci.VxOpt->output_map(STATLineType::fho) != STATOutputType::None) { if(gci.VxOpt->DevFlag) { shc.set_fcst_var(genesis_dev_name); shc.set_obs_var (genesis_dev_name); write_fho_row(shc, gci.CTSDev, - gci.VxOpt->output_map(stat_fho), + gci.VxOpt->output_map(STATLineType::fho), stat_at, i_stat_row, txt_at[i_fho], i_txt_row[i_fho]); } @@ -1985,20 +1985,20 @@ void write_ctc_stats(const PairDataGenesis &gpd, shc.set_fcst_var(genesis_ops_name); shc.set_obs_var (genesis_ops_name); write_fho_row(shc, gci.CTSOps, - gci.VxOpt->output_map(stat_fho), + gci.VxOpt->output_map(STATLineType::fho), stat_at, i_stat_row, txt_at[i_fho], i_txt_row[i_fho]); } } // Write out CTC - if(gci.VxOpt->output_map(stat_ctc) != STATOutputType_None) { + if(gci.VxOpt->output_map(STATLineType::ctc) != STATOutputType::None) { if(gci.VxOpt->DevFlag) { shc.set_fcst_var(genesis_dev_name); shc.set_obs_var (genesis_dev_name); write_ctc_row(shc, gci.CTSDev, - gci.VxOpt->output_map(stat_ctc), + gci.VxOpt->output_map(STATLineType::ctc), stat_at, i_stat_row, txt_at[i_ctc], i_txt_row[i_ctc]); } @@ -2007,14 +2007,14 @@ void write_ctc_stats(const PairDataGenesis &gpd, shc.set_fcst_var(genesis_ops_name); shc.set_obs_var (genesis_ops_name); write_ctc_row(shc, gci.CTSOps, - gci.VxOpt->output_map(stat_ctc), + gci.VxOpt->output_map(STATLineType::ctc), stat_at, i_stat_row, txt_at[i_ctc], i_txt_row[i_ctc]); } } // Write out CTS - if(gci.VxOpt->output_map(stat_cts) != STATOutputType_None) { + if(gci.VxOpt->output_map(STATLineType::cts) != STATOutputType::None) { if(gci.VxOpt->DevFlag) { gci.CTSDev.compute_stats(); @@ -2023,7 +2023,7 @@ void write_ctc_stats(const PairDataGenesis &gpd, shc.set_fcst_var(genesis_dev_name); shc.set_obs_var (genesis_dev_name); write_cts_row(shc, gci.CTSDev, - gci.VxOpt->output_map(stat_cts), + gci.VxOpt->output_map(STATLineType::cts), stat_at, i_stat_row, txt_at[i_cts], i_txt_row[i_cts]); } @@ -2035,18 +2035,18 @@ void write_ctc_stats(const PairDataGenesis &gpd, shc.set_fcst_var(genesis_ops_name); shc.set_obs_var (genesis_ops_name); write_cts_row(shc, gci.CTSOps, - gci.VxOpt->output_map(stat_cts), + gci.VxOpt->output_map(STATLineType::cts), stat_at, i_stat_row, txt_at[i_cts], i_txt_row[i_cts]); } } // Write out GENMPR - if(gci.VxOpt->output_map(stat_genmpr) != STATOutputType_None) { + if(gci.VxOpt->output_map(STATLineType::genmpr) != STATOutputType::None) { shc.set_fcst_var(genesis_name); shc.set_obs_var (genesis_name); write_ctc_genmpr_row(shc, gpd, - gci.VxOpt->output_map(stat_genmpr), + gci.VxOpt->output_map(STATLineType::genmpr), stat_at, i_stat_row, txt_at[i_genmpr], i_txt_row[i_genmpr]); } @@ -2096,7 +2096,7 @@ void write_ctc_genmpr_row(StatHdrColumns &shc, write_ctc_genmpr_cols(gpd, i, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -2219,43 +2219,43 @@ void write_pct_stats(ProbGenPCTInfo &pgi) { shc.set_obs_valid_end(pgi.BestEnd); // Write PCT output - if(pgi.VxOpt->output_map(stat_pct) != STATOutputType_None) { + if(pgi.VxOpt->output_map(STATLineType::pct) != STATOutputType::None) { write_pct_row(shc, pgi.PCTMap[lead_hr], - pgi.VxOpt->output_map(stat_pct), + pgi.VxOpt->output_map(STATLineType::pct), 1, 1, stat_at, i_stat_row, txt_at[i_pct], i_txt_row[i_pct]); } // Write PSTD output - if(pgi.VxOpt->output_map(stat_pstd) != STATOutputType_None) { + if(pgi.VxOpt->output_map(STATLineType::pstd) != STATOutputType::None) { pgi.PCTMap[lead_hr].compute_stats(); pgi.PCTMap[lead_hr].compute_ci(); write_pstd_row(shc, pgi.PCTMap[lead_hr], - pgi.VxOpt->output_map(stat_pstd), + pgi.VxOpt->output_map(STATLineType::pstd), 1, 1, stat_at, i_stat_row, txt_at[i_pstd], i_txt_row[i_pstd]); } // Write PJC output - if(pgi.VxOpt->output_map(stat_pjc) != STATOutputType_None) { + if(pgi.VxOpt->output_map(STATLineType::pjc) != STATOutputType::None) { write_pjc_row(shc, pgi.PCTMap[lead_hr], - pgi.VxOpt->output_map(stat_pjc), + pgi.VxOpt->output_map(STATLineType::pjc), 1, 1, stat_at, i_stat_row, txt_at[i_pjc], i_txt_row[i_pjc]); } // Write PRC output - if(pgi.VxOpt->output_map(stat_pjc) != STATOutputType_None) { + if(pgi.VxOpt->output_map(STATLineType::pjc) != STATOutputType::None) { write_prc_row(shc, pgi.PCTMap[lead_hr], - pgi.VxOpt->output_map(stat_prc), + pgi.VxOpt->output_map(STATLineType::prc), 1, 1, stat_at, i_stat_row, txt_at[i_prc], i_txt_row[i_prc]); } // Write out GENMPR - if(pgi.VxOpt->output_map(stat_genmpr) != STATOutputType_None) { + if(pgi.VxOpt->output_map(STATLineType::genmpr) != STATOutputType::None) { write_pct_genmpr_row(shc, pgi, lead_hr, - pgi.VxOpt->output_map(stat_genmpr), + pgi.VxOpt->output_map(STATLineType::genmpr), stat_at, i_stat_row, txt_at[i_genmpr], i_txt_row[i_genmpr]); } @@ -2308,7 +2308,7 @@ void write_pct_genmpr_row(StatHdrColumns &shc, stat_at, stat_row, n_header_columns); // If requested, copy row to the text file - if(out_type == STATOutputType_Both) { + if(out_type == STATOutputType::Both) { copy_ascii_table_row(stat_at, stat_row, txt_at, txt_row); // Increment the text row counter @@ -2565,7 +2565,7 @@ void finish_txt_files() { for(i=0; ilat(), fgi->lon(), fdev_fyoy_str); BestDevHitMap[bgi] += 1; @@ -1082,12 +1082,12 @@ void GenCTCInfo::inc_dev(GenesisPairCategory c, } } // False Alarms - else if(c == FYONGenesis) { + else if(c == GenesisPairCategory::FYON) { CTSDev.cts.inc_fy_on(); inc_pnt(fgi->lat(), fgi->lon(), fdev_fyon_str); } // Misses - else if(c == FNOYGenesis) { + else if(c == GenesisPairCategory::FNOY) { CTSDev.cts.inc_fn_oy(); // Count all BEST track genesis pairs @@ -1110,11 +1110,11 @@ void GenCTCInfo::inc_ops(GenesisPairCategory c, const GenesisInfo *bgi) { // Discard - if(c == DiscardGenesis) { + if(c == GenesisPairCategory::Discard) { return; } // Hits - else if(c == FYOYGenesis) { + else if(c == GenesisPairCategory::FYOY) { CTSOps.cts.inc_fy_oy(); inc_pnt(fgi->lat(), fgi->lon(), fops_fyoy_str); BestOpsHitMap[bgi] += 1; @@ -1125,12 +1125,12 @@ void GenCTCInfo::inc_ops(GenesisPairCategory c, } } // False Alarms - else if(c == FYONGenesis) { + else if(c == GenesisPairCategory::FYON) { CTSOps.cts.inc_fy_on(); inc_pnt(fgi->lat(), fgi->lon(), fops_fyon_str); } // Misses - else if(c == FNOYGenesis) { + else if(c == GenesisPairCategory::FNOY) { CTSOps.cts.inc_fn_oy(); // Count all BEST track genesis pairs diff --git a/src/tools/tc_utils/tc_gen/tc_gen_conf_info.h b/src/tools/tc_utils/tc_gen/tc_gen_conf_info.h index 65ddd1b3de..900745f43b 100644 --- a/src/tools/tc_utils/tc_gen/tc_gen_conf_info.h +++ b/src/tools/tc_utils/tc_gen/tc_gen_conf_info.h @@ -39,14 +39,14 @@ static const int n_txt = 8; // Text file type static const STATLineType txt_file_type[n_txt] = { - stat_fho, // 0 - stat_ctc, // 1 - stat_cts, // 2 - stat_pct, // 3 - stat_pstd, // 4 - stat_pjc, // 5 - stat_prc, // 6 - stat_genmpr // 7 + STATLineType::fho, // 0 + STATLineType::ctc, // 1 + STATLineType::cts, // 2 + STATLineType::pct, // 3 + STATLineType::pstd, // 4 + STATLineType::pjc, // 5 + STATLineType::prc, // 6 + STATLineType::genmpr // 7 }; // Output data type names diff --git a/src/tools/tc_utils/tc_pairs/tc_pairs.cc b/src/tools/tc_utils/tc_pairs/tc_pairs.cc index 0955dad28b..1516d8745d 100644 --- a/src/tools/tc_utils/tc_pairs/tc_pairs.cc +++ b/src/tools/tc_utils/tc_pairs/tc_pairs.cc @@ -318,8 +318,8 @@ void process_bdecks(TrackInfoArray &bdeck_tracks) { mlog << Debug(2) << "Processing " << files.n() << " BDECK file(s).\n"; process_track_files(files, files_model_suffix, bdeck_tracks, false, - (conf_info.AnlyTrack == TrackType_BDeck || - conf_info.AnlyTrack == TrackType_Both)); + (conf_info.AnlyTrack == TrackType::BDeck || + conf_info.AnlyTrack == TrackType::Both)); mlog << Debug(2) << "Found " << bdeck_tracks.n() << " BDECK track(s).\n"; @@ -341,15 +341,15 @@ void process_adecks(const TrackInfoArray &bdeck_tracks) { mlog << Debug(2) << "Processing " << files.n() << " ADECK file(s).\n"; process_track_files(files, files_model_suffix, adeck_tracks, true, - (conf_info.AnlyTrack == TrackType_ADeck || - conf_info.AnlyTrack == TrackType_Both)); + (conf_info.AnlyTrack == TrackType::ADeck || + conf_info.AnlyTrack == TrackType::Both)); // // Derive new track types // // Handle 12-hourly interpolated models - if(conf_info.Interp12) { + if(Interp12Type::None != conf_info.Interp12) { mlog << Debug(2) << "Deriving 12-hour interpolated ADECK tracks.\n"; derive_interp12(adeck_tracks); @@ -710,7 +710,7 @@ void process_prob_files(const StringArray &files, if(!is_keeper(&line)) continue; // Only process probability of RI lines - if(line.type() == ATCFLineType_ProbRI) { + if(line.type() == ATCFLineType::ProbRI) { dland = compute_dland(line.lat(), -1.0*line.lon()); if(probs.add(line, dland, conf_info.CheckDup)) { cur_add++; @@ -1013,7 +1013,7 @@ void filter_probs(ProbInfoArray &probs) { } // If we've made it here, retain this probability - if(p[i]->type() == ATCFLineType_ProbRI) probs.add(p.prob_rirw(i)); + if(p[i]->type() == ATCFLineType::ProbRI) probs.add(p.prob_rirw(i)); } // Print summary filtering info @@ -1172,7 +1172,7 @@ void derive_interp12(TrackInfoArray &tracks) { char c; // If Interp12 logic set to NONE, Nothing to do. - if(conf_info.Interp12 == Interp12Type_None) return; + if(conf_info.Interp12 == Interp12Type::None) return; // Loop through the track array and store case information for(i=0; i> dl; diff --git a/src/tools/tc_utils/tc_pairs/tc_pairs_conf_info.cc b/src/tools/tc_utils/tc_pairs/tc_pairs_conf_info.cc index f5edf0d1a2..a2b9ef5f87 100644 --- a/src/tools/tc_utils/tc_pairs/tc_pairs_conf_info.cc +++ b/src/tools/tc_utils/tc_pairs/tc_pairs_conf_info.cc @@ -95,14 +95,14 @@ void TCPairsConfInfo::clear() { ValidAreaMask.clear(); LeadReq.clear(); CheckDup = true; - Interp12 = Interp12Type_Replace; + Interp12 = Interp12Type::Replace; NConsensus = 0; LagTime.clear(); BestTechnique.clear(); BestBaseline.clear(); OperTechnique.clear(); OperBaseline.clear(); - AnlyTrack = TrackType_None; + AnlyTrack = TrackType::None; MatchPoints = false; DLandFile.clear(); WatchWarnFile.clear(); diff --git a/src/tools/tc_utils/tc_rmw/tc_rmw.cc b/src/tools/tc_utils/tc_rmw/tc_rmw.cc index c281b758e2..d32bc62d81 100644 --- a/src/tools/tc_utils/tc_rmw/tc_rmw.cc +++ b/src/tools/tc_utils/tc_rmw/tc_rmw.cc @@ -19,6 +19,7 @@ // 002 07/06/22 Howard Soh METplus-Internal #19 Rename main to met_main // 003 09/28/22 Prestopnik MET #2227 Remove namspace std and netCDF from header files // 004 04/26/23 Halley Gotway MET #2523 Reorder NetCDF dimensions +// 005 03/11/24 Halley Gotway MET #2833 range/azimuth grid // //////////////////////////////////////////////////////////////////////// @@ -554,7 +555,13 @@ void setup_grid() { grid_data.name = "TCRMW"; grid_data.range_n = conf_info.n_range; grid_data.azimuth_n = conf_info.n_azimuth; - grid_data.range_max_km = conf_info.max_range_km; + + // Define the maximum range in km based on the fixed increment + if(is_bad_data(conf_info.rmw_scale)) { + grid_data.range_max_km = + conf_info.delta_range_km * + (conf_info.n_range - 1); + } tcrmw_grid.set_from_data(grid_data); grid.set(grid_data); @@ -593,8 +600,9 @@ void setup_nc_file() { lead_time_str_var, lead_time_sec_var); // Define range and azimuth dimensions - def_tc_range_azimuth(nc_out, range_dim, azimuth_dim, tcrmw_grid, - conf_info.rmw_scale); + def_tc_range_azimuth(nc_out, + range_dim, azimuth_dim, + tcrmw_grid, conf_info.rmw_scale); // Define latitude and longitude arrays def_tc_lat_lon(nc_out, @@ -606,11 +614,11 @@ void setup_nc_file() { // Get VarInfo data_info = conf_info.data_info[i_var]; mlog << Debug(4) << "Processing field: " << data_info->magic_str() << "\n"; - string fname = data_info->name_attr(); + string fname = data_info->name_attr(); variable_levels[fname].push_back(data_info->level_attr()); variable_long_names[fname] = data_info->long_name_attr(); variable_units[fname] = data_info->units_attr(); - wind_converter.update_input(fname, data_info->units_attr()); + wind_converter.update_input(fname, data_info->units_attr()); } // Define pressure levels @@ -644,7 +652,7 @@ void compute_lat_lon(TcrmwGrid& tcrmw_grid, ia * tcrmw_grid.azimuth_delta_deg(), lat, lon); lat_arr[i] = lat; - lon_arr[i] = - lon; + lon_arr[i] = -lon; } } } @@ -688,9 +696,15 @@ void process_fields(const TrackInfoArray& tracks) { grid_data.lat_center = point.lat(); grid_data.lon_center = -1.0*point.lon(); // internal sign change - // RMW is same as mrd() - grid_data.range_max_km = conf_info.rmw_scale * - point.mrd() * tc_km_per_nautical_miles * conf_info.n_range; + // Define the maximum range in km relative to the radius of maximum winds + if(!is_bad_data(conf_info.rmw_scale)) { + grid_data.range_max_km = + conf_info.rmw_scale * + point.mrd() * tc_km_per_nautical_miles * + (conf_info.n_range - 1); + } + + // Re-define the range/azimuth grid tcrmw_grid.clear(); tcrmw_grid.set_from_data(grid_data); grid.clear(); @@ -713,7 +727,7 @@ void process_fields(const TrackInfoArray& tracks) { for(int i_var = 0; i_var < conf_info.get_n_data(); i_var++) { - // Update the variable info with the valid time of the track point + // Update with the valid time of the track point data_info = conf_info.data_info[i_var]; string sname = data_info->name_attr().string(); @@ -731,24 +745,27 @@ void process_fields(const TrackInfoArray& tracks) { mlog << Debug(4) << "data_max:" << data_max << "\n"; // Regrid data - data_dp = met_regrid(data_dp, latlon_arr, grid, data_info->regrid()); + data_dp = met_regrid(data_dp, latlon_arr, grid, + data_info->regrid()); data_dp.data_range(data_min, data_max); mlog << Debug(4) << "data_min:" << data_min << "\n"; mlog << Debug(4) << "data_max:" << data_max << "\n"; - // if this is "U", setup everything for matching "V" and compute the radial/tangential - if(wind_converter.compute_winds_if_input_is_u(i_point, sname, slevel, valid_time, data_files, ftype, - latlon_arr, lat_arr, lon_arr, grid, data_dp, tcrmw_grid)) { - write_tc_pressure_level_data(nc_out, tcrmw_grid, - pressure_level_indices, data_info->level_attr(), i_point, - data_3d_vars[conf_info.radial_velocity_field_name.string()], - wind_converter.get_wind_r_arr()); - write_tc_pressure_level_data(nc_out, tcrmw_grid, - pressure_level_indices, data_info->level_attr(), i_point, - data_3d_vars[conf_info.tangential_velocity_field_name.string()], - wind_converter.get_wind_t_arr()); + // If this is "U", setup everything for matching "V" + // and compute the radial/tangential winds + if(wind_converter.compute_winds_if_input_is_u( + i_point, sname, slevel, valid_time, data_files, ftype, + latlon_arr, lat_arr, lon_arr, grid, data_dp, tcrmw_grid)) { + write_tc_pressure_level_data(nc_out, tcrmw_grid, + pressure_level_indices, data_info->level_attr(), i_point, + data_3d_vars[conf_info.radial_velocity_field_name.string()], + wind_converter.get_wind_r_arr()); + write_tc_pressure_level_data(nc_out, tcrmw_grid, + pressure_level_indices, data_info->level_attr(), i_point, + data_3d_vars[conf_info.tangential_velocity_field_name.string()], + wind_converter.get_wind_t_arr()); } - + // Write data if(variable_levels[data_info->name_attr()].size() > 1) { write_tc_pressure_level_data(nc_out, tcrmw_grid, diff --git a/src/tools/tc_utils/tc_rmw/tc_rmw.h b/src/tools/tc_utils/tc_rmw/tc_rmw.h index b97f136188..7691a2c012 100644 --- a/src/tools/tc_utils/tc_rmw/tc_rmw.h +++ b/src/tools/tc_utils/tc_rmw/tc_rmw.h @@ -146,10 +146,6 @@ static Grid grid; static double* lat_arr; static double* lon_arr; -// Wind arrays -/* static double* wind_r_arr; */ -/* static double* wind_t_arr; */ - //////////////////////////////////////////////////////////////////////// #endif // __TC_RMW_H__ diff --git a/src/tools/tc_utils/tc_rmw/tc_rmw_conf_info.cc b/src/tools/tc_utils/tc_rmw/tc_rmw_conf_info.cc index 7f8537ef80..eaaeebafeb 100644 --- a/src/tools/tc_utils/tc_rmw/tc_rmw_conf_info.cc +++ b/src/tools/tc_utils/tc_rmw/tc_rmw_conf_info.cc @@ -72,7 +72,6 @@ void TCRMWConfInfo::clear() { n_range = bad_data_int; n_azimuth = bad_data_int; - max_range_km = bad_data_double; delta_range_km = bad_data_double; rmw_scale = bad_data_double; @@ -175,15 +174,21 @@ void TCRMWConfInfo::process_config(GrdFileType ftype) { // Conf: n_azimuth n_azimuth = Conf.lookup_int(conf_key_n_azimuth); - // Conf: max_range - max_range_km = Conf.lookup_double(conf_key_max_range); - // Conf: delta_range delta_range_km = Conf.lookup_double(conf_key_delta_range); // Conf: rmw_scale rmw_scale = Conf.lookup_double(conf_key_rmw_scale); + // Error check + if(is_bad_data(delta_range_km) && is_bad_data(rmw_scale)) { + mlog << Error << "\nTCRMWConfInfo::process_config() -> " + << "the \"" << conf_key_delta_range << "\" and \"" + << conf_key_rmw_scale << "\" configuration options " + << "cannot both be set to bad data.\n\n"; + exit(1); + } + compute_tangential_and_radial_winds = Conf.lookup_bool(conf_key_compute_tangential_and_radial_winds); u_wind_field_name = Conf.lookup_string(conf_key_u_wind_field_name); v_wind_field_name = Conf.lookup_string(conf_key_v_wind_field_name); @@ -192,7 +197,6 @@ void TCRMWConfInfo::process_config(GrdFileType ftype) { tangential_velocity_long_field_name = Conf.lookup_string(conf_key_tangential_velocity_long_field_name); radial_velocity_long_field_name = Conf.lookup_string(conf_key_radial_velocity_long_field_name); - // Conf: data.field fdict = Conf.lookup_array(conf_key_data_field); diff --git a/src/tools/tc_utils/tc_rmw/tc_rmw_conf_info.h b/src/tools/tc_utils/tc_rmw/tc_rmw_conf_info.h index f1d8d52ec8..1e3bf5b3b2 100644 --- a/src/tools/tc_utils/tc_rmw/tc_rmw_conf_info.h +++ b/src/tools/tc_utils/tc_rmw/tc_rmw_conf_info.h @@ -50,18 +50,17 @@ class TCRMWConfInfo { // Range/Azimuth information int n_range; int n_azimuth; - double max_range_km; double delta_range_km; double rmw_scale; - // Wind conversion information - bool compute_tangential_and_radial_winds; - ConcatString u_wind_field_name; - ConcatString v_wind_field_name; - ConcatString tangential_velocity_field_name; - ConcatString radial_velocity_field_name; - ConcatString tangential_velocity_long_field_name; - ConcatString radial_velocity_long_field_name; + // Wind conversion information + bool compute_tangential_and_radial_winds; + ConcatString u_wind_field_name; + ConcatString v_wind_field_name; + ConcatString tangential_velocity_field_name; + ConcatString radial_velocity_field_name; + ConcatString tangential_velocity_long_field_name; + ConcatString radial_velocity_long_field_name; // Variable information VarInfo** data_info; diff --git a/src/tools/tc_utils/tc_stat/tc_stat_files.cc b/src/tools/tc_utils/tc_stat/tc_stat_files.cc index 77a6b9d11b..a8c63c592c 100644 --- a/src/tools/tc_utils/tc_stat/tc_stat_files.cc +++ b/src/tools/tc_utils/tc_stat/tc_stat_files.cc @@ -165,8 +165,8 @@ bool TCStatFiles::operator>>(TrackPairInfo &pair) { // Skip header and non-TCMPR/TCDIAG lines if(line.is_header() || - (line.type() != TCStatLineType_TCMPR && - line.type() != TCStatLineType_TCDIAG)) continue; + (line.type() != TCStatLineType::TCMPR && + line.type() != TCStatLineType::TCDIAG)) continue; // Add the current point pair.add(line); @@ -177,7 +177,7 @@ bool TCStatFiles::operator>>(TrackPairInfo &pair) { // Check for a trailing TCDIAG line if(CurLDF.peek_line(line)) { - if(line.type() == TCStatLineType_TCDIAG) { + if(line.type() == TCStatLineType::TCDIAG) { pair.add(line); CurLDF >> line; } @@ -231,7 +231,7 @@ bool TCStatFiles::operator>>(ProbRIRWPairInfo &pair) { while((status = (CurLDF >> line))) { // Skip header and non-PROBRIRW lines - if(line.is_header() || line.type() != TCStatLineType_ProbRIRW) continue; + if(line.is_header() || line.type() != TCStatLineType::ProbRIRW) continue; // Add the current point pair.set(line); @@ -280,7 +280,7 @@ bool TCStatFiles::operator>>(TCStatLine &line) { while((status = (CurLDF >> line))) { // Skip header and invalid line types - if(line.is_header() || line.type() == NoTCStatLineType) continue; + if(line.is_header() || line.type() == TCStatLineType::None) continue; break; diff --git a/src/tools/tc_utils/tc_stat/tc_stat_job.cc b/src/tools/tc_utils/tc_stat/tc_stat_job.cc index 9814f759c4..ec8172776c 100644 --- a/src/tools/tc_utils/tc_stat/tc_stat_job.cc +++ b/src/tools/tc_utils/tc_stat/tc_stat_job.cc @@ -54,7 +54,7 @@ static bool check_masks (const MaskPoly &, const Grid &, const Ma TCStatJob *TCStatJobFactory::new_tc_stat_job_type(const char *type_str) { TCStatJob *job = (TCStatJob *) nullptr; - TCStatJobType type = NoTCStatJobType; + TCStatJobType type = TCStatJobType::None; // Determine the TCStatJobType type = string_to_tcstatjobtype((string)type_str); @@ -63,23 +63,23 @@ TCStatJob *TCStatJobFactory::new_tc_stat_job_type(const char *type_str) { // The TCStatJob object is allocated and needs to be deleted by caller. switch(type) { - case TCStatJobType_Filter: + case TCStatJobType::Filter: job = new TCStatJobFilter; break; - case TCStatJobType_Summary: + case TCStatJobType::Summary: job = new TCStatJobSummary; break; - case TCStatJobType_RIRW: + case TCStatJobType::RIRW: job = new TCStatJobRIRW; break; - case TCStatJobType_ProbRIRW: + case TCStatJobType::ProbRIRW: job = new TCStatJobProbRIRW; break; - case NoTCStatJobType: + case TCStatJobType::None: default: mlog << Error << "\nTCStatJobFactory::new_tc_stat_job_type() -> " << "unsupported job type \"" << type_str << "\"\n\n"; @@ -196,7 +196,7 @@ void TCStatJob::clear() { Precision = default_precision; - JobType = NoTCStatJobType; + JobType = TCStatJobType::None; AModel.clear(); BModel.clear(); @@ -551,10 +551,10 @@ bool TCStatJob::is_keeper_track(const TrackPairInfo &pair, // HUWARN, TSWARN, HUWATCH, TSWATCH if(TrackWatchWarn.has(watchwarntype_to_string(ww_type)) || (TrackWatchWarn.has("ALL") && - (ww_type == HurricaneWarn || - ww_type == TropicalStormWarn || - ww_type == HurricaneWatch || - ww_type == TropicalStormWatch))) { + (ww_type == WatchWarnType::HurricaneWarn || + ww_type == WatchWarnType::TropicalStormWarn || + ww_type == WatchWarnType::HurricaneWatch || + ww_type == WatchWarnType::TropicalStormWatch))) { keep = true; break; } @@ -712,7 +712,7 @@ bool TCStatJob::is_keeper_line(const TCStatLine &line, TCPointCounts &n) const { // Does not apply to TCDIAG lines - if(line.type() == TCStatLineType_TCDIAG) return true; + if(line.type() == TCStatLineType::TCDIAG) return true; bool keep = true; double v_dbl, alat, alon, blat, blon; @@ -767,7 +767,7 @@ bool TCStatJob::is_keeper_line(const TCStatLine &line, !LineType.has(line.line_type())) { keep = false; n.RejLineType++; } // Check that PROBRIRW lines include the requested probability type - else if(line.type() == TCStatLineType_ProbRIRW && + else if(line.type() == TCStatLineType::ProbRIRW && !is_bad_data(ProbRIRWThresh) && is_bad_data(get_probrirw_value(line, ProbRIRWThresh))) { keep = false; @@ -885,7 +885,7 @@ double TCStatJob::get_column_double(const TCStatLine &line, // Check for PROBRIRW_PROB special case if(strcasecmp(column.c_str(), "PROBRIRW_PROB") == 0 && - line.type() == TCStatLineType_ProbRIRW) { + line.type() == TCStatLineType::ProbRIRW) { v = get_probrirw_value(line, ProbRIRWThresh); return v; } @@ -1289,7 +1289,7 @@ ConcatString TCStatJob::serialize() const { s.clear(); s.set_precision(get_precision()); - if(JobType != NoTCStatJobType) + if(JobType != TCStatJobType::None) s << "-job " << tcstatjobtype_to_string(JobType) << " "; for(i=0; i " << "unexpected stat line type \"" << statlinetype_to_string(cur_lt) @@ -3741,16 +3741,16 @@ void TCStatJobRIRW::setup_stat_file(int n_row) { // Write the STAT header row // switch(out_lt) { - case stat_ctc: + case STATLineType::ctc: write_header_row(ctc_columns, n_ctc_columns, 1, stat_at, 0, 0); break; - case stat_cts: + case STATLineType::cts: write_header_row(cts_columns, n_cts_columns, 1, stat_at, 0, 0); break; // Write only header columns for unspecified line type - case no_stat_line_type: + case STATLineType::none: write_header_row((const char **) 0, 0, 1, stat_at, 0, 0); break; @@ -3995,7 +3995,7 @@ void TCStatJobProbRIRW::clear() { TCStatJob::clear(); - JobType = TCStatJobType_ProbRIRW; + JobType = TCStatJobType::ProbRIRW; ByColumn.clear(); ProbRIRWMap.clear(); @@ -4337,10 +4337,10 @@ void TCStatJobProbRIRW::do_output(ostream &out) { out_lt = string_to_statlinetype(OutLineType[i].c_str()); // Write the header columns - if(out_lt == stat_pct) lt_cols = get_n_pct_columns (n); - else if(out_lt == stat_pstd) lt_cols = get_n_pstd_columns(n); - else if(out_lt == stat_prc) lt_cols = get_n_prc_columns (n); - else if(out_lt == stat_pjc) lt_cols = get_n_pjc_columns (n); + if(out_lt == STATLineType::pct) lt_cols = get_n_pct_columns (n); + else if(out_lt == STATLineType::pstd) lt_cols = get_n_pstd_columns(n); + else if(out_lt == STATLineType::prc) lt_cols = get_n_prc_columns (n); + else if(out_lt == STATLineType::pjc) lt_cols = get_n_pjc_columns (n); else { mlog << Error << "\nvoid TCStatJobProbRIRW::do_output(ostream &out) -> " << "unsupported output line type \"" << OutLineType[i] << "\"\n\n"; @@ -4371,10 +4371,10 @@ void TCStatJobProbRIRW::do_output(ostream &out) { out_at.set_entry(r, c++, ByColumn[j]); // Write the header columns - if(out_lt == stat_pct) write_pct_header_row (0, n, out_at, r, c); - else if(out_lt == stat_pstd) write_pstd_header_row(0, n, out_at, r, c); - else if(out_lt == stat_prc) write_prc_header_row (0, n, out_at, r, c); - else if(out_lt == stat_pjc) write_pjc_header_row (0, n, out_at, r, c); + if(out_lt == STATLineType::pct) write_pct_header_row (0, n, out_at, r, c); + else if(out_lt == STATLineType::pstd) write_pstd_header_row(0, n, out_at, r, c); + else if(out_lt == STATLineType::prc) write_prc_header_row (0, n, out_at, r, c); + else if(out_lt == STATLineType::pjc) write_pjc_header_row (0, n, out_at, r, c); // Loop over the map entries and populate the output table for(it=ProbRIRWMap.begin(),r=1; it!=ProbRIRWMap.end(); it++,r++) { @@ -4399,7 +4399,7 @@ void TCStatJobProbRIRW::do_output(ostream &out) { out_at.set_entry(r, c++, sa[j]); // Compute PSTD statistics - if(out_lt == stat_pstd) { + if(out_lt == STATLineType::pstd) { it->second.Info.allocate_n_alpha(1); it->second.Info.alpha[0] = OutAlpha; it->second.Info.compute_stats(); @@ -4407,10 +4407,10 @@ void TCStatJobProbRIRW::do_output(ostream &out) { } // Write output columns - if(out_lt == stat_pct) write_pct_cols (it->second.Info, out_at, r, c); - else if(out_lt == stat_pstd) write_pstd_cols(it->second.Info, 0, out_at, r, c); - else if(out_lt == stat_prc) write_prc_cols (it->second.Info, out_at, r, c); - else if(out_lt == stat_pjc) write_pjc_cols (it->second.Info, out_at, r, c); + if(out_lt == STATLineType::pct) write_pct_cols (it->second.Info, out_at, r, c); + else if(out_lt == STATLineType::pstd) write_pstd_cols(it->second.Info, 0, out_at, r, c); + else if(out_lt == STATLineType::prc) write_prc_cols (it->second.Info, out_at, r, c); + else if(out_lt == STATLineType::pjc) write_pjc_cols (it->second.Info, out_at, r, c); } // end for it // Write the table for the current output line type @@ -4580,7 +4580,7 @@ double get_probrirw_value(const TCStatLine &line, double ProbRIRWThresh) { ConcatString cs; // Only valid for the PROBRIRW line type - if(line.type() != TCStatLineType_ProbRIRW) return bad_data_double; + if(line.type() != TCStatLineType::ProbRIRW) return bad_data_double; // Get the number of threhsolds n = atoi(line.get_item("N_THRESH")); diff --git a/src/tools/tc_utils/tc_stat/tc_stat_job.h b/src/tools/tc_utils/tc_stat/tc_stat_job.h index ec12e8e4bb..eb82a8006c 100644 --- a/src/tools/tc_utils/tc_stat/tc_stat_job.h +++ b/src/tools/tc_utils/tc_stat/tc_stat_job.h @@ -34,7 +34,7 @@ static const bool default_match_points = false; static const bool default_event_equal = false; // Default rapid intensification is an increase of 30 kts over 24 hours -static const TrackType default_rirw_track = TrackType_None; +static const TrackType default_rirw_track = TrackType::None; static const int default_rirw_time = 86400; static const bool default_rirw_exact = true; static const SingleThresh default_rirw_thresh(">=30.0"); @@ -109,17 +109,17 @@ struct cs_cmp { // // Enumerate all the possible TC-STAT Analysis Job Types // -enum TCStatJobType { - - TCStatJobType_Filter, // Filter out the TC-STAT data and write - // the lines to the filename specified. - TCStatJobType_Summary, // Compute summary info for one or more - // columns of data. - TCStatJobType_RIRW, // Derive contingency table and statistics - // for RI/RW events. - TCStatJobType_ProbRIRW, // Derive probabilistic contingency table and - // statistics for PROBRIRW lines. - NoTCStatJobType // Default value +enum class TCStatJobType { + + Filter, // Filter out the TC-STAT data and write + // the lines to the filename specified. + Summary, // Compute summary info for one or more + // columns of data. + RIRW, // Derive contingency table and statistics + // for RI/RW events. + ProbRIRW, // Derive probabilistic contingency table and + // statistics for PROBRIRW lines. + None // Default value }; extern TCStatJobType string_to_tcstatjobtype(const ConcatString);