{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\nGrid-Stat: Analysis validation \n==============================================================================\n\nDemonstrates the use of METplus for model validation as both of the \n\"forecast\" and \"obs\" fields are from different versions of the same model. \n(GloTEC:GloTEC:NetCDF with multiple times in file) \n\n\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Overview\n--------\n\nThis use case illustrates the use of grid_stat tool for the space weather domain.\nIt compares Total Electron Content for a GloTEC model run initialized with COSMIC-1\nradio occultation (RO) data to a GloTEC model run without such data. \n\nIn this use case, the forecast is considered to be the run without COSMIC-1 RO data.\nThe observations are considered to be the run with COSMIC-1 RO data.\n\nThis use case runs grid_stat for the first two forecast times of a \nspace weather event known as the St. Patrick's Day Storm (Mar 17, 2015). \n\nNovel aspects of this use case:\n\n* This is the first example use case to run grid_stat on a space weather model (GloTEC)\n* Example of how to run with NetCDF input data which do not strictly conform to the Climate Forecasts (CF) conventions\n* Example of using masks covering latitudinal bands of interest to the space weather community: equatorial region, mid-latitude region, and polar region\n* Example of masking using the values of a quality flag which vary at each time step and grid point\n\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Scientific Objective\n--------------------\n\nCompare gridded forecast data from a run of the GloTEC model that includes \nassimilation of COSMIC-1 radio occultation (RO) observations to gridded forecast \ndata from a GloTEC model run that does not include COSMIC-1 RO data. \n\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Datasets\n--------\n\n| **Forecast:** GloTEC Total Electron Content (TEC) model run without assimilation of any COSMIC-1 RO data\n| **Observation:** GloTEC TEC model run that assimilates COSMIC-1 RO data\n\n| **Location:** All of the input data required for this use case can be found in the sample data tarball. \n| Click here to download: https://github.com/NCAR/METplus/releases/download/v3.0/sample_data-space_weather-3.0.tgz\n| This tarball should be unpacked into the directory that you will set the value of INPUT_BASE. See 'Running METplus' section for more information.\n\n| **Data source:** NOAA Space Weather Prediction Center (SWPC)\n| **Data contact:** Dominic Fuller-Rowell (dominic.fuller-rowell@noaa.gov)\n\n\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "METplus Use Case Contact\n------------------------\n\n| **Author:** Jonathan L. Vigh (National Center for Atmospheric Research / Research Applications Laboratory / Joint Numerical Testbed)\n| **Last modified:** 06 February 2020\n\n\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "METplus Components\n------------------\n\nThis use case utilizes the METplus GridStat wrapper to search for\nfiles that are valid at a given run time and generate a command to run\nthe MET tool grid_stat if all required files are found.\n\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "METplus Workflow\n----------------\n\nGridStat is the only tool called in this example. It processes the following\nrun times:\n\n| **Init:** 2015-03-17 0005Z\n| **Forecast lead:** 0\n\n| **Init:** 2015-03-17 0015Z\n| **Forecast lead:** 0\n\n\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "METplus Configuration\n---------------------\n\nMETplus first loads all of the configuration files found in parm/metplus_config,\nthen it loads any configuration files passed to METplus via the command line\nwith the -c option, i.e. -c parm/use_cases/model_applications/space_weather/GridStat_fcstGloTEC_obsGloTEC_vx7.conf\n\n.. highlight:: bash\n.. literalinclude:: ../../../../parm/use_cases/model_applications/space_weather/GridStat_fcstGloTEC_obsGloTEC_vx7.conf\n\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "MET Configuration\n---------------------\n\nMETplus sets environment variables based on the values in the METplus configuration file.\nThese variables are referenced in the MET configuration file.\n\n.. highlight:: bash\n.. literalinclude:: ../../../../parm/use_cases/model_applications/space_weather/GridStatConfig_vx7\n\nNote the following variables are referenced in the MET configuration file.\n\n* **${MODEL}** - Name of forecast input. Corresponds to MODEL in the METplus configuration file.\n* **${OBTYPE}** - Name of observation input. Corresponds to OBTYPE in the METplus configuration file.\n* **${FCST_FIELD}** - Formatted forecast field information. Generated from FCST_VAR<n>_[NAME/LEVEL/THRESH/OPTIONS] in the METplus configuration file.\n* **${OBS_FIELD}** - Formatted observation field information. Generated from OBS_VAR<n>_[NAME/LEVEL/THRESH/OPTIONS] in the METplus configuration file.\n* **${FCST_VAR}** - Field name of forecast data to process. Used in output_prefix to include input information in the output filenames. Corresponds to FCST_VAR<n>_NAME in the METplus configuration file.\n* **${OBS_VAR}** - Field name of observation data to process. Used in output_prefix to include input information in the output filenames. Corresponds to OBS_VAR<n>_NAME in the METplus configuration file.\n* **${LEVEL}** - Vertical level of the forecast input data. Used in output_prefix to include input information in the output filenames. Corresponds to FCST_VAR<n>_LEVELS in the METplus configuration file.\n* **${VERIF_MASK}** - Optional verification mask file or list of files. Corresponds to GRID_STAT_VERIFICATION_MASK_TEMPLATE in the METplus configuration file.\n* **${NEIGHBORHOOD_SHAPE}** - Shape of the neighborhood method applied. Corresponds to GRID_STAT_NEIGHBORHOOD_SHAPE in the METplus configuration file. Default value is 1 if not set.\n* **${NEIGHBORHOOD_WIDTH}** - Width of the neighborhood method applied. Corresponds to GRID_STAT_NEIGHBORHOOD_WIDTH in the METplus configuration file. Default value is SQUARE if not set.\n\n\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Running METplus\n---------------\n\nThis use case can be run two ways:\n\n1) Passing in GridStat_fcstGloTEC_obsGloTEC_vx7.conf then a user-specific system configuration file::\n\n       master_metplus.py -c /path/to/METplus/parm/use_cases/model_applications/space_weather/GridStat_fcstGloTEC_obsGloTEC_vx7.conf -c /path/to/user_system.conf\n\n2) Modifying the configurations in parm/metplus_config, then passing in GridStat_fcstGloTEC_obsGloTEC_vx7.conf::\n\n       master_metplus.py -c /path/to/METplus/parm/use_cases/model_applications/space_weather/GridStat_fcstGloTEC_obsGloTEC_vx7.conf\n\nThe former method is recommended. Whether you add them to a user-specific configuration file or modify the metplus_config files, the following variables must be set correctly:\n\n* **INPUT_BASE** - Path to directory where sample data tarballs are unpacked (See Datasets section to obtain tarballs). This is not required to run METplus, but it is required to run the examples in parm/use_cases\n* **OUTPUT_BASE** - Path where METplus output will be written. This must be in a location where you have write permissions\n* **MET_INSTALL_DIR** - Path to location where MET is installed locally\n\nExample User Configuration File::\n\n  [dir]\n  INPUT_BASE = /path/to/sample/input/data\n  OUTPUT_BASE = /path/to/output/dir\n  MET_INSTALL_DIR = /path/to/met-X.Y \n\n**NOTE:** All of these items must be found under the [dir] section.\n\n\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Expected Output\n---------------\n\nA successful run will output the following both to the screen and to the logfile::\n\n  INFO: METplus has successfully finished running.\n\nRefer to the value set for **OUTPUT_BASE** to find where the output data was generated.\nOutput for this use case will be found in space_weather/glotec_vs_glotec/output_data/2015_03_17 (relative to **OUTPUT_BASE**)\nand will contain the following files:\n\n* grid_stat_GloTEC_without_cosmic-vx7_TEC_vs_GloTEC_with_cosmic_000000L_20150317_000500V_pairs.nc  \n* grid_stat_GloTEC_without_cosmic-vx7_TEC_vs_GloTEC_with_cosmic_000000L_20150317_001500V_pairs.nc\n* grid_stat_GloTEC_without_cosmic-vx7_TEC_vs_GloTEC_with_cosmic_000000L_20150317_000500V.stat      \n* grid_stat_GloTEC_without_cosmic-vx7_TEC_vs_GloTEC_with_cosmic_000000L_20150317_001500V.stat\n\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Keywords\n--------\n\n<div class=\"alert alert-info\"><h4>Note</h4><p></p></div>\n\n `GridStatToolUseCase <https://ncar.github.io/METplus/search.html?q=GridStatToolUseCase&check_keywords=yes&area=default>`_,\n `SpaceWeatherAppUseCase <https://ncar.github.io/METplus/search.html?q=SpaceWeatherAppUseCase&check_keywords=yes&area=default>`_,\n `NOAASWPCOrgUseCase  <https://ncar.github.io/METplus/search.html?q=NOAASWPCOrgUseCase&check_keywords=yes&area=default>`_,\n `CustomStringLoopingUseCase <https://ncar.github.io/METplus/search.html?q=CustomStringLoopingUseCase&check_keywords=yes&area=default>`_,\n `MaskingFeatureUseCase  <https://ncar.github.io/METplus/search.html?q=MaskingFeatureUseCase&check_keywords=yes&area=default>`_,\n `ValidationUseCase  <https://ncar.github.io/METplus/search.html?q=ValidationUseCase&check_keywords=yes&area=default>`_\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        ""
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.6.12"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}