Skip to content

Instantly share code, notes, and snippets.

@pukpr
Created May 28, 2024 12:17
Show Gist options
  • Save pukpr/2326fba3f5061ed2a8cec58b43db8308 to your computer and use it in GitHub Desktop.
Save pukpr/2326fba3f5061ed2a8cec58b43db8308 to your computer and use it in GitHub Desktop.
Simple multiplicative Tidal factor
-- Conventional tidal series summation or superposition of cycles
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;
Cumulative : Long_Float := 0.0;
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 + 3 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 + 4 .. 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;
Cumulative := Cumulative + cos(Scaling + TF1);
Res(I) := (Time, cos(Scaling + TF1)*(Integ + TF2) );
end;
end loop;
Cumulative := Cumulative/Long_Float(Template'Length);
for I in Template'Range loop
Res(I).Value := Res(I).Value - Cumulative*Integ;
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
--Res2,
Res1 : 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;
@pukpr
Copy link
Author

pukpr commented Jul 8, 2024

QBO

image

  -0.00000000000 :offset:
   0.00000000000 :bg:
  -0.09409837054 :impA:
 -20.87444476543 :impB:
 -85.07058458260 :impC:
  -0.87837055349:delA:
   0.36500000000:delB:
   0.74481804826:asym:
  -0.04963903635:ann1:
   1.89447805742:ann2:
  -0.02849161838:sem1:
  20.12174109245:sem2:
  -0.00231642390:year:
  -0.00407395177:IR:
   0.00507340616 :mA:
  -0.01592984598 :mP:
  -0.32346154288 :shiftT:
  -0.02891018512 :init:
---- Tidal ----
  27.32166155400,   -0.09600559637,   -0.01763515489,  1, -48799,  1.97141362358840E-04
  27.21222081500,   -1.75091405094,    2.95697494095,  2, -131888,  1.32857891933721E-03
1095.17502233364,   -0.03640400064,   -1.48308284052,  3, -32953,  1.10807095297658E-04
 346.61411888846,   -0.01520027431,    2.69758702125,  4, -2350,  6.75480455428567E-04
 173.30705944423,    0.06223914995,   -2.56839727821,  5,  5504,  1.11069772217238E-03
  13.63341568476,    0.03499516161,   -2.03467095279,  6, -73,  1.27519237842966E-01
  13.66083077700,    0.17582989482,   23.47296342113,  7, -44,  3.15871834215700E-01
  13.60611040750,    0.04320567223,    0.21004803974,  8,  351,  9.58576256141684E-03
  27.55454988600,   -0.05821053221,   -1.53179434785,  9, -168,  8.56270429060868E-02
  13.77727494300,    0.00000000000,    0.11133501891,  10, -100,  1.33923946433446E-02
  27.10365333842,    0.25782232602,   -0.06666814475,  11,  11663,  2.19180972938905E-03
-411.77602506657,    0.01035837411,  -57.06978954640,  12,  4935,  2.05741286843882E-04
  27.09267692660,   -0.19146439713,   -3.23599040980,  13, -6245,  3.11602478779971E-03
-205.88801253329,   -0.01916099014,   -1.36423636535,  14, -2883,  6.88512067061880E-04
  13.69115772864,    0.04513664837,   22.52786391849,  15,  1400,  3.00966440226341E-03
   9.10846048884,    0.02121385760,   -1.74167406476,  16,  634,  2.89185464561847E-03
  27.44323926226,    0.02610594196,   -1.23650596949,  17,  470,  4.57605339746949E-03
  27.66676714572,    0.03339433934,   -2.19144989791,  18,  362,  7.23427343095432E-03
2190.35004466729,    0.07558770960,   -6.45277620379,  19,  13664,  5.49170263678697E-04
  26.87829334283,   -0.16288970950,    3.90753748751,  20, -20082,  8.15198513893674E-04
---- LTE ----
   0.00000000000 :trend:
   0.00000000000 :accel:
   0.25473595304 :K0:
  -0.18590491816 :level:
  -0.73653222958,    0.28829702379,    0.03247957524 1

CC 0.9112808632 0.4519173125 7 1
PS C:\Users\pp\scratch\anom\run> ..\backup qbo_30_kit_1960_1980oneB

C:\Users\pp\scratch\anom\run>copy enso_opt.exe.par enso_opt.exe.par.qbo_30_kit_1960_1980oneB

image

50
image

Catchup mode enabled:TRUE

  -0.00000000000 :offset:
   0.00000000000 :bg:
  -0.10790160331 :impA:
 -21.32339934561 :impB:
  23.12824074346 :impC:
  -0.95224931857:delA:
   0.36500000000:delB:
   0.85142703877:asym:
  -0.05515422005:ann1:
   1.33747943784:ann2:
  -0.02426196313:sem1:
  17.46479258389:sem2:
  -0.00244857984:year:
  -0.00405876629:IR:
  -0.01673714371 :mA:
   0.01349810708 :mP:
  -0.34323108063 :shiftT:
  -0.03885832180 :init:
---- Tidal ----
  27.32166155400,   -0.14674126948,    0.00669046138,  1, -74535,  1.97141362358840E-04
  27.21222081500,   -1.53855486998,    2.01414115923,  2, -115905,  1.32857891933721E-03
1095.17502233364,   -0.05512079638,   -0.41803192944,  3, -49845,  1.10807095297658E-04
 346.61399987411,   -0.02491475930,    0.88069571398,  4, -3788,  6.75480455428567E-04
 173.30699993705,    0.14606076187,   -2.66804821557,  5,  13050,  1.11069772217238E-03
  13.63341568476,   -0.02618661971,   -2.95299973766,  6, -121,  1.27519237842966E-01
  13.66083077700,    0.12862976246,   23.70108387573,  7, -59,  3.15871834215700E-01
  13.60611040750,    0.06452846491,    0.16856592008,  8,  573,  9.58576256141684E-03
  27.55454988600,   -0.08126367100,   -2.48015156818,  9, -195,  8.56270429060868E-02
  13.77727494300,    0.00000000000,    0.11133330692,  10, -100,  1.33923946433446E-02
  27.10365333842,   -0.25453986809,    0.17621846176,  11, -11713,  2.19180972938905E-03
-411.77585709766,    0.02227056301,   53.11983590653,  12,  10725,  2.05741286843882E-04
  27.09267692660,    0.26358145090,   -1.61488260056,  13,  8359,  3.11602478779971E-03
-205.88792854883,    0.11438723214,    0.28128105007,  14,  16514,  6.88512067061880E-04
  13.69115772864,    0.02998449875,   19.20200773882,  15,  896,  3.00966440226341E-03
   9.10846048884,    0.07800709537,   -2.49116096418,  16,  2597,  2.89185464561847E-03
  27.44323926226,    0.03907604542,   -1.84889861710,  17,  754,  4.57605339746949E-03
  27.66676714572,   -0.04195644051,   -2.67065357175,  18, -680,  7.23427343095432E-03
2190.35004466729,    0.07552893203,    4.35168671522,  19,  13653,  5.49170263678697E-04
  26.87829334283,   -0.28182001826,    3.82623213377,  20, -34671,  8.15198513893674E-04
---- LTE ----
   0.00000000000 :trend:
   0.00000000000 :accel:
   0.24350190565 :K0:
   0.02871471559 :level:
   0.74241461378,    0.29844980276,    2.44193608852 1

CC 0.9241659569 0.4393720874 3 1
PS C:\Users\pp\scratch\anom\run> ..\backup qbo_30_kit_1960_1980oneB-50b

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