"""
TCGen: Genesis Density Function (GDF) and Track Density Function (TDF) 
======================================================================

model_applications/s2s/TCGen_fcstGFSO_obsBDECKS_GDF_TDF.conf

"""
##############################################################################
# .. contents::
#   :depth: 1
#   :local:
#   :backlinks: none

##############################################################################
# Scientific Objective
# --------------------
# 
# Tropocal cyclone (TC) genesis density function (GDF) and track density function (TDF) are designed to
# quantitatively evaluate geographic distributions of TC activities including TC genesis frequency and
# subsequent TC tracks. Spatial patterns of long-term averaged GDF or TDF on the regional or global scale
# are particularly useful to evaluate TC forecasts against those derived from an observational best-track
# dataset, such as IBTrACS or ATCF B-decks, from a climate perspective. The metrics can help assess the forecast biases
# (under- or over-prediction) of TC formations or TC vortices around particular locations in a numerical model.
#
# For demonstration purposes, only cyclone tracker output and b-decks data for 2016 are used.
# 
# The following settings are used in the use case, all of which are configurable in the METplus configuration file (see below).
#
# Forecast genesis event criteria:
#
# | Minimum forecast lead: 48h
# | Maximum forecast lead: 120h
# | Maximum velocity threshold: >= 16.5 m/s
# | Minimum TC duration: 24h
# |
#
# Observed genesis event criteria:
#
# | Minimum TC duration: 24h
# | Maximum velocity threshold: >= 17.0 m/s
# | Minimum TC Category: TD
# |
#
# Matching settings:
#
# | Genesis matching window: +/- 24h
# | Early genesis matching window: -120h
# | Late genesis matching window: +120h
# | Genesis hit scoring window: +/- 24h
# | Early genesis hit scoring window: -120h
# | Late genesis hit scoring window: +120h
# | Matching and Scoring radius: 555 km
# | 
#
# In addition to the above settings, normalization is performed on the metrics by the number of years included in the dataset
# (in this example, just one), and the total number of model forecasts valid at the time of an observed genesis event. The latter
# can also be thought of as the total number of chances that the model had to forecast a genesis event.
#

##############################################################################
# Version Added
# -------------
#
# METplus version 4.1

##############################################################################
# Datasets
# --------
#
# Both forecast and observation datasets for this use case must adhere to the ATCF format.
#
# **Forecast:**
# GFDL Cyclone Tracker output configured for "genesis mode" for the FV3GFS model.
# This configuration used an experimental GFSv15 physics package,
# and had a horizontal grid spacing of ~25 km with 64 vertical levels.
#
# **Observation:**
# Global ATCF B-decks files from the National Hurricane Center (NHC) and Joint Typhoon Warning Center (JTWC)
#
# **Climatology:** None
#
# **Location:** All of the input data required for this use case can be 
# found in a sample data tarball. Each use case category will have 
# one or more sample data tarballs. It is only necessary to download 
# the tarball with the use case’s dataset and not the entire collection 
# of sample data. Click here to access the METplus releases page and download sample data 
# for the appropriate release: https://github.com/dtcenter/METplus/releases
# This tarball should be unpacked into the directory that you will 
# set the value of INPUT_BASE. See :ref:`running-metplus` section for more information.

##############################################################################
# Software Versions
# -----------------
#
# This use case was developed with specific versions of various software and Python packages. Any deviation from these versions
# may require re-configuration or adaptation to reproduce the results shown.
#
# Names and version numbers::
#
#  python-3.6.3
#  cartopy-0.18.0
#  matplotlib-3.1.2
#  MET-10.0.0
#  METplus-4.0.0
#  METplotpy-1.0.0
#

##############################################################################
# METplus Components
# ------------------
#
# This use case utilizes the MET TCGen tool to generate matched pairs of TC genesis,
# and then uses Python Embedding to compute the TDF and GDF metrics and create graphics for
# the year 2016.
#

