pynemo_exe.py 1.73 KB
Newer Older
James Harle's avatar
James Harle committed
1 2 3 4 5 6 7
'''
Entry for the project

@author: Mr. Srikanth Nagella
'''

import sys, getopt
James Harle's avatar
2to3  
James Harle committed
8
from . import profile
James Harle's avatar
James Harle committed
9 10 11 12 13 14 15 16 17 18 19 20
import logging

# Logging set to info
logging.basicConfig(level=logging.INFO)
import time
def main():
    """ Main function which checks the command line parameters and
        passes them to the profile module for processing """

    setup_file = ''
    mask_gui = False
    try:
21
        opts, dummy_args = getopt.getopt(sys.argv[1:], "hs:d:g", ["help", "setup=", "download_cmems=", "mask_gui"])
James Harle's avatar
James Harle committed
22
    except getopt.GetoptError:
thopri's avatar
thopri committed
23
        print("usage: pynemo -g -s -d <namelist.bdy> ")
James Harle's avatar
James Harle committed
24 25 26 27
        sys.exit(2)

    for opt, arg in opts:
        if opt == "-h":
thopri's avatar
thopri committed
28
            print("usage: pynemo [-g] -s -d <namelist.bdy> ")
James Harle's avatar
2to3  
James Harle committed
29 30
            print("       -g (optional) will open settings editor before extracting the data")
            print("       -s <bdy filename> file to use")
thopri's avatar
thopri committed
31
            print("       -d (optional) will download CMEMS data using provided bdy file")
James Harle's avatar
James Harle committed
32 33 34
            sys.exit()
        elif opt in ("-s", "--setup"):
            setup_file = arg
thopri's avatar
thopri committed
35
        elif opt in ("-g", "--mask_gui"):
James Harle's avatar
James Harle committed
36
            mask_gui = True
thopri's avatar
thopri committed
37 38 39 40 41 42 43
        elif opt in ("-d", "--download_cmems"):
            setup_file = arg
            t0 = time.time()
            profile.download_cmems(setup_file)
            t1 = time.time()
            print("CMEMS download time: %s" % (t1 - t0))
            sys.exit(0)
44

James Harle's avatar
James Harle committed
45
    if setup_file == "":
James Harle's avatar
2to3  
James Harle committed
46
        print("usage: pynemo [-g] -s <namelist.bdy> ")
James Harle's avatar
James Harle committed
47 48 49 50 51 52 53
        sys.exit(2)

    #Logger
    #logger = logging.getLogger(__name__)
    t0 = time.time()
    profile.process_bdy(setup_file, mask_gui)
    t1 = time.time()
James Harle's avatar
2to3  
James Harle committed
54
    print("Execution Time: %s" % (t1-t0))
James Harle's avatar
James Harle committed
55 56 57
    
if __name__ == "__main__":
    main()