#!/Users/fries2/bin/uvcdat/cdatgui/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
import vcs
import cdms2

# Generated by CDATGUI

# If you want your script to run in the GUI, please only change the bodies
# of the functions below. The comment in """ """ will let you know what goes
# in the function, and what it is expected to return.


def get_files():
    """
    Returns all the files used in the visualizations in this project
    """
    file_0 = cdms2.open("file://%s/clt.nc" % vcs.sample_data)
    return file_0


def get_variables(files):
    """
    Retrieves each of the variables desired from the files in `get_files()`

    Feel free to modify the variables to whatever extent you desire; you'll
    be able to modify them further in the GUI once it loads.
    """
    var_0 = files[0](u'clt')
    var_0.id = 'clt'
    var_1 = files[0](u'u')
    var_1.id = 'u'
    var_2 = files[0](u'v')
    var_2.id = 'v'
    return var_0, var_1, var_2


def get_graphics_methods():
    """
    Retrieve and customize all graphics methods used in the visualization
    """
    gm_0 = vcs.createisofill()
    return gm_0


def get_templates():
    """
    Retrieve and customize all templates used in the visualization
    """
    tmpl_0 = vcs.createtemplate()
    tmpl_0.ytic1.x2 = 0.075
    tmpl_0.ytic1.line = 'std'
    tmpl_0.ytic1.x1 = 0.0705
    tmpl_0.ytic2.x2 = 0.5295
    tmpl_0.ytic2.line = 'std'
    tmpl_0.ytic2.x1 = 0.525
    tmpl_0.logicalmask.priority = 0
    tmpl_0.dataname.priority = 0
    tmpl_0.xunits.priority = 0
    tmpl_0.data.x1 = 0.075
    tmpl_0.data.x2 = 0.525
    tmpl_0.data.y1 = 0.707061
    tmpl_0.data.y2 = 0.932061
    tmpl_0.ymintic2.priority = 0
    tmpl_0.xlabel2.priority = 0
    tmpl_0.box2.priority = 0
    tmpl_0.comment2.priority = 0
    tmpl_0.function.priority = 0
    tmpl_0.xtic2.y1 = 0.932061
    tmpl_0.xtic2.line = 'std'
    tmpl_0.xtic2.y2 = 0.938361
    tmpl_0.crtime.priority = 0
    tmpl_0.zname.priority = 0
    tmpl_0.units.priority = 0
    tmpl_0.box4.priority = 0
    tmpl_0.box3.priority = 0
    tmpl_0.xmintic1.priority = 0
    tmpl_0.xmintic2.priority = 0
    tmpl_0.zvalue.priority = 0
    tmpl_0.transformation.priority = 0
    tmpl_0.yvalue.priority = 0
    tmpl_0.mean.priority = 0
    tmpl_0.ymintic1.priority = 0
    tmpl_0.xtic1.y1 = 0.699861
    tmpl_0.xtic1.line = 'std'
    tmpl_0.xtic1.y2 = 0.707061
    tmpl_0.xlabel1.textorientation = 'center10'
    tmpl_0.xlabel1.y = 0.697
    tmpl_0.xlabel1.texttable = 'font3'
    tmpl_0.box1.x1 = 0.075
    tmpl_0.box1.x2 = 0.525
    tmpl_0.box1.y1 = 0.707061
    tmpl_0.box1.line = 'std'
    tmpl_0.box1.y2 = 0.932061
    tmpl_0.zunits.priority = 0
    tmpl_0.file.priority = 0
    tmpl_0.tunits.priority = 0
    tmpl_0.line4.priority = 0
    tmpl_0.line3.priority = 0
    tmpl_0.line2.priority = 0
    tmpl_0.line1.priority = 0
    tmpl_0.max.priority = 0
    tmpl_0.tname.priority = 0
    tmpl_0.xname.priority = 0
    tmpl_0.xvalue.priority = 0
    tmpl_0.crdate.priority = 0
    tmpl_0.tvalue.priority = 0
    tmpl_0.ylabel1.textorientation = 'right10'
    tmpl_0.ylabel1.x = 0.068
    tmpl_0.ylabel1.texttable = 'font3'
    tmpl_0.yname.priority = 0
    tmpl_0.ylabel2.priority = 0
    tmpl_0.yunits.priority = 0
    tmpl_0.comment4.priority = 0
    tmpl_0.min.priority = 0
    tmpl_0.comment1.textorientation = 'center20'
    tmpl_0.comment1.y = 0.970061
    tmpl_0.comment1.x = 0.30242
    tmpl_0.comment1.texttable = 'font3'
    tmpl_0.comment3.priority = 0
    tmpl_0.title.textorientation = 'left15'
    tmpl_0.title.y = 0.809506
    tmpl_0.title.x = 0.552
    tmpl_0.title.texttable = 'font3'
    tmpl_0.legend.y1 = 0.66
    tmpl_0.legend.y2 = 0.675
    tmpl_0.legend.line = 'std'
    tmpl_0.legend.textorientation = 'center10'
    tmpl_0.legend.x2 = 0.525
    tmpl_0.legend.texttable = 'font3'
    tmpl_0.legend.x1 = 0.075

    tmpl_1 = vcs.createtemplate()
    tmpl_1.ytic1.x2 = 0.075
    tmpl_1.ytic1.line = 'std'
    tmpl_1.ytic1.x1 = 0.0705
    tmpl_1.ytic2.x2 = 0.5295
    tmpl_1.ytic2.line = 'std'
    tmpl_1.ytic2.x1 = 0.525
    tmpl_1.logicalmask.priority = 0
    tmpl_1.dataname.priority = 0
    tmpl_1.xunits.priority = 0
    tmpl_1.data.x1 = 0.075
    tmpl_1.data.x2 = 0.525
    tmpl_1.data.y1 = 0.3915
    tmpl_1.data.y2 = 0.6165
    tmpl_1.ymintic2.priority = 0
    tmpl_1.xlabel2.priority = 0
    tmpl_1.box2.priority = 0
    tmpl_1.comment2.priority = 0
    tmpl_1.function.priority = 0
    tmpl_1.xtic2.y1 = 0.6165
    tmpl_1.xtic2.line = 'std'
    tmpl_1.xtic2.y2 = 0.6228
    tmpl_1.crtime.priority = 0
    tmpl_1.zname.priority = 0
    tmpl_1.units.priority = 0
    tmpl_1.box4.priority = 0
    tmpl_1.box3.priority = 0
    tmpl_1.xmintic1.priority = 0
    tmpl_1.xmintic2.priority = 0
    tmpl_1.zvalue.priority = 0
    tmpl_1.transformation.priority = 0
    tmpl_1.yvalue.priority = 0
    tmpl_1.mean.priority = 0
    tmpl_1.ymintic1.priority = 0
    tmpl_1.xtic1.y1 = 0.3843
    tmpl_1.xtic1.line = 'std'
    tmpl_1.xtic1.y2 = 0.3915
    tmpl_1.xlabel1.textorientation = 'center10'
    tmpl_1.xlabel1.y = 0.382
    tmpl_1.xlabel1.texttable = 'font3'
    tmpl_1.box1.x1 = 0.075
    tmpl_1.box1.x2 = 0.525
    tmpl_1.box1.y1 = 0.3915
    tmpl_1.box1.line = 'std'
    tmpl_1.box1.y2 = 0.6165
    tmpl_1.zunits.priority = 0
    tmpl_1.file.priority = 0
    tmpl_1.tunits.priority = 0
    tmpl_1.line4.priority = 0
    tmpl_1.line3.priority = 0
    tmpl_1.line2.priority = 0
    tmpl_1.line1.priority = 0
    tmpl_1.max.priority = 0
    tmpl_1.tname.priority = 0
    tmpl_1.xname.priority = 0
    tmpl_1.xvalue.priority = 0
    tmpl_1.crdate.priority = 0
    tmpl_1.tvalue.priority = 0
    tmpl_1.ylabel1.textorientation = 'right10'
    tmpl_1.ylabel1.x = 0.068
    tmpl_1.ylabel1.texttable = 'font3'
    tmpl_1.yname.priority = 0
    tmpl_1.ylabel2.priority = 0
    tmpl_1.yunits.priority = 0
    tmpl_1.comment4.priority = 0
    tmpl_1.min.priority = 0
    tmpl_1.comment1.priority = 0
    tmpl_1.comment3.priority = 0
    tmpl_1.title.textorientation = 'left15'
    tmpl_1.title.y = 0.494445
    tmpl_1.title.x = 0.552
    tmpl_1.title.texttable = 'font3'
    tmpl_1.legend.y1 = 0.341909
    tmpl_1.legend.y2 = 0.358555
    tmpl_1.legend.line = 'std'
    tmpl_1.legend.textorientation = 'center10'
    tmpl_1.legend.x2 = 0.523449
    tmpl_1.legend.texttable = 'font3'
    tmpl_1.legend.x1 = 0.0726107

    tmpl_2 = vcs.createtemplate()
    tmpl_2.ytic1.x2 = 0.075
    tmpl_2.ytic1.line = 'std'
    tmpl_2.ytic1.x1 = 0.0705
    tmpl_2.ytic2.x2 = 0.5295
    tmpl_2.ytic2.line = 'std'
    tmpl_2.ytic2.x1 = 0.525
    tmpl_2.logicalmask.priority = 0
    tmpl_2.dataname.priority = 0
    tmpl_2.xunits.priority = 0
    tmpl_2.data.x1 = 0.075
    tmpl_2.data.x2 = 0.525
    tmpl_2.data.y1 = 0.0685
    tmpl_2.data.y2 = 0.2935
    tmpl_2.ymintic2.priority = 0
    tmpl_2.xlabel2.priority = 0
    tmpl_2.box2.priority = 0
    tmpl_2.comment2.priority = 0
    tmpl_2.function.priority = 0
    tmpl_2.xtic2.y1 = 0.2935
    tmpl_2.xtic2.line = 'std'
    tmpl_2.xtic2.y2 = 0.2998
    tmpl_2.crtime.priority = 0
    tmpl_2.zname.priority = 0
    tmpl_2.units.priority = 0
    tmpl_2.box4.priority = 0
    tmpl_2.box3.priority = 0
    tmpl_2.xmintic1.priority = 0
    tmpl_2.xmintic2.priority = 0
    tmpl_2.zvalue.priority = 0
    tmpl_2.transformation.priority = 0
    tmpl_2.yvalue.priority = 0
    tmpl_2.mean.priority = 0
    tmpl_2.ymintic1.priority = 0
    tmpl_2.xtic1.y1 = 0.0622
    tmpl_2.xtic1.line = 'std'
    tmpl_2.xtic1.y2 = 0.0682
    tmpl_2.xlabel1.textorientation = 'center10'
    tmpl_2.xlabel1.y = 0.06
    tmpl_2.xlabel1.texttable = 'font3'
    tmpl_2.box1.x1 = 0.075
    tmpl_2.box1.x2 = 0.525
    tmpl_2.box1.y1 = 0.0685
    tmpl_2.box1.line = 'std'
    tmpl_2.box1.y2 = 0.2935
    tmpl_2.zunits.priority = 0
    tmpl_2.file.priority = 0
    tmpl_2.tunits.priority = 0
    tmpl_2.line4.priority = 0
    tmpl_2.line3.priority = 0
    tmpl_2.line2.priority = 0
    tmpl_2.line1.priority = 0
    tmpl_2.max.priority = 0
    tmpl_2.tname.priority = 0
    tmpl_2.xname.priority = 0
    tmpl_2.xvalue.priority = 0
    tmpl_2.crdate.priority = 0
    tmpl_2.tvalue.priority = 0
    tmpl_2.ylabel1.textorientation = 'right10'
    tmpl_2.ylabel1.x = 0.068
    tmpl_2.ylabel1.texttable = 'font3'
    tmpl_2.yname.priority = 0
    tmpl_2.ylabel2.priority = 0
    tmpl_2.yunits.priority = 0
    tmpl_2.comment4.priority = 0
    tmpl_2.min.priority = 0
    tmpl_2.comment1.priority = 0
    tmpl_2.comment3.priority = 0
    tmpl_2.title.textorientation = 'left15'
    tmpl_2.title.y = 0.169792
    tmpl_2.title.x = 0.552
    tmpl_2.title.texttable = 'font3'
    tmpl_2.legend.y1 = 0.025
    tmpl_2.legend.y2 = 0.04
    tmpl_2.legend.line = 'std'
    tmpl_2.legend.textorientation = 'center10'
    tmpl_2.legend.x2 = 0.525
    tmpl_2.legend.texttable = 'font3'
    tmpl_2.legend.x1 = 0.075
    return tmpl_0, tmpl_1, tmpl_2


