Skip to content
dankelley edited this page Feb 12, 2012 · 16 revisions

The problem

tidem() produces slightly different results from those produced by t-tide (matlab) or as in Foreman's Fortran code. (See https://github.com/dankelley/oce/issues/170 for the linked issue.) FIXED

Resolution

As indicate below, the code now produces identical results (apart from differences in the last digits, probably owing to the rounding algorithm).

Matlab results (Tuktoyaktuk example; t_tide_v1)

NOTE: this test differs from the t_demo, in not requesting inference of certain extra constituents.

>> t_demo_dek
       echo on
       % Load the example.
       load t_example
      
       % The call (see t_demo code for details).
       [tidestruc,pout]=t_tide(tuk_elev,...
       'interval',1, ...                     % hourly data
       'start',tuk_time(1),...               % start time is datestr(tuk_time(1))
       'latitude',69+27/60,...               % Latitude of obs
       'error','linear',...                   % coloured boostrap CI
       'synthesis',1);                       % Use SNR=1 for synthesis. 
   number of standard constituents used: 35
   Points used: 1510 of 1584
   percent of var residual after lsqfit/var original: 74.18 %
   Greenwich phase computed with nodal corrections applied to amplitude 
 and phase relative to center time
   Using linearized error estimates
   Generating prediction with nodal corrections, SNR is 1.000000
   percent of var residual after synthesis/var original: 78.48 %
-----------------------------------
date: 12-Feb-2012
nobs = 1584,  ngood = 1510,  record length (days) = 66.00
start time: 06-Jul-1975 01:00:00
rayleigh criterion = 1.0
Greenwich phase computed with nodal corrections applied to amplitude \n and phase relative to center time

x0= 1.98, x trend= 0

var(x)= 0.82196   var(xp)= 0.17847   var(xres)= 0.64505
percent var predicted/var original= 21.7 %

     tidal amplitude and phase with 95% CI estimates

tide   freq       amp     amp_err    pha    pha_err     snr
 MM   0.0015122    0.2121    0.520   263.34   140.36     0.17
 MSF  0.0028219    0.1561    0.520   133.79   190.80     0.09
 ALP1 0.0343966    0.0152    0.035   334.96   143.55     0.19
 2Q1  0.0357064    0.0246    0.035    82.69    89.79     0.48
 Q1   0.0372185    0.0158    0.035    65.74   140.52      0.2
*O1   0.0387307    0.0764    0.035    74.23    29.21      4.7
 NO1  0.0402686    0.0290    0.035   238.14    53.30     0.67
*K1   0.0417807    0.1347    0.035    81.09    15.88       14
 J1   0.0432929    0.0253    0.035     7.32    86.65     0.51
*OO1  0.0448308    0.0531    0.035   235.75    43.75      2.3
 UPS1 0.0463430    0.0298    0.035    91.73    87.12     0.71
 EPS2 0.0761773    0.0211    0.025   184.60    66.90      0.7
*MU2  0.0776895    0.0419    0.025    83.23    33.80      2.8
*N2   0.0789992    0.0838    0.025    44.52    16.86       11
*M2   0.0805114    0.4904    0.025    77.70     2.89  3.8e+02
 L2   0.0820236    0.0213    0.025    35.21    82.99     0.71
*S2   0.0833333    0.2202    0.025   137.48     6.57       76
 ETA2 0.0850736    0.0071    0.025   246.04   244.75     0.08
*MO3  0.1192421    0.0148    0.010   234.97    40.64      2.3
*M3   0.1207671    0.0123    0.010   261.57    44.24      1.6
 MK3  0.1222921    0.0049    0.010   331.60   117.60     0.25
 SK3  0.1251141    0.0023    0.010   237.67   252.65    0.057
*MN4  0.1595106    0.0092    0.009   256.47    52.75      1.1
*M4   0.1610228    0.0126    0.009   291.79    38.58        2
 SN4  0.1623326    0.0083    0.009   270.86    59.59     0.89
 MS4  0.1638447    0.0010    0.009   339.36   479.51    0.014
 S4   0.1666667    0.0047    0.009   299.56   108.18     0.28
 2MK5 0.2028035    0.0013    0.005   310.16   214.21    0.073
 2SK5 0.2084474    0.0045    0.005   104.00    62.57     0.94
 2MN6 0.2400221    0.0035    0.007   271.22   101.52     0.28
 M6   0.2415342    0.0017    0.007   158.87   207.35    0.067
 2MS6 0.2443561    0.0056    0.007   306.12    65.12     0.71
 2SM6 0.2471781    0.0023    0.007   298.91   165.20     0.12
*3MK7 0.2833149    0.0086    0.004   212.25    29.48      3.7
 M8   0.3220456    0.0030    0.003    42.38    56.79     0.86

tidem() results

> library(oce)
> data(sealevelTuktoyaktuk)
> #source('~/src/R-kelley/oce/R/tidem.R')
> m <- tidem(sealevelTuktoyaktuk)#, latitude=69+27/60)
> summary(m)
tidem summary
-------------

Call:
tidem(x = sealevelTuktoyaktuk)

Start time:  1975-07-06 01:00:00 UTC 
RMS misfit to data:  0.7808454 

Fitted model:
        Freq Amplitude  Phase       p    
Z0   0.00000   1.98062   0.00 < 2e-16 ***
MM   0.00151   0.21213 263.34  0.0056 ** 
MSF  0.00282   0.15606 133.80  0.0070 ** 
ALP1 0.03440   0.01523 334.96  0.7421    
2Q1  0.03571   0.02458  82.69  0.6791    
Q1   0.03722   0.01579  65.74  0.7681    
O1   0.03873   0.07641  74.23  0.1050    
NO1  0.04027   0.02903 238.14  0.3703    
K1   0.04178   0.13474  81.09  0.0767 .  
J1   0.04329   0.02530   7.32  0.5844    
OO1  0.04483   0.05310 235.75  0.2785    
UPS1 0.04634   0.02980  91.73  0.6617    
EPS2 0.07618   0.02115 184.60  0.7260    
MU2  0.07769   0.04189  83.23  0.4790    
N2   0.07900   0.08377  44.52  0.1966    
M2   0.08051   0.49041  77.70 7.4e-05 ***
L2   0.08202   0.02132  35.21  0.6934    
S2   0.08333   0.22024 137.48 3.2e-05 ***
ETA2 0.08507   0.00713 246.04  0.8878    
MO3  0.11924   0.01484 234.97  0.7517    
M3   0.12077   0.01226 261.57  0.8090    
MK3  0.12229   0.00492 331.60  0.9353    
SK3  0.12511   0.00234 237.67  0.9618    
MN4  0.15951   0.00917 256.47  0.8191    
M4   0.16102   0.01257 291.79  0.7779    
SN4  0.16233   0.00830 270.86  0.8396    
MS4  0.16384   0.00103 339.36  0.9802    
S4   0.16667   0.00468 299.56  0.9365    
2MK5 0.20280   0.00127 310.16  0.9774    
2SK5 0.20845   0.00455 104.00  0.9298    
2MN6 0.24002   0.00353 271.22  0.9312    
M6   0.24153   0.00173 158.87  0.9672    
2MS6 0.24436   0.00564 306.12  0.8989    
2SM6 0.24718   0.00227 298.91  0.9676    
3MK7 0.28331   0.00857 212.25  0.8383    
M8   0.32205   0.00304  42.38  0.9364    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 
* Processing Log::
  * 2012-02-12 16:28:39.602 UTC: ``create 'tidem' object``
  * 2012-02-12 16:28:39.604 UTC: ``tidem(x = sealevelTuktoyaktuk)``
> 
> 

Foreman results

Note that he is doing inference, etc., so the results cannot be compared with the tidem() results, or the t-tide results that mimic them.

Appendix 7.3 Final Analysis Results Arising from the Input Data of Appendix 7.2
and the Standard Constituent Data Package of Appendix 7.1.
ANALYSIS OF HOURLY TIDAL HEIGHTS STN 6485 16H 6/ 7/75 TO 14H 9/ 9/75
NO.OBS.= 1559 NO.PTS.ANAL.= 1559 MIDPT= 3H 8/ 8/75 SEPARATION =1.00
NO NAME FREQUENCY STN M-Y/ M-Y A G AL GL
1 Z0 0.00000000 6485 775/ 975 1.9806 0.00 1.9806 0.00
2 MM 0.00151215 6485 775/ 975 0.2121 263.34 0.2121 288.50
3 MSF 0.00282193 6485 775/ 975 0.1561 133.80 0.1561 115.15
4 ALP1 0.03439657 6485 775/ 975 0.0152 334.95 0.0141 180.96
5 2Q1 0.03570635 6485 775/ 975 0.0246 82.69 0.0226 246.82
6 Q1 0.03721850 6485 775/ 975 0.0158 65.74 0.0144 252.75
7 O1 0.03873065 6485 775/ 975 0.0764 74.23 0.0694 284.43
8 NO1 0.04026859 6485 775/ 975 0.0290 238.14 0.0380 275.85
9 P1 0.04155259 6485 775/ 975 0.0465 71.76 INF FR K1 0.0468 252.20
10 K1 0.04178075 6485 775/ 975 0.1406 64.69 0.1332 145.54
11 J1 0.04329290 6485 775/ 975 0.0253 7.32 0.0234 103.63
12 OO1 0.04483084 6485 775/ 975 0.0531 235.74 0.0463 358.47
13 UPS1 0.04634299 6485 775/ 975 0.0298 91.73 0.0233 239.12
14 EPS2 0.07617731 6485 775/ 975 0.0211 184.59 0.0216 109.98
15 MU2 0.07768947 6485 775/ 975 0.0419 83.23 0.0428 30.06
16 N2 0.07899925 6485 775/ 975 0.0838 44.52 0.0857 306.35
17 M2 0.08051140 6485 775/ 975 0.4904 77.70 0.5007 4.40
18 L2 0.08202355 6485 775/ 975 0.0213 35.21 0.0174 168.03
19 S2 0.08333334 6485 775/ 975 0.2195 126.65 0.2193 36.74
20 K2 0.08356149 6485 775/ 975 0.0597 149.05 INF FR S2 0.0515 131.15
21 ETA2 0.08507364 6485 775/ 975 0.0071 246.05 0.0059 235.38
22 MO3 0.11924206 6485 775/ 975 0.0148 234.97 0.0138 11.86
23 M3 0.12076710 6485 775/ 975 0.0123 261.57 0.0126 331.91
24 MK3 0.12229215 6485 775/ 975 0.0049 331.60 0.0048 339.15
25 SK3 0.12511408 6485 775/ 975 0.0023 237.69 0.0022 228.64
26 MN4 0.15951066 6485 775/ 975 0.0092 256.47 0.0096 85.00
27 M4 0.16102280 6485 775/ 975 0.0126 291.78 0.0131 145.17
28 SN4 0.16233259 6485 775/ 975 0.0083 270.85 0.0085 82.78
29 MS4 0.16384473 6485 775/ 975 0.0010 339.35 0.0011 176.14
30 S4 0.16666667 6485 775/ 975 0.0047 299.56 0.0047 119.75
31 2MK5 0.20280355 6485 775/ 975 0.0013 310.10 0.0013 244.34
32 2SK5 0.20844743 6485 775/ 975 0.0045 104.00 0.0043 5.04
33 2MN6 0.24002205 6485 775/ 975 0.0035 271.24 0.0038 26.46
34 M6 0.24153420 6485 775/ 975 0.0017 158.89 0.0018 298.97
35 2MS6 0.24435614 6485 775/ 975 0.0056 306.10 0.0059 69.59
36 2SM6 0.24717808 6485 775/ 975 0.0023 298.92 0.0023 45.80
37 3MK7 0.28331494 6485 775/ 975 0.0086 212.25 0.0086 73.20
38 M8 0.32204559 6485 775/ 975 0.0030 42.43 0.0033 109.22
39 M10 0.40255699 6485 775/ 975 0.0009 198.23 0.0010 191.71