ttide_py icon indicating copy to clipboard operation
ttide_py copied to clipboard

Example constructed elevation not matching original

Open LaurieWilkinson opened this issue 5 years ago • 1 comments

Hi,

I have tried the example from the docstring with the 'real' data, i.e.

import ttide as tt import numpy as np

t = np.arange(1001) m2_freq = 2 * np.pi / 12.42 elev = 5 * np.cos(m2_freq * t) tfit_e = tt.t_tide(elev) elev_fit = tfit_e(t)

When comparing the original elevation, 'elev', to the reconstructed one, 'elev_fit', the phases and frequencies are different, as shown in the figure below. Shouldn't these be the same or am I missing something?

Figure_1

LaurieWilkinson avatar Jan 14 '20 09:01 LaurieWilkinson

The synthesis that should match "elev" is in tfit_e['xout']

The mismatch with the synthesis from calling the TTideCon object is due to the time vector that you're providing doesn't match the time vector constructed within t_tide:

import ttide as tt import numpy as np

N=1000 t = np.arange(N+1) m2_freq = 2 * np.pi * 0.0805114 elev = 5 * np.cos(m2_freq * t) tfit_e = tt.t_tide(elev) elev_fit = tfit_e( (t-N/2)/24)

print("Err1:", np.max(np.abs(elev - elev_fit))) print("Err2:", np.max(np.abs(elev - tfit_e['xout'][:,0])))

Gives me:

Err1: 1.0786432503656629e-05 Err2: 1.0786432503656629e-05

mdunphy avatar Jun 22 '20 21:06 mdunphy