Esempio n. 1
0
def tidalSuite(model, observed, step, start, type, plot=False,
               save_csv=False, debug=False, debug_plot=False):
    '''
    Create stats classes for a given tidal variable.

    Accepts interpolated model and observed data, the timestep, and start
    time. Type is a string representing the type of data. If plot is set
    to true, a time plot and regression plot will be produced.

    Returns a dictionary containing all the stats.
    '''
    if debug: print "tidalSuite..."
    stats = TidalStats(model, observed, step, start, type=type,
                       debug=debug, debug_plot=debug_plot)
    stats_suite = stats.getStats()
    stats_suite['r_squared'] = stats.linReg()['r_2']
    stats_suite['phase'] = stats.getPhase()

    if plot or debug_plot:
        stats.plotData()
        stats.plotRegression(stats.linReg())

    if save_csv:
        stats.save_data()

    if debug: print "...tidalSuite done."

    return stats_suite
Esempio n. 2
0
def tidalSuite(gear, model, observed, step, start,
               model_u, observed_u, model_v, observed_v,
               model_time, observed_time,
               kind='', plot=False, save_csv=False, save_path='./',
               debug=False, debug_plot=False):
    """
    Create stats classes for a given tidal variable.

    Accepts interpolated model and observed data, the timestep, and start
    time. kind is a string representing the kind of data. If plot is set
    to true, a time plot and regression plot will be produced.

    Returns a dictionary containing all the stats.
    """
    if debug: print "tidalSuite..."
    stats = TidalStats(gear, model, observed, step, start,
                       model_u = model_u, observed_u = observed_u, model_v = model_v, observed_v = observed_v,
                       model_time = model_time, observed_time = observed_time,
                       kind=kind, debug=debug, debug_plot=debug_plot)
    stats_suite = stats.getStats()
    stats_suite['r_squared'] = stats.linReg()['r_2']
    # calling special methods
    if kind == 'direction':
        rmse, nrmse = stats.statsForDirection(debug=debug)
        stats_suite['RMSE'] = rmse
        stats_suite['NRMSE'] = nrmse
    try: #Fix for Drifter's data
        stats_suite['phase'] = stats.getPhase(debug=debug)
    except:
        stats_suite['phase'] = 0.0

    if plot or debug_plot:
        plotData(stats)
        plotRegression(stats, stats.linReg())

    if save_csv:
        stats.save_data(path=save_path)
        plotData(stats, savepath=save_path, fname=kind+"_"+gear+"_time_series.png")
        plotRegression(stats, stats.linReg(), savepath=save_path, fname=kind+"_"+gear+"_linear_regression.png")

    if debug: print "...tidalSuite done."

    return stats_suite
Esempio n. 3
0
def tidalSuite(model,
               observed,
               step,
               start,
               type,
               plot=False,
               save_csv=False,
               debug=False,
               debug_plot=False):
    '''
    Create stats classes for a given tidal variable.

    Accepts interpolated model and observed data, the timestep, and start
    time. Type is a string representing the type of data. If plot is set
    to true, a time plot and regression plot will be produced.
    
    Returns a dictionary containing all the stats.
    '''
    if debug: print "tidalSuite..."
    stats = TidalStats(model,
                       observed,
                       step,
                       start,
                       type=type,
                       debug=debug,
                       debug_plot=debug_plot)
    stats_suite = stats.getStats()
    stats_suite['r_squared'] = stats.linReg()['r_2']
    stats_suite['phase'] = stats.getPhase()

    if plot or debug_plot:
        stats.plotData()
        stats.plotRegression(stats.linReg())

    if save_csv:
        stats.save_data()

    if debug: print "...tidalSuite done."

    return stats_suite
Esempio n. 4
0
def tidalSuite(gear,
               model,
               observed,
               step,
               start,
               model_u,
               observed_u,
               model_v,
               observed_v,
               model_time,
               observed_time,
               kind='',
               plot=False,
               save_csv=False,
               save_path='./',
               debug=False,
               debug_plot=False):
    """
    Create stats classes for a given tidal variable.

    Accepts interpolated model and observed data, the timestep, and start
    time. kind is a string representing the kind of data. If plot is set
    to true, a time plot and regression plot will be produced.

    Returns a dictionary containing all the stats.
    """
    if debug: print "tidalSuite..."
    stats = TidalStats(gear,
                       model,
                       observed,
                       step,
                       start,
                       model_u=model_u,
                       observed_u=observed_u,
                       model_v=model_v,
                       observed_v=observed_v,
                       model_time=model_time,
                       observed_time=observed_time,
                       kind=kind,
                       debug=debug,
                       debug_plot=debug_plot)
    stats_suite = stats.getStats()
    stats_suite['r_squared'] = stats.linReg()['r_2']
    # calling special methods
    if kind == 'direction':
        rmse, nrmse = stats.statsForDirection(debug=debug)
        stats_suite['RMSE'] = rmse
        stats_suite['NRMSE'] = nrmse
    try:  #Fix for Drifter's data
        stats_suite['phase'] = stats.getPhase(debug=debug)
    except:
        stats_suite['phase'] = 0.0

    if plot or debug_plot:
        plotData(stats)
        plotRegression(stats, stats.linReg())

    if save_csv:
        stats.save_data(path=save_path)
        plotData(stats,
                 savepath=save_path,
                 fname=kind + "_" + gear + "_time_series.png")
        plotRegression(stats,
                       stats.linReg(),
                       savepath=save_path,
                       fname=kind + "_" + gear + "_linear_regression.png")

    if debug: print "...tidalSuite done."

    return stats_suite