##############################################################################
# METplus Workflow
# ----------------
#
# **Beginning time (INIT_BEG):** 2016
#
# **End time (INIT_END):** None
#
# **Increment between beginning and end times (INIT_INCREMENT):** None
#
# **Sequence of forecast leads to process (LEAD_SEQ):** None
#
# The following tools are used for each run time: TCGen, Python
#
# The TCGen tool is designed to be provided a single file pair or a directory containing a list of files,
# rather than loop over valid or initialization times. Thus, a single year is used in the METplus configuration
# file and wildcard symbols are provided to gather all the tracker and genesis input files at each
# input directory.

##############################################################################
# METplus Configuration
# ---------------------
#
# .. highlight:: bash
# .. literalinclude:: ../../../../parm/use_cases/model_applications/s2s/TCGen_fcstGFSO_obsBDECKS_GDF_TDF.conf
#

##############################################################################
# MET Configuration
# -----------------
#
# METplus sets environment variables based on user settings in the METplus configuration file. 
# See :ref:`How METplus controls MET config file settings<metplus-control-met>` for more details. 
#
# **YOU SHOULD NOT SET ANY OF THESE ENVIRONMENT VARIABLES YOURSELF! THEY WILL BE OVERWRITTEN BY METPLUS WHEN IT CALLS THE MET TOOLS!**
#
# If there is a setting in the MET configuration file that is currently not supported by METplus you'd like to control, please refer to:
# :ref:`Overriding Unsupported MET config file settings<met-config-overrides>`
#
# .. dropdown:: TCGenConfig_wrapped
#
#   .. literalinclude:: ../../../../parm/met_config/TCGenConfig_wrapped

##############################################################################
# Python Embedding
# ----------------
#
# This use case uses a Python embedding script to create output graphics.
#
#  .. dropdown:: parm/use_cases/model_applications/s2s/TCGen_fcstGFSO_obsBDECKS_GDF_TDF/UserScript_fcstGFSO_obsBDECKS_GDF_TDF.py
#
#   .. highlight:: python
#   .. literalinclude:: ../../../../parm/use_cases/model_applications/s2s/TCGen_fcstGFSO_obsBDECKS_GDF_TDF/UserScript_fcstGFSO_obsBDECKS_GDF_TDF.py
#
# For more information on the basic requirements to utilize Python Embedding in METplus, 
# please refer to the MET User’s Guide section on
# `Python embedding <https://met.readthedocs.io/en/latest/Users_Guide/appendixF.html#appendix-f-python-embedding>`_.

##############################################################################
# User Scripting
# --------------
#
# User Scripting is not used in this use case.

##############################################################################
# Running METplus
# ---------------
#
# Pass the use case configuration file to the run_metplus.py script along 
# with any user-specific system configuration files if desired::
#
#   run_metplus.py /path/to/METplus/parm/use_cases/model_applications/s2s/TCGen_fcstGFSO_obsBDECKS_GDF_TDF.conf /path/to/user_system.conf
#
# See :ref:`running-metplus` for more information.

##############################################################################
# Expected Output
# ---------------
#
# A successful run will output the following both to the screen and to the logfile::
#
#   INFO: METplus has successfully finished running.
#
# Refer to the value set for **OUTPUT_BASE** to find where the output data was generated.
#
# Output from TCGen for this use case will be found in model_applications/s2s/TCGen_fcstGFSO_obsBDECKS_GDF_TDF/TCGen (relative to **OUTPUT_BASE**)
#
# For each month and year there will be five files written::
#
# * tc_gen_2016_pairs.nc
# * tc_gen_2016_genmpr.txt
# * tc_gen_2016_ctc.txt
# * tc_gen_2016_cts.txt
# * tc_gen_2016.stat
#

##############################################################################
# Keywords
# --------
#
# .. note::
#
#   * TCGenToolUseCase 
#   * S2SAppUseCase
#   * UserScriptUseCase
#   * METplotpyUseCase
#
#   Navigate to the :ref:`quick-search` page to discover other similar use cases.
#
#
#

# sphinx_gallery_thumbnail_path = '_static/s2s-TCGen_fcstGFSO_obsBDECKS_GDF_TDF.png'
#
