{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Example: Introductory Use Case\n\nmet_tool_wrapper/Example/Example.conf\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Scientific Objective\n\nNone.\n\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Datasets\n\nNone.\n\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## METplus Components\n\nThis use case utilizes the METplus Example wrapper to demonstrate the effect of time looping and filename template METplus configuration variables.\n\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## METplus Workflow\n\nExample is the only tool called in this example. This configuration loops by valid time every 6 hours from 2017-02-01 at 0Z until 2017-02-02 at 0Z. For each valid time, the 3, 6, 9, and 12 hour forecast leads are processed. It processes the following run times:\n\n| **Valid:** 2017-02-01 0Z\n| **Forecast lead:** 3 hour\n\n| **Valid:** 2017-02-01 0Z\n| **Forecast lead:** 6 hour\n\n| **Valid:** 2017-02-01 0Z\n| **Forecast lead:** 9 hour\n\n| **Valid:** 2017-02-01 0Z\n| **Forecast lead:** 12 hour\n\n| **Valid:** 2017-02-01 6Z\n| **Forecast lead:** 3 hour\n\n| **Valid:** 2017-02-01 6Z\n| **Forecast lead:** 6 hour\n\n| **Valid:** 2017-02-01 6Z\n| **Forecast lead:** 9 hour\n\n| **Valid:** 2017-02-01 6Z\n| **Forecast lead:** 12 hour\n\n| **Valid:** 2017-02-01 12Z\n| **Forecast lead:** 3 hour\n\n| **Valid:** 2017-02-01 12Z\n| **Forecast lead:** 6 hour\n\n| **Valid:** 2017-02-01 12Z\n| **Forecast lead:** 9 hour\n\n| **Valid:** 2017-02-01 12Z\n| **Forecast lead:** 12 hour\n\n| **Valid:** 2017-02-01 18Z\n| **Forecast lead:** 3 hour\n\n| **Valid:** 2017-02-01 18Z\n| **Forecast lead:** 6 hour\n\n| **Valid:** 2017-02-01 18Z\n| **Forecast lead:** 9 hour\n\n| **Valid:** 2017-02-01 18Z\n| **Forecast lead:** 12 hour\n\n| **Valid:** 2017-02-02 0Z\n| **Forecast lead:** 3 hour\n\n| **Valid:** 2017-02-02 0Z\n| **Forecast lead:** 6 hour\n\n| **Valid:** 2017-02-02 0Z\n| **Forecast lead:** 9 hour\n\n| **Valid:** 2017-02-02 0Z\n| **Forecast lead:** 12 hour\n|\n\n\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## METplus Configuration\n\nMETplus first loads all of the configuration files found in parm/metplus_config, then it loads any configuration files passed to METplus via the command line with the -c option, i.e. -c parm/use_cases/met_tool_wrapper/Example/Example.conf\n\n.. highlight:: bash\n.. literalinclude:: ../../../../parm/use_cases/met_tool_wrapper/Example/Example.conf\n\nThe following configuration variables tell METplus to loop by valid time starting at 2017-02-01 0Z, ending on 2017-02-02 0Z, incrementing 6 hours each iteration::\n\n  LOOP_BY = VALID\n  VALID_TIME_FMT = %Y%m%d%H\n  VALID_BEG = 2017020100\n  VALID_END = 2017020200\n  VALID_INCREMENT = 6H\n\nThe following configuration variable tells METplus to process the 3 hour, 6 hour, 9 hour, and 12 hour forecast leads for EACH valid time::\n\n  LEAD_SEQ = 3H, 6H, 9H, 12H\n\nThe following configuration variable tells METplus to look in /dir/containing/example/data to find data to process::\n\n  [dir]\n  EXAMPLE_INPUT_DIR = /dir/containing/example/data\n\nNote that this variable must be found following the [dir] section header\n\nThe following configuration variable tells METplus to look for files in the input directory matching the format specified::\n\n  [filename_templates]\n  EXAMPLE_INPUT_TEMPLATE = {init?fmt=%Y%m%d}/file_{init?fmt=%Y%m%d}_{init?fmt=%2H}_F{lead?fmt=%3H}.ext\n\nFor example, valid time 2017-02-01 18Z and forecast lead 3 hours, the desired file is /dir/containing/example/data/20170201/file_20170201_15_F03.ext\n\nNote that the initialization time used is 2017-02-01 15Z, which is calculated by subtracting the forecast lead from the valid time.\n\n\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## MET Configuration\n\nNone.\n\n\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Running METplus\n\nThis use case can be run two ways:\n\n1) Passing in Example.conf then a user-specific system configuration file::\n\n       run_metplus.py -c /path/to/METplus/parm/use_cases/met_tool_wrapper/Example/Example.conf -c /path/to/user_system.conf\n\n2) Modifying the configurations in parm/metplus_config, then passing in Example.conf::\n\n       run_metplus.py -c /path/to/METplus/parm/use_cases/met_tool_wrapper/Example/Example.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* **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  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\nA successful run will output the following both to the screen and to the logfile::\n\n  INFO: METplus has successfully finished running.\n\nYou should also see a series of log output listing init/valid times, forecast lead times, and filenames derived from the filename templates. Here is an excerpt::\n\n  12/30 19:44:02.901 metplus (met_util.py:425) INFO: ****************************************\n  12/30 19:44:02.901 metplus (met_util.py:426) INFO: * Running METplus\n  12/30 19:44:02.902 metplus (met_util.py:432) INFO: *  at valid time: 201702010000\n  12/30 19:44:02.902 metplus (met_util.py:435) INFO: ****************************************\n  12/30 19:44:02.902 metplus.Example (example_wrapper.py:58) INFO: Running ExampleWrapper at valid time 20170201000000\n  12/30 19:44:02.902 metplus.Example (example_wrapper.py:63) INFO: Input directory is /dir/containing/example/data\n  12/30 19:44:02.902 metplus.Example (example_wrapper.py:64) INFO: Input template is {init?fmt=%Y%m%d}/file_{init?fmt=%Y%m%d}_{init?fmt=%2H}_F{lead?fmt=%3H}.ext\n  12/30 19:44:02.902 metplus.Example (example_wrapper.py:79) INFO: Processing forecast lead 3 hours initialized at 2017-01-31 21Z and valid at 2017-02-01 00Z\n  12/30 19:44:02.903 metplus.Example (example_wrapper.py:88) INFO: Looking in input directory for file: 20170131/file_20170131_21_F003.ext\n  12/30 19:44:02.903 metplus.Example (example_wrapper.py:79) INFO: Processing forecast lead 6 hours initialized at 2017-01-31 18Z and valid at 2017-02-01 00Z\n  12/30 19:44:02.903 metplus.Example (example_wrapper.py:88) INFO: Looking in input directory for file: 20170131/file_20170131_18_F006.ext\n  12/30 19:44:02.904 metplus.Example (example_wrapper.py:79) INFO: Processing forecast lead 9 hours initialized at 2017-01-31 15Z and valid at 2017-02-01 00Z\n  12/30 19:44:02.904 metplus.Example (example_wrapper.py:88) INFO: Looking in input directory for file: 20170131/file_20170131_15_F009.ext\n  12/30 19:44:02.904 metplus.Example (example_wrapper.py:79) INFO: Processing forecast lead 12 hours initialized at 2017-01-31 12Z and valid at 2017-02-01 00Z\n  12/30 19:44:02.904 metplus.Example (example_wrapper.py:88) INFO: Looking in input directory for file: 20170131/file_20170131_12_F012.ext\n  12/30 19:44:02.904 metplus (met_util.py:425) INFO: ****************************************\n  12/30 19:44:02.904 metplus (met_util.py:426) INFO: * Running METplus\n  12/30 19:44:02.905 metplus (met_util.py:432) INFO: *  at valid time: 201702010600\n  12/30 19:44:02.905 metplus (met_util.py:435) INFO: ****************************************\n  12/30 19:44:02.905 metplus.Example (example_wrapper.py:58) INFO: Running ExampleWrapper at valid time 20170201060000\n  12/30 19:44:02.905 metplus.Example (example_wrapper.py:63) INFO: Input directory is /dir/containing/example/data\n  12/30 19:44:02.905 metplus.Example (example_wrapper.py:64) INFO: Input template is {init?fmt=%Y%m%d}/file_{init?fmt=%Y%m%d}_{init?fmt=%2H}_F{lead?fmt=%3H}.ext\n  12/30 19:44:02.905 metplus.Example (example_wrapper.py:79) INFO: Processing forecast lead 3 hours initialized at 2017-02-01 03Z and valid at 2017-02-01 06Z\n  12/30 19:44:02.906 metplus.Example (example_wrapper.py:88) INFO: Looking in input directory for file: 20170201/file_20170201_03_F003.ext\n\n\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Keywords\n\n<div class=\"alert alert-info\"><h4>Note</h4><p>* ExampleToolUseCase\n\n  Navigate to the `quick-search` page to discover other similar use cases.</p></div>\n\n\n"
      ]
    }
  ],
  "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.7.9"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}