<p>My recommendation is that you check the tidal prediction code provided with t_tide (t_predic). In there, you will find a piece of code like this:</p>
<p><code>ap=tidecon(:,1)/2.*exp(-i*tidecon(:,3)*pi/180);  am=conj(ap);</code></p>
<p>You can check that you are doing that part correctly up to there.</p>
<p>The other important part is the astronomical nodal modulation correction. That is the difference in phase for your specific location. The code for that is given in t_vuf.</p>

CC BY-SA 4.0
2022-12-27T18:54:06.210Z
2022-12-27T18:54:06.210Z
arkaia
<p>I am trying to reconstruct the astronomical tide time series from harmonic constituents (calculated from T_Tide).I am using the equation that all knows H(t) = Amplitude * cos ( t * harmonicSpeed + phase lag), I wrote my script in python. The output is not matching with the tide predicction (from the T_Tide file). As you know the construction is very simple but I am thinking that my problem is about the sampling interval, I really don´t know how to interpret it for this case, I wrote 1/24 due to the input time (for calculating in T_TIDE , hourly data), I am not sure about this.</p>
<p>I share the harmonic constants file  from T_Tide and the tide predicction values file (hourly , which I want to reproduce). They are <a href="https://github.com/feraxel/Harmonic-constans/commit/fb11b9ef9909b03e722978ccfa102fc7b9fd1f01#diff-09639ac17104196efd895598afe1af5234cbb5bcac39070e4a3d9133c611a4ea" rel="nofollow noreferrer">https://github.com/feraxel/Harmonic-constans/commit/fb11b9ef9909b03e722978ccfa102fc7b9fd1f01#diff-09639ac17104196efd895598afe1af5234cbb5bcac39070e4a3d9133c611a4ea</a>    and  <a href="https://github.com/feraxel/Harmonic-constans/commit/1e46d1d416c49ef131005d8fa68775f9169c0270#diff-545b5ec39a1b72b56fa5e37c33afb30a3c3c39ba0e6fe1d583b4a1d77e9fc74a" rel="nofollow noreferrer">https://github.com/feraxel/Harmonic-constans/commit/1e46d1d416c49ef131005d8fa68775f9169c0270#diff-545b5ec39a1b72b56fa5e37c33afb30a3c3c39ba0e6fe1d583b4a1d77e9fc74a</a></p>
<blockquote>
<pre><code>os.chdir(r'directory') # change the file.txt directory
con =  pd.read_csv('harmonics_aca.txt',sep=' ') # We load the harmonic constants
</code></pre>
<h5>We create a datetime vector for concatenate to the constructed tide</h5>
<pre><code>date = pd.date_range(start='01/02/2018 22:00:00', end='05/30/2022 15:00:00',freq='H') 
datetime = pd.DataFrame({'Fecha':date})

tide = 0 
H = [] # This vector save the tide for the t time 
dt = 1/24 #####Sampling interval 
for t in np.arange(0,len(fecha)*dt,dt):
    Am = con.iloc[i,2] # Harmonic constituent amplitude
    Ph = np.deg2rad(con.iloc[i,4]) # Harmonic constituent phase
    Fr = (con.iloc[i,1]*2*np.pi)  # Frecuency (1/Hours)*2*pi
    level = Am*np.cos(Fr*t - Ph)
    tide = tide+level

H.append(tide)
tide = 0
</code></pre>
</blockquote>

<oceanography><ocean-currents><tides>
How to construct the tide signal from harmonic constituents?
Miguel 
# How to construct the tide signal from harmonic constituents?

(Asked by: username_0 on 2022-12-27)

I am trying to reconstruct the astronomical tide time series from harmonic constituents (calculated from T\_Tide).I am using the equation that all knows H(t) = Amplitude \* cos ( t \* harmonicSpeed + phase lag), I wrote my script in python. The output is not matching with the tide predicction (from the T\_Tide file). As you know the construction is very simple but I am thinking that my problem is about the sampling interval, I really don´t know how to interpret it for this case, I wrote 1/24 due to the input time (for calculating in T\_TIDE , hourly data), I am not sure about this.

I share the harmonic constants file from T\_Tide and the tide predicction values file (hourly , which I want to reproduce). They are <https://github.com/feraxel/Harmonic-constans/commit/fb11b9ef9909b03e722978ccfa102fc7b9fd1f01#diff-09639ac17104196efd895598afe1af5234cbb5bcac39070e4a3d9133c611a4ea> and <https://github.com/feraxel/Harmonic-constans/commit/1e46d1d416c49ef131005d8fa68775f9169c0270#diff-545b5ec39a1b72b56fa5e37c33afb30a3c3c39ba0e6fe1d583b4a1d77e9fc74a>

> ```
> os.chdir(r'directory') # change the file.txt directory
> con =  pd.read_csv('harmonics_aca.txt',sep=' ') # We load the harmonic constants
>
> ```
>
> ##### We create a datetime vector for concatenate to the constructed tide
>
> ```
> date = pd.date_range(start='01/02/2018 22:00:00', end='05/30/2022 15:00:00',freq='H') 
> datetime = pd.DataFrame({'Fecha':date})
>
> tide = 0 
> H = [] # This vector save the tide for the t time 
> dt = 1/24 #####Sampling interval 
> for t in np.arange(0,len(fecha)*dt,dt):
>     Am = con.iloc[i,2] # Harmonic constituent amplitude
>     Ph = np.deg2rad(con.iloc[i,4]) # Harmonic constituent phase
>     Fr = (con.iloc[i,1]*2*np.pi)  # Frecuency (1/Hours)*2*pi
>     level = Am*np.cos(Fr*t - Ph)
>     tide = tide+level
>
> H.append(tide)
> tide = 0
>
> ```

**Tags:** oceanography, ocean-currents, tides


---

## 1 answers

### Answer by username_1 on 2022-12-27. Score: 1 | Accepted answer

My recommendation is that you check the tidal prediction code provided with t\_tide (t\_predic). In there, you will find a piece of code like this:

`ap=tidecon(:,1)/2.*exp(-i*tidecon(:,3)*pi/180); am=conj(ap);`

You can check that you are doing that part correctly up to there.

The other important part is the astronomical nodal modulation correction. That is the difference in phase for your specific location. The code for that is given in t\_vuf.


---