def get_number_of_canvases():
    """
    Returns the number of canvases used in the visualizations

    Canvases will be left to right, then wrap onto the next row.
    """
    return 1


def get_rows_cols():
    """
    Return the row and column counts
    """
    return 1, 1


def plot(canvases, variables, graphics_methods, templates):
    """
    Plots each of the plots onto the desired canvases
    """
    canvases[0].plot(variables['clt'], templates[0], graphics_methods[0])
    canvases[0].plot(variables['u'], templates[1], graphics_methods[0])
    canvases[0].plot(variables['v'], templates[2], graphics_methods[0])

if __name__ == "__main__":
    canvases = [vcs.init() for canvas in range(get_number_of_canvases())]
    files = get_files()
    files = [files] if type(files) not in (tuple, list) else files
    variables = get_variables(files)
    # Converts the variables into a dictionary
    variables = {var.id: var for var in variables}
    gms = get_graphics_methods()
    gms = [gms] if type(gms) not in (tuple, list) else gms
    tmpls = get_templates()
    tmpls = [tmpls] if type(tmpls) not in (tuple, list) else tmpls
    plot(canvases, variables, gms, tmpls)
    from IPython import embed
    def interact():
        canvases[0].interact()
    print "To interact with your plots, type `interact()` and hit enter."
    embed()
