示例#1
0
def predict_tide(t, hc, constituents, DELTAT=0.0, CORRECTIONS='OTIS'):
    """
    Predict tides at a single time using harmonic constants

    Parameters
    ----------
    t: float
        days relative to 1992-01-01T00:00:00
    hc: complex
        harmonic constant vector
    constituents: list
        tidal constituent IDs
    DELTAT: float, default 0.0
        time correction for converting to Ephemeris Time (days)
    CORRECTIONS: str, default 'OTIS'
        use nodal corrections from OTIS/ATLAS or GOT models

    Returns
    -------
    ht: float
        tide values reconstructed using the nodal corrections

    References
    ----------
    .. [1] Egbert and Erofeeva, "Efficient Inverse Modeling of Barotropic
        Ocean Tides", Journal of Atmospheric and Oceanic Technology, (2002).
    """

    #-- number of points and number of constituents
    npts, nc = np.shape(hc)
    #-- load the nodal corrections
    #-- convert time to Modified Julian Days (MJD)
    pu, pf, G = load_nodal_corrections(t + 48622.0,
                                       constituents,
                                       DELTAT=DELTAT,
                                       CORRECTIONS=CORRECTIONS)
    #-- allocate for output tidal elevation
    ht = np.ma.zeros((npts))
    ht.mask = np.zeros((npts), dtype=bool)
    #-- for each constituent
    for k, c in enumerate(constituents):
        if CORRECTIONS in ('OTIS', 'ATLAS', 'netcdf'):
            #-- load parameters for each constituent
            amp, ph, omega, alpha, species = load_constituent(c)
            #-- add component for constituent to output tidal elevation
            th = omega * t * 86400.0 + ph + pu[0, k]
        elif CORRECTIONS in ('GOT', 'FES'):
            th = G[0, k] * np.pi / 180.0 + pu[0, k]
        #-- sum over all tides
        ht.data[:] += pf[0,k]*hc.real[:,k]*np.cos(th) - \
            pf[0,k]*hc.imag[:,k]*np.sin(th)
        ht.mask[:] |= (hc.real.mask[:, k] | hc.imag.mask[:, k])
    #-- return the tidal elevation after removing singleton dimensions
    return np.squeeze(ht)
示例#2
0
def predict_tide(t, hc, constituents, DELTAT=0.0, CORRECTIONS='OTIS'):
    """
    Predict tides at a single time using harmonic constants

    Arguments
    ---------
    t: days relative to 1992-01-01T00:00:00
    hc: harmonic constant vector (complex)
    constituents: tidal constituent IDs

    Keyword arguments
    -----------------
    DELTAT: time correction for converting to Ephemeris Time (days)
    CORRECTIONS: use nodal corrections from OTIS/ATLAS or GOT models

    Returns
    -------
    ht: tide values reconstructed using the nodal corrections
    """

    #-- number of points and number of constituents
    npts, nc = np.shape(hc)
    #-- load the nodal corrections
    #-- convert time to Modified Julian Days (MJD)
    pu, pf, G = load_nodal_corrections(t + 48622.0,
                                       constituents,
                                       DELTAT=DELTAT,
                                       CORRECTIONS=CORRECTIONS)
    #-- allocate for output tidal elevation
    ht = np.ma.zeros((npts))
    ht.mask = np.zeros((npts), dtype=np.bool)
    #-- for each constituent
    for k, c in enumerate(constituents):
        if CORRECTIONS in ('OTIS', 'ATLAS', 'netcdf'):
            #-- load parameters for each constituent
            amp, ph, omega, alpha, species = load_constituent(c)
            #-- add component for constituent to output tidal elevation
            th = omega * t * 86400.0 + ph + pu[0, k]
        elif CORRECTIONS in ('GOT', 'FES'):
            th = G[0, k] * np.pi / 180.0 + pu[0, k]
        #-- sum over all tides
        ht.data[:] += pf[0,k]*hc.real[:,k]*np.cos(th) - \
            pf[0,k]*hc.imag[:,k]*np.sin(th)
        ht.mask[:] |= (hc.real.mask[:, k] | hc.imag.mask[:, k])
    #-- return the tidal elevation after removing singleton dimensions
    return np.squeeze(ht)
示例#3
0
def predict_tidal_ts(time,hc,constituents,DELTAT=0.0,CORRECTIONS='OTIS'):
	nt = len(time)
	#-- load the nodal corrections
	pu,pf,G = load_nodal_corrections(time + 48622.0, constituents,
		DELTAT=DELTAT, CORRECTIONS=CORRECTIONS)
	#-- allocate for output time series
	ht = np.zeros((nt))
	#-- for each constituent
	for k,c in enumerate(constituents):
		if CORRECTIONS in ('OTIS','ATLAS','netcdf'):
			#-- load parameters for each constituent
			amp,ph,omega,alpha,species = load_constituent(c)
			#-- add component for constituent to output tidal time series
			th = omega*time*86400.0 + ph + pu[:,k]
		elif (CORRECTIONS == 'GOT'):
			th = G[:,k]*np.pi/180.0 + pu[:,k]
		#-- sum over all tides at location
		ht += pf[:,k]*hc.real[0,k]*np.cos(th) - pf[:,k]*hc.imag[0,k]*np.sin(th)
	#-- return the tidal time series
	return ht