<reponame>NOAA-EMC/oops<filename>tools/plot.py
#!/usr/bin/env python3
"""
@author: <NAME>
@description: plotting facility for L95 and QG
"""

import os
import argparse
import sys

# -----------------------------------------------------------------------------
# Main parser -----------------------------------------------------------------
# -----------------------------------------------------------------------------
parser = argparse.ArgumentParser()
subparser_model = parser.add_subparsers(help="model help", required=True, dest="model")

# -----------------------------------------------------------------------------
# L95 model sub-parsers --------------------------------------------------------
# -----------------------------------------------------------------------------
parser_l95 = subparser_model.add_parser("l95", help="L95 parser")

# L95 diagnostics sub-parsers
subparser_diagnostic_l95 = parser_l95.add_subparsers(help="L95 diagnostic help", required=True, dest="diagnostic")
parser_l95_cost = subparser_diagnostic_l95.add_parser("cost", help="L95 cost parser")
parser_l95_fields = subparser_diagnostic_l95.add_parser("fields", help="L95 fields parser")

# L95 cost arguments
parser_l95_cost.add_argument("filepath", type=str, help="File path")
parser_l95_cost.add_argument("--output", help="Output file path")

# L95 fields arguments
parser_l95_fields.add_argument("filepath", help="File path")
parser_l95_fields.add_argument("basefilepath", nargs="?", help="Base file path", default=None)
parser_l95_fields.add_argument("--output", help="Output file path")

# -----------------------------------------------------------------------------
# QG model sub-parsers --------------------------------------------------------
# -----------------------------------------------------------------------------
parser_qg = subparser_model.add_parser("qg", help="QG parser")

# QG diagnostics sub-parsers
subparser_diagnostic_qg = parser_qg.add_subparsers(help="QG diagnostic help", required=True, dest="diagnostic")
parser_qg_cost = subparser_diagnostic_qg.add_parser("cost", help="QG cost parser")
parser_qg_fields = subparser_diagnostic_qg.add_parser("fields", help="QG fields parser")
parser_qg_obs = subparser_diagnostic_qg.add_parser("obs", help="QG obs parser")

# QG cost arguments
parser_qg_cost.add_argument("filepath", type=str, help="File path")
parser_qg_cost.add_argument("--output", help="Output file path")

# QG fields arguments
parser_qg_fields.add_argument("filepath", help="File path")
parser_qg_fields.add_argument("basefilepath", nargs="?", help="Base file path", default=None)
parser_qg_fields.add_argument("--plotwind", dest="plotwind", action="store_true", help="Plot wind")
parser_qg_fields.add_argument("--gif", help="Gif pattern values, separated with commas, replacing %id% in the file path")
parser_qg_fields.add_argument("--output", help="Output file path")

# QG obs arguments
parser_qg_obs.add_argument("filepath", type=str, help="File path")
parser_qg_obs.add_argument("--output", help="Output file path")

# -----------------------------------------------------------------------------
# Parse and print arguments ---------------------------------------------------
# -----------------------------------------------------------------------------
# Parse argument
args = parser.parse_args()

# Print arguments
print("Parameters:")
for arg in vars(args):
    if not arg is None:
        print(" - " + arg + ": " + str(getattr(args, arg)))

# -----------------------------------------------------------------------------
# Load appropriate module and run function ------------------------------------
# -----------------------------------------------------------------------------
sys.path.insert(1, "plot")
module = __import__(args.model + "_" + args.diagnostic)
func = getattr(module, "func")
print("Run script")
func(args)

#!/usr/bin/env python3
"""
@author: <NAME>
@description: plotting facility for L95 and QG
"""

import os
import argparse
import sys

# -----------------------------------------------------------------------------
# Main parser -----------------------------------------------------------------
# -----------------------------------------------------------------------------
parser = argparse.ArgumentParser()
subparser_model = parser.add_subparsers(help="model help", required=True, dest="model")

