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 Jun 16, 2024

NINO4

image

Status: 4 2 0.68421 0.53629 # 1820

   0.00000000000 :offset:
   0.00005937545 :bg:
  -0.06091824845 :impA:
  -6.33626708030 :impC:
  -0.05486688115:delA:
   0.46957103552:delB:
   0.03518769242:asym:
  -0.07450214559:ann1:
   2.82260305466:ann2:
   0.10110990263:sem1:
  -0.95149943424:sem2:
  -0.00000932623:year:
  -0.00000000000:IR:
  -0.17923576796 :mA:
  -0.00347336967 :mP:
   0.08114354412 :shiftT:
  -0.03549419222 :init:
---- Tidal ----
  27.32166155400,   -0.02451516609,   -0.44952183269,  1, -13979,  1.76628953531850E-04
  27.21222081500,   -0.71932745213,   14.27682051930,  2, -54575,  1.32047425097857E-03
  27.10365333842,    0.00106879739,    4.33973872656,  3, -53,  2.26569924321020E-03
6793.47648813065,   -0.15898285092,    4.05136660932,  4, -20202,  7.90867249242066E-04
3396.73824406533,   -0.40249302293,    0.91293245037,  5, -41030,  9.83370612492222E-04
  27.55454988600,   -1.40062659315,    6.23101412628,  6, -1736,  8.56289947134097E-02
  13.77727494300,   -0.05209763236,   -0.24398330548,  7, -491,  1.33274573071050E-02
   9.18484996200,    0.01089369664,   -0.74357594475,  8,  370,  2.31918283471700E-03
  13.63341568476,    0.01337820325,   -0.69630075021,  9, -90,  1.27448455896301E-01
3232.60542850251,    0.78734049546,   -2.87799934100,  10,  77572,  1.01366789012042E-03
  27.09267692660,   -0.14957406230,   21.84358138185,  11, -4934,  3.09392634878083E-03
  13.66083077700,   -0.00597517306,   11.69200670096,  12, -102,  3.15777097820916E-01
1616.30271425126,   -1.45186201374,    3.82398812675,  13, -877075,  1.65553462995255E-04
  13.60611040750,    2.19527301891,   -6.07176358225,  14,  22585,  9.67714118545784E-03
  27.44323926226,    0.00710409363,   -1.58366542712,  15,  55,  4.57977530236714E-03
  27.66676714572,    0.67970985082,    1.42284170210,  16,  9303,  7.22901067260159E-03
---- LTE ----
   0.00114335941 :trend:
   0.00001444546 :accel:
   2.04963492805 :K0:
  -2.38501971665 :level:
  10.13014167260,    0.14093342985,   -2.68782245753 1
   8.70885909097,    0.19080091157,    2.57732811406 1
  17.41771818193,    0.15210927684,   -1.71738633166 2
  34.83543636386,    0.08837788514,    0.92451360074 4
  43.54429545483,    0.11439583254,    1.82119862072 5
 548.65812273085,    0.10567904987,   -2.11629355603 63
  78.37973181869,    0.06373011599,    0.55512144068 9
3779.64484547916,    0.06666911563,    2.91619025091 434
3048.10068183803,    0.10942056257,   -0.68244712570 350

DTW 0.5363075264 0.6842148598 4 1
PS C:\Users\pp\scratch\na\run> ..\backup bi_nino4_adrac_1_wow_pt79_1920_1980excl-1870drac_flat2_modulation1Harm5dtw

NINO34

image

@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