#!/usr/bin/env python
import os
import argparse

import Ngl

from wrf.system import SOMMemberPlotSystem

if __name__ == "__main__":
    
    parser = argparse.ArgumentParser(description="Generate meteorological "
                                     "plots for SOM members")
    parser.add_argument("-c", "--casename", required=True, 
                        help="the case name (e.g. 'site1-october')")
    parser.add_argument("-s", "--somid", required=True,
                        help="the SOM ID to use (e.g. 'SOM001')")
    parser.add_argument("-p", "--caseparent", required=False,
                       default="/projectw/reanalyses/1.2",
                       help=("the case parent directory "
                             "[default: /projectw/reanalyses/1.2]"))
    args = parser.parse_args()
    
    parentdir = os.path.expanduser(os.path.expandvars(args.caseparent))
    casename = args.casename
    somid = args.somid
    
    sys = SOMMemberPlotSystem(parentdir, casename, somid)
    
    try:
        sys.run()
    finally:
        Ngl.end()