{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# UserScript: Run Once Per Init Use Case\n\nmet_tool_wrapper/UserScript/UserScript_run_once_per_init.conf\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Scientific Objective\n\nDemonstrate how to run a user-defined script that should be executed once\nfor each initialization time.\nThis use case runs a simple ls command to list the contents of a directory.\nA wildcard character (*) is used to replace filename template tags for\nvalid and lead to find all files that match any of the times available.\n\n\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Datasets\n\n| **Input:** Empty test files from the METplus repository\n|\n\n\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## METplus Components\n\nThis use case utilizes the METplus UserScript wrapper to generate a command\nthat is specified by the user.\n\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## METplus Workflow\n\nUserScript is the only tool called in this example. It processes the following\nrun times:\n\n| **Init:** 2014-10-31 09:30:15\n| **Init:** 2014-10-31 21:30:15\n| **Init:** 2014-11-01 09:30:15\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,\nthen it loads any configuration files passed to METplus via the command line\nwith the -c option, i.e. -c parm/use_cases/met_tool_wrapper/UserScript/UserScript_run_once_per_init.conf\n\n.. highlight:: bash\n.. literalinclude:: ../../../../parm/use_cases/met_tool_wrapper/UserScript/UserScript_run_once_per_init.conf\n\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## MET Configuration\n\nNone. UserScript does not use configuration files.\n\n\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Running METplus\n\nThis use case can be run two ways:\n\n1) Passing in UserScript_run_once_per_init.conf_run_once then a user-specific system configuration file::\n\n       run_metplus.py -c /path/to/METplus/parm/use_cases/met_tool_wrapper/UserScript/UserScript_run_once_per_init.conf_run_once -c /path/to/user_system.conf\n\n2) Modifying the configurations in parm/metplus_config, then passing in UserScript_run_once_per_init.conf::\n\n       run_metplus.py -c /path/to/METplus/parm/use_cases/met_tool_wrapper/GridStat/UserScript_run_once_per_init.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\nA successful run will output the following both to the screen and to the logfile::\n\n  INFO: METplus has successfully finished running.\n\nNo output files are generated from this use case, but the logfile will\ncontain the results of the directory listing command(s)\n\nInit time: 2014-10-31 09:30:15\n\n* init_20141031093015_valid_20141031093015_lead_000.nc\n* init_20141031093015_valid_20141031213015_lead_012.nc\n* init_20141031093015_valid_20141101093015_lead_024.nc\n* init_20141031093015_valid_20141102093015_lead_048.nc\n* init_20141031093015_valid_20141103093015_lead_072.nc\n* init_20141031093015_valid_20141104093015_lead_096.nc\n* init_20141031093015_valid_20141105093015_lead_120.nc\n* init_20141031093015_valid_20141106093015_lead_144.nc\n* init_20141031093015_valid_20141107093015_lead_168.nc\n\nInit time: 2014-10-31 21:30:15\n\n* init_20141031213015_valid_20141031213015_lead_000.nc\n* init_20141031213015_valid_20141101093015_lead_012.nc\n* init_20141031213015_valid_20141101213015_lead_024.nc\n* init_20141031213015_valid_20141102213015_lead_048.nc\n* init_20141031213015_valid_20141103213015_lead_072.nc\n* init_20141031213015_valid_20141104213015_lead_096.nc\n* init_20141031213015_valid_20141105213015_lead_120.nc\n* init_20141031213015_valid_20141106213015_lead_144.nc\n* init_20141031213015_valid_20141107213015_lead_168.nc\n\nInit time: 2014-11-01 09:30:15\n\n* init_20141101093015_valid_20141101093015_lead_000.nc\n* init_20141101093015_valid_20141101213015_lead_012.nc\n* init_20141101093015_valid_20141102093015_lead_024.nc\n* init_20141101093015_valid_20141103093015_lead_048.nc\n* init_20141101093015_valid_20141104093015_lead_072.nc\n* init_20141101093015_valid_20141105093015_lead_096.nc\n* init_20141101093015_valid_20141106093015_lead_120.nc\n* init_20141101093015_valid_20141107093015_lead_144.nc\n* init_20141101093015_valid_20141108093015_lead_168.nc\n\n\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Keywords\n\n<div class=\"alert alert-info\"><h4>Note</h4><p>* UserScriptUseCase\n  * RuntimeFreqUseCase\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
}