Beispiel #1
0
def plotdata_run(plotplan,
                 filetable1,
                 filetable2,
                 varname,
                 seasonname,
                 outputPath,
                 unique_ID,
                 aux=None,
                 newgrid=0):
    """Inputs:
    plotplan is a plot_plan class to be instantiated
    filetable1 is the model data file table
    fileteable2 is the obs or reference model data file table
    varname is a string representing the variable to be plotted
    seasonname is a string representing the season for climatology to be presented
    aux is an auxiliary option, if any

    This function will spawn another process and return it as p, an instance of
    multiprocessing.Process.  This p will create a plotplan object and run its compute() method.
    To check the status of p, call plotdata_status(p) to get a semaphore value (>0 means done).
    To get the computed value, call plotdata_results(p).
    """
    #logging.basicConfig(filename="diags.log",level=logging.INFO)
    #log = logging.getLogger("diags")
    sema = Semaphore()
    #log.info("initial sema=%s"%sema)
    parent_conn, child_conn = Pipe()
    p = Process(target=_plotdata_run,
                args=(child_conn, sema, plotplan, filetable1, filetable2,
                      varname, seasonname, outputPath, unique_ID, aux,
                      newgrid))
    #log.info("initial p=%s"%(p))
    #outfile=_plotdata_run(plotplan, filetable1, filetable2, varname, seasonname, outputPath,
    #                      unique_ID, aux, newgrid)
    #print outfile
    """
    p = Process( target=_plotdata_run,
                 args=( plotplan, filetable1, filetable2, varname, seasonname, outputPath,
                        unique_ID, aux, newgrid ) )
    """
    p.start()
    p.sema = sema
    #pid = p.pid
    #p.join()
    p.parent_conn = parent_conn
    return p
Beispiel #2
0
def plotdata_run( plotspec, filetable1, filetable2, varname, seasonname, outputPath, unique_ID, aux=None, newgrid=0 ):
    """Inputs:
    plotspec is a plot_spec class to be instantiated
    filetable1 is the model data file table
    fileteable2 is the obs or reference model data file table
    varname is a string representing the variable to be plotted
    seasonname is a string representing the season for climatology to be presented
    aux is an auxiliary option, if any

    This function will spawn another process and return it as p, an instance of
    multiprocessing.Process.  This p will create a plotspec object and run its compute() method.
    To check the status of p, call plotdata_status(p) to get a semaphore value (>0 means done).
    To get the computed value, call plotdata_results(p).
    """
    #logging.basicConfig(filename="diags.log",level=logging.INFO)
    #log = logging.getLogger("diags")
    sema = Semaphore()
    #log.info("initial sema=%s"%sema)
    parent_conn, child_conn = Pipe()
    p = Process( target=_plotdata_run,
                 args=(child_conn, sema,
                       plotspec, filetable1, filetable2, varname, seasonname, outputPath,
                       unique_ID, aux, newgrid ) )
    #log.info("initial p=%s"%(p))
    #outfile=_plotdata_run(plotspec, filetable1, filetable2, varname, seasonname, outputPath,
    #                      unique_ID, aux, newgrid)
    #print outfile
    """
    p = Process( target=_plotdata_run,
                 args=( plotspec, filetable1, filetable2, varname, seasonname, outputPath,
                        unique_ID, aux, newgrid ) )
    """
    p.start()
    p.sema = sema
    #pid = p.pid
    #p.join()
    p.parent_conn = parent_conn
    return p