Skip to content

Instantly share code, notes, and snippets.

@pukpr
Last active May 22, 2024 13:53
Show Gist options
  • Save pukpr/239a25ebe81082c6a14107861b7b9af3 to your computer and use it in GitHub Desktop.
Save pukpr/239a25ebe81082c6a14107861b7b9af3 to your computer and use it in GitHub Desktop.
Declination times perigee factors tidal summation
-- Conventional tidal series summation or superposition of cycles
-- Declination times perigee factors
function Tide_Sum_Diff (Template : in Data_Pairs;
Constituents : in Long_Periods_Amp_Phase;
Periods : in Long_Periods;
Ref_Time : in Long_Float := 0.0;
Scaling : in Long_Float := 1.0;
Cos_Phase : in Boolean := True;
Year_Len : in Long_Float := Year_Length;
Integ: in Long_Float := 0.0
) return Data_Pairs is
Pi : Long_Float := Ada.Numerics.Pi;
Time : Long_Float;
Res : Data_Pairs := Template;
begin
for I in Template'Range loop
Time := Template(I).Date + Ref_Time;
declare
TF1, TF2 : Long_Float := 0.0;
use Ada.Numerics.Long_Elementary_Functions;
begin
for J in Constituents'First .. Constituents'First + 8 loop
declare
L : Amp_Phase renames Constituents(J);
Period : Long_Float := Periods(J);
begin
if Cos_Phase then
TF1 := TF1 + L.Amplitude*(Cos(2.0*Pi*Year_Len/Period*Time + L.Phase));
else
TF1 := TF1 + L.Amplitude*(Sin(2.0*Pi*Year_Len/Period*Time + L.Phase));
end if;
end;
end loop;
for J in Constituents'First + 9 .. Constituents'Last loop
declare
L : Amp_Phase renames Constituents(J);
Period : Long_Float := Periods(J);
begin
if Cos_Phase then
TF2 := TF2 + L.Amplitude*(Cos(2.0*Pi*Year_Len/Period*Time + L.Phase));
else
TF2 := TF2 + L.Amplitude*(Sin(2.0*Pi*Year_Len/Period*Time + L.Phase));
end if;
end;
end loop;
Res(I) := (Time, (Scaling + TF1)*(Integ + TF2));
end;
end loop;
return Res;
end Tide_Sum_Diff;
function Tide_Sum (Template : in Data_Pairs;
Constituents : in Long_Periods_Amp_Phase;
Periods : in Long_Periods;
Ref_Time : in Long_Float := 0.0;
Scaling : in Long_Float := 1.0;
Cos_Phase : in Boolean := True;
Year_Len : in Long_Float := Year_Length;
Integ: in Long_Float := 0.0
) return Data_Pairs is
Res1, Res2 : Data_Pairs := Template;
begin
Res1 := Tide_Sum_Diff (Template, Constituents, Periods, 0.0, Scaling, Cos_Phase, Year_Len, Integ);
Res2 := Tide_Sum_Diff (Template, Constituents, Periods, Ref_Time, Scaling, Cos_Phase, Year_Len, Integ);
for I in Res1'Range loop
Res1(I).Value := Res1(I).Value - Res2(I).Value;
end loop;
return Res1;
end Tide_Sum;
-- see https://geoenergymath.com/2024/04/29/fundy-mental-continued
@pukpr
Copy link
Author

pukpr commented May 22, 2024

PDO

image

  10.69166905808 :offset:
  -9.10646580709 :bg:
   0.84054666135 :impA:
  -0.21792506012 :impB:
  -1.59733950503 :impC:
  -0.46979656241:delA:
   0.24508596064:delB:
  -0.00000013621:asym:
   0.36310591121:ann1:
  -2.30586880837:ann2:
   0.23067632591:sem1:
  -1.10447177422:sem2:
  -0.00165871705:year:
  -0.35701183884:IR:
  -0.00135243795 :mA:
   0.00135223259 :mP:
  -0.10029998930 :shiftT:
   0.61953937812 :init:
---- Tidal ----
  27.32166155400,    0.01790117102,    5.18972247203,  1,  3538,  4.92043575392418E-04
  27.21222081500,   -0.04465096858,    0.90316327437,  2, -2821,  1.64073093446322E-03
  27.10365333842,    0.04413019984,    5.85091189360,  3,  1442,  2.86165535307149E-03
  13.66083077700,   -0.55961827568,   -2.30356454067,  4, -277,  3.15919149301349E-01
  13.60611040750,   -0.07258264809,    4.51564127160,  5, -827,  9.98077709582378E-03
  13.63341568476,   -0.04171344447,  -11.57444605568,  6, -133,  1.28178306799966E-01
  13.55182666921,   -0.00551318194,    4.77208771049,  7, -489,  1.41740263913067E-03
  13.57891428673,    0.00226423169,    1.88634250009,  8,  75,  1.29555306345175E-03
  26.99594871373,   -0.04579446901,   -3.63281786635,  9, -2106,  2.28268787185689E-03
  27.55454988600,    0.07716556468,   -0.33795415662,  10, -10,  8.57620038125863E-02
  13.77727494300,    0.11373640109,    3.43966597829,  11,  748,  1.34109849025151E-02
  13.71880577217,    0.00255117017,    7.71097937611,  12,  374,  5.38051824950004E-04
  27.09267692660,   -0.04544282608,   -2.93052133698,  13, -2100,  2.27221694417265E-03
---- LTE ----
   0.00000000000 :trend:
   0.00000000000 :accel:
  -0.03143584272 :K0:
  -0.09380226994 :level:
   0.74303296929,    0.39148327933,    1.83776108693 0
   0.32323483006,    0.29741904143,   -0.73143342642 0
   3.03711939005,    0.37643879015,    0.30235420306 0
   6.94848088794,    0.41441873819,    2.80152227276 0
  -0.57322922453,    0.30398138322,    2.83171285964 0
   3.90833379254,    0.76705191438,    2.41426305064 0
 739.51774728029,    0.82716022439,    1.26312992094 1
13311.31945104524,    0.45861932501,   -2.41577570658 18

DTW 0.7712390670 0.3920946649 7 1
PS C:\Users\pp\scratch\drac\run> ..\backup tropAMO_ENSO_forcing_scaled1_pdo_trial2cc1d_2harm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment