def mooring_1dvar(file_in):
    """Standard EcoFOCI Mooring .nc files with one dimensional parameters as a function of time
    such as temperature at a particular level
    Timestep of data is assumed to be in fractions of a day"""
    #dir_path = os.path.dirname(os.path.abspath(__file__))
    ncfile = file_in

    ###nc readin/out
    nchandle = ncutil.ncopen(ncfile)
    params = constants.nc_vars_moor()
    ncdata = ncutil.ncreadfile(nchandle, params)
    ncutil.ncclose(nchandle)

    ###data massaging
    #time_all = ncdata[:,0] + ncdata[:,1]
    xx = ncutil.nc_missing(ncdata[:, 9], flag=1e35, setfill='Zero')
    pytime = util.EPICdate2udunits(ncdata[:, 0], ncdata[:, 1])

    dt = 1. / pytime['interval_min']  #data is 4 times daily
    time_base = 'days'
    time = pytime['timeint']
    #time = util.subsample(time, int(pytime.get('interval_min')) / 4)

    variance = np.var(xx)
    #normalize
    print 'Variance = %s ' % (variance)
    x = (xx - np.mean(xx)) / np.sqrt(variance)
    variance = np.var(x)

    return (xx, x, dt, np.array(time), variance, time_base)
def mooring_1dvar(file_in):
    """ TODO: make file choice and var choice more transparent"""

    #dir_path = os.path.dirname(os.path.abspath(__file__))    
    ncfile = file_in
    
    ###nc readin/out
    nchandle = ncutil.ncopen(ncfile)
    params = constants.nc_vars_moor()
    ncdata = ncutil.ncreadfile(nchandle, params)
    ncutil.ncclose(nchandle)

    ###data massaging
    #time_all = ncdata[:,0] + ncdata[:,1]
    xx = ncutil.nc_missing(ncdata[:,9], flag=1e35, setfill='Zero')
    pytime = util.EPICdate2udunits(ncdata[:,0], ncdata[:,1])
    

    dt = 1. / pytime['interval_min'] #data is 4 times daily
    time_base = 'days'
    time = pytime['timeint']
    #time = util.subsample(time, int(pytime.get('interval_min')) / 4)

    variance = np.var(xx)
    #normalize
    print 'Variance = %s ' % (variance)
    x = (xx - np.mean(xx)) / np.sqrt(variance)
    variance = np.var(x)

    return (xx, x,dt,np.array(time), variance, time_base)  
def mooring_1dvar(file_in):
    """Standard EcoFOCI Mooring .nc files with one dimensional parameters as a function of time
    such as temperature at a particular level
    Timestep of data is assumed to be in fractions of a day"""
    #dir_path = os.path.dirname(os.path.abspath(__file__))    
    ncfile = file_in
    
    ###nc readin/out
    nchandle = ncutil.ncopen(ncfile)
    params = constants.nc_vars_moor()
    ncdata = ncutil.ncreadfile(nchandle, params)
    ncutil.ncclose(nchandle)

    ###data massaging
    #time_all = ncdata[:,0] + ncdata[:,1]
    xx = ncutil.nc_missing(ncdata[:,9], flag=1e35, setfill='Zero')
    pytime = util.EPICdate2udunits(ncdata[:,0], ncdata[:,1])
    

    dt = 1. / pytime['interval_min'] #data is 4 times daily
    time_base = 'days'
    time = pytime['timeint']
    #time = util.subsample(time, int(pytime.get('interval_min')) / 4)

    variance = np.var(xx)
    #normalize
    print 'Variance = %s ' % (variance)
    x = (xx - np.mean(xx)) / np.sqrt(variance)
    variance = np.var(x)

    return (xx, x,dt,np.array(time), variance, time_base)  
def mooring_1dvar(file_in):
    """ TODO: make file choice and var choice more transparent"""

    #dir_path = os.path.dirname(os.path.abspath(__file__))
    ncfile = file_in

    ###nc readin/out
    nchandle = ncutil.ncopen(ncfile)
    params = constants.nc_vars_moor()
    ncdata = ncutil.ncreadfile(nchandle, params)
    ncutil.ncclose(nchandle)

    ###data massaging
    #time_all = ncdata[:,0] + ncdata[:,1]
    xx = ncutil.nc_missing(ncdata[:, 9], flag=1e35, setfill='Zero')
    pytime = util.EPICdate2udunits(ncdata[:, 0], ncdata[:, 1])

    dt = 1. / pytime['interval_min']  #data is 4 times daily
    time_base = 'days'
    time = pytime['timeint']
    #time = util.subsample(time, int(pytime.get('interval_min')) / 4)

    variance = np.var(xx)
    #normalize
    print 'Variance = %s ' % (variance)
    x = (xx - np.mean(xx)) / np.sqrt(variance)
    variance = np.var(x)

    return (xx, x, dt, np.array(time), variance, time_base)