# -----------------------------------------------------------------------------
# L95 model sub-parsers --------------------------------------------------------
# -----------------------------------------------------------------------------
parser_l95 = subparser_model.add_parser("l95", help="L95 parser")

# L95 diagnostics sub-parsers
subparser_diagnostic_l95 = parser_l95.add_subparsers(help="L95 diagnostic help", required=True, dest="diagnostic")
parser_l95_cost = subparser_diagnostic_l95.add_parser("cost", help="L95 cost parser")
parser_l95_fields = subparser_diagnostic_l95.add_parser("fields", help="L95 fields parser")

# L95 cost arguments
parser_l95_cost.add_argument("filepath", type=str, help="File path")
parser_l95_cost.add_argument("--output", help="Output file path")

# L95 fields arguments
parser_l95_fields.add_argument("filepath", help="File path")
parser_l95_fields.add_argument("basefilepath", nargs="?", help="Base file path", default=None)
parser_l95_fields.add_argument("--output", help="Output file path")

# -----------------------------------------------------------------------------
# QG model sub-parsers --------------------------------------------------------
# -----------------------------------------------------------------------------
parser_qg = subparser_model.add_parser("qg", help="QG parser")

# QG diagnostics sub-parsers
subparser_diagnostic_qg = parser_qg.add_subparsers(help="QG diagnostic help", required=True, dest="diagnostic")
parser_qg_cost = subparser_diagnostic_qg.add_parser("cost", help="QG cost parser")
parser_qg_fields = subparser_diagnostic_qg.add_parser("fields", help="QG fields parser")
parser_qg_obs = subparser_diagnostic_qg.add_parser("obs", help="QG obs parser")

# QG cost arguments
parser_qg_cost.add_argument("filepath", type=str, help="File path")
parser_qg_cost.add_argument("--output", help="Output file path")

# QG fields arguments
parser_qg_fields.add_argument("filepath", help="File path")
parser_qg_fields.add_argument("basefilepath", nargs="?", help="Base file path", default=None)
parser_qg_fields.add_argument("--plotwind", dest="plotwind", action="store_true", help="Plot wind")
parser_qg_fields.add_argument("--gif", help="Gif pattern values, separated with commas, replacing %id% in the file path")
parser_qg_fields.add_argument("--output", help="Output file path")

# QG obs arguments
parser_qg_obs.add_argument("filepath", type=str, help="File path")
parser_qg_obs.add_argument("--output", help="Output file path")

# -----------------------------------------------------------------------------
# Parse and print arguments ---------------------------------------------------
# -----------------------------------------------------------------------------
# Parse argument
args = parser.parse_args()

# Print arguments
print("Parameters:")
for arg in vars(args):
    if not arg is None:
        print(" - " + arg + ": " + str(getattr(args, arg)))

# -----------------------------------------------------------------------------
# Load appropriate module and run function ------------------------------------
# -----------------------------------------------------------------------------
sys.path.insert(1, "plot")
module = __import__(args.model + "_" + args.diagnostic)
func = getattr(module, "func")
print("Run script")
func(args)
#!/usr/bin/env python3 @author: <NAME> @description: plotting facility for L95 and QG # ----------------------------------------------------------------------------- # Main parser ----------------------------------------------------------------- # ----------------------------------------------------------------------------- # ----------------------------------------------------------------------------- # L95 model sub-parsers -------------------------------------------------------- # ----------------------------------------------------------------------------- # L95 diagnostics sub-parsers # L95 cost arguments # L95 fields arguments # ----------------------------------------------------------------------------- # QG model sub-parsers -------------------------------------------------------- # ----------------------------------------------------------------------------- # QG diagnostics sub-parsers # QG cost arguments # QG fields arguments # QG obs arguments # ----------------------------------------------------------------------------- # Parse and print arguments --------------------------------------------------- # ----------------------------------------------------------------------------- # Parse argument # Print arguments # ----------------------------------------------------------------------------- # Load appropriate module and run function ------------------------------------ # -----------------------------------------------------------------------------