def detide_u(t,u,gaugeno,component):
    
    """
    Detide one of the components *u*  or *v*.

    :Input:
     - *t*, *u* arrays of data
     - *gaugeno* (int) gauge number, e.g. 1107
     - *component* (str) is 'u' or 'v'
    """

    j = ((t>=-20) & (t<=28))
    t1 = t[j]
    u1 = u[j]

    u1_poly_fit = TG.fit_tide_poly(t1,u1,15)

    j = find((t>=0) & (t<=25))
    t2 = t1[j]
    u2 = u1[j]
    u2_poly_fit = u1_poly_fit[j]

    p = {k:TG.periods[k] for k in TG.constituents_hawaii}
    print "Using only constituents %s" % p.keys()

    u1_harmonic_fit, u1_offset, u1_amplitude, u1_phase= \
            TG.fit_tide_harmonic(t1, u1, periods=p, t0=0, svd_tol=1e-5)
    u2_harmonic_fit = u1_harmonic_fit[j]


    if component=='u':
        plt.figure(310,figsize=(10,10))
    else:
        plt.figure(311,figsize=(10,10))
    plt.clf()
    plt.subplot(211)
    plt.plot(t,u,'k',label='Observations')
    plt.plot(t1,u1_harmonic_fit,'b',label='Harmonic fit')
    plt.plot(t1,u1_poly_fit,'r',label='Polynomial fit')
    plt.title('%s-component of velocity at HAI%s' % (component,gaugeno))
    plt.legend()
    plt.subplot(212)
    plt.plot(t2,u2 - u2_harmonic_fit,'b',label='Residual: harmonic fit')
    plt.plot(t2,u2 - u2_poly_fit,'r',label='Residual: polynomial fit')
    plt.xlim(7,14)
    plt.legend()
    return t2, u2-u2_harmonic_fit, u2-u2_poly_fit
Example #2
0
def detide_u(t, u, gaugeno, component):
    """
    Detide one of the components *u*  or *v*.

    :Input:
     - *t*, *u* arrays of data
     - *gaugeno* (int) gauge number, e.g. 1107
     - *component* (str) is 'u' or 'v'
    """

    j = ((t >= -20) & (t <= 28))
    t1 = t[j]
    u1 = u[j]

    u1_poly_fit = TG.fit_tide_poly(t1, u1, 15)

    j = find((t >= 0) & (t <= 25))
    t2 = t1[j]
    u2 = u1[j]
    u2_poly_fit = u1_poly_fit[j]

    p = {k: TG.periods[k] for k in TG.constituents_hawaii}
    print "Using only constituents %s" % p.keys()

    u1_harmonic_fit, u1_offset, u1_amplitude, u1_phase= \
            TG.fit_tide_harmonic(t1, u1, periods=p, t0=0, svd_tol=1e-5)
    u2_harmonic_fit = u1_harmonic_fit[j]

    if component == 'u':
        plt.figure(310, figsize=(10, 10))
    else:
        plt.figure(311, figsize=(10, 10))
    plt.clf()
    plt.subplot(211)
    plt.plot(t, u, 'k', label='Observations')
    plt.plot(t1, u1_harmonic_fit, 'b', label='Harmonic fit')
    plt.plot(t1, u1_poly_fit, 'r', label='Polynomial fit')
    plt.title('%s-component of velocity at HAI%s' % (component, gaugeno))
    plt.legend()
    plt.subplot(212)
    plt.plot(t2, u2 - u2_harmonic_fit, 'b', label='Residual: harmonic fit')
    plt.plot(t2, u2 - u2_poly_fit, 'r', label='Residual: polynomial fit')
    plt.xlim(7, 14)
    plt.legend()
    return t2, u2 - u2_harmonic_fit, u2 - u2_poly_fit
def detide_and_plot(t,u,gaugeno,component,axes):
    """
    Detide one of the components *u*  or *v*.

    :Input:
     - *t*, *u* arrays of data
     - *gaugeno* (int) gauge number, e.g. 1107
     - *component* (str) is 'u' or 'v'
    """

    j = ((t>=-20) & (t<=28))
    t1 = t[j]
    u1 = u[j]

    u1_poly_fit = TG.fit_tide_poly(t1,u1,15)

    j = find((t>=0) & (t<=25))
    t2 = t1[j]
    u2 = u1[j]
    u2_poly_fit = u1_poly_fit[j]

    p = {k:TG.periods[k] for k in TG.constituents_hawaii}
    print "Using only constituents %s" % p.keys()

    u1_harmonic_fit, u1_offset, u1_amplitude, u1_phase= \
            TG.fit_tide_harmonic(t1, u1, periods=p, t0=0, svd_tol=1e-5)
    u2_harmonic_fit = u1_harmonic_fit[j]


    axes.plot(t,u,'k',label='Observations (depth-averaged)')
    axes.plot(t1,u1_harmonic_fit,'b',label='Harmonic fit to tide')
    axes.plot(t1,u1_poly_fit,'r',label='Polynomial fit to tide')
    if component=='u':
        axes.set_title('u (east-west velocity) at HAI%s' % gaugeno)
    else:
        axes.set_title('v (north-south velocity) at HAI%s' % gaugeno)
        axes.legend(loc='lower left')
        plt.xlabel("Hours post-quake")
    plt.ylabel("Speed in cm/sec")
    return t2, u2-u2_harmonic_fit, u2-u2_poly_fit
Example #4
0
def detide_and_plot(t, u, gaugeno, component, axes):
    """
    Detide one of the components *u*  or *v*.

    :Input:
     - *t*, *u* arrays of data
     - *gaugeno* (int) gauge number, e.g. 1107
     - *component* (str) is 'u' or 'v'
    """

    j = ((t >= -20) & (t <= 28))
    t1 = t[j]
    u1 = u[j]

    u1_poly_fit = TG.fit_tide_poly(t1, u1, 15)

    j = find((t >= 0) & (t <= 25))
    t2 = t1[j]
    u2 = u1[j]
    u2_poly_fit = u1_poly_fit[j]

    p = {k: TG.periods[k] for k in TG.constituents_hawaii}
    print "Using only constituents %s" % p.keys()

    u1_harmonic_fit, u1_offset, u1_amplitude, u1_phase= \
            TG.fit_tide_harmonic(t1, u1, periods=p, t0=0, svd_tol=1e-5)
    u2_harmonic_fit = u1_harmonic_fit[j]

    axes.plot(t, u, 'k', label='Observations (depth-averaged)')
    axes.plot(t1, u1_harmonic_fit, 'b', label='Harmonic fit to tide')
    axes.plot(t1, u1_poly_fit, 'r', label='Polynomial fit to tide')
    if component == 'u':
        axes.set_title('u (east-west velocity) at HAI%s' % gaugeno)
    else:
        axes.set_title('v (north-south velocity) at HAI%s' % gaugeno)
        axes.legend(loc='lower left')
        plt.xlabel("Hours post-quake")
    plt.ylabel("Speed in cm/sec")
    return t2, u2 - u2_harmonic_fit, u2 - u2_poly_fit