Skip to content

Instantly share code, notes, and snippets.

@pukpr
Created November 2, 2023 00:06
Show Gist options
  • Save pukpr/3e1484dd8248623453ccf77723957b55 to your computer and use it in GitHub Desktop.
Save pukpr/3e1484dd8248623453ccf77723957b55 to your computer and use it in GitHub Desktop.
Analytic Tidal Forcing
-- Conventional tidal series summation or superposition of cycles
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
Pi : Long_Float := Ada.Numerics.Pi;
Time : Long_Float;
Res : Data_Pairs := Template;
Yr : Long_Float := Year_Len;
Drac : Long_Float := 2.0*pi*Yr/Draconic;
Trop : Long_Float := 2.0*pi*Yr/Tropical;
Anom : Long_Float := 2.0*pi*Yr/Anomalistic;
Nodal : Long_Float := Drac-Trop;
Peri : Long_Float := (Trop-Anom)/2.0;
K1 : Long_Float := Constituents(1).Value; -- -0.06
K2 : Long_Float := Constituents(2).Value; -- -0.064
TA : Long_Float := Constituents(3).Value; -- 0.144
TP : Long_Float := Constituents(4).Value; -- 0.7
AA : Long_Float := Constituents(5).Value; -- -0.718
AP : Long_Float := Constituents(6).Value; -- -0.62
T2A : Long_Float := Constituents(7).Value; -- 0.16
T2P : Long_Float := Constituents(8).Value; -- 0.29
DSA : Long_Float := Constituents(9).Value; -- 0.001 ----
DSP : Long_Float := Constituents(10).Value; -- -0.0129
A2A : Long_Float := Constituents(11).Value; -- -0.062
SYA : Long_Float := Constituents(12).Value; -- 0.362
SYP : Long_Float := Constituents(13).Value; -- 0.96
EA : Long_Float := Constituents(14).Value; -- 0.284
EP : Long_Float := Constituents(15).Value; -- 4.0
E2A : Long_Float := Constituents(16).Value; -- -0.0227
T2AYA : Long_Float := Constituents(17).Value; -- 0.04 ---
T2AYP : Long_Float := Constituents(18).Value; -- 0
Q1 : Long_Float := Constituents(19).Value; -- -0.01
Q2 : Long_Float := Constituents(20).Value; -- 9.47
DA : Long_Float := Constituents(21).Value; -- -0.087
DP : Long_Float := Constituents(22).Value; -- 0.17
K3 : Long_Float := Constituents(23).Value; -- -0.088
NA : Long_Float := Constituents(24).Value; -- 0.1
NP : Long_Float := Constituents(25).Value; -- 9.6
PA : Long_Float := Constituents(26).Value; -- 0.05
PP : Long_Float := Constituents(27).Value; -- -6
TN2A : Long_Float := Constituents(28).Value; -- 0 ---
TN2P : Long_Float := Constituents(29).Value;
function Ds is new rsin (DA, Drac, DP); -- = A*sin(2*Drac*(x+p));
function Ts is new rsin (TA, Trop, TP); -- = A*sin(2*Trop*(x+p))
function DsB is new gsin (DSA, 2.0*Drac, DSP); -- = A*sin(2*Drac*(x+p));
function TsB is new gsin (TN2A, 2.0*Trop, TN2P); -- = A*sin(2*Trop*(x+p))
function T2s is new gsin (T2AYA, Trop+Drac, T2AYP); -- = A*sin((Trop+Drac)*(x+p))
function As is new gsin (AA, Anom, AP); -- = A*sin(Anom*(x+p))
-- function Semi is new gsin(SA, 4.0*Pi, SP); -- = A*sin(4*pi*(x+p))
function Evect is new gsin(EA, 2.0*Trop-Anom-4.0*Pi, EP); -- = A*sin((2*Trop-Anom-4*pi)*(x+p))
function Syn is new gsin(SYA, 2.0*Trop-4.0*Pi, SYP); -- = A*sin((2*Trop-4*pi)*(x+p))
--function Annual is new gsin(YA, 2.0*Pi, YP); -- = A*cos(2*pi*(x+p))
function N is new gsin (NA, Nodal, NP); -- = A*sin(Nodal*(x+p))
--function N2 is new gsin (N2A, Nodal/2.0, N2P); -- = A*sin(Nodal/2.0*(x+p))
function P is new gsin (PA, Peri, PP); -- = A*sin(Peri*(x+p))
-- # Define the model
function Model (Time : in Long_Float) return Long_Float is
MM : Long_Float := As(Time, 0.0);
Msm : Long_Float := Evect(Time, 0.0);
Mfp : Long_Float := T2s(Time, + A2A*Mm + E2A*Msm);
Mf : Long_Float := Ts(Time, + A2A*Mm + E2A*Msm, T2A) + TsB(Time, + A2A*Mm + E2A*Msm);
Mfd : Long_Float := Ds(Time, + A2A*Mm + E2A*Msm, T2P) + DsB(Time, + A2A*Mm + E2A*Msm);
Msf : Long_Float := Syn(Time, + Q1*(Mf+Mfd+Mfp+Q2*Mf*Mfd)); -- + Q2*Mfp
begin
return Mf + Mfd + Mfp + Q2*Mf*Mfd + Msm + Msf + N(Time, 0.0) + P(Time, 0.0) + -- + Semi(Time) + Annual(Time) + N2(Time)
As(Time, + K1*(Mf+Mfd+Mfp+Q2*Mf*Mfd) + K2*Mm + K3*Msf);
end Model;
begin
for I in Template'Range loop
Time := Template(I).Date - Ref_Time;
declare
TF : Long_Float := 0.0;
begin
Tf := Model (Time);
Res(I) := (Time, Scaling * TF);
end;
end loop;
return Res;
end Tide_Sum;
@pukpr
Copy link
Author

pukpr commented Nov 8, 2023

Darwin

High frequency terms

image

  -0.00000000000 :offset:
  -0.69246368223 :bg:
   0.00000000000 :impA:
   0.00000000000 :impB:
   0.00000000000 :impC:
   0.38001663945:delA:
   0.04731370355:delB:
   0.01335762510:asym:
  -0.09668832108:ann1:
   7.20498742699:ann2:
  -0.04802974486:sem1:
  -4.57721943544:sem2:
  -0.00296162558:year:
   0.07470627164:IR:
   0.00000000000 :mA:
  -0.00111820688 :mP:
   0.00711849828 :shiftT:
  -0.00000000000 :init:
---- Tidal ----
   9.10846048884,   -0.29133661745 1
  29.53065054328,   -1.31032210843 2
  27.09267692660,    0.12354502823 3
   7.08840640006,   -7.32431988355 4
   6.85248390316,   -0.62867991759 5
  13.60611040750,    0.28182442336 6
  13.66083077700,   14.96559309119 7
3396.73824406533,    0.90159198938 8
   9.12068919638,    0.00272599735 9
  13.77727494300,   -0.26164797713 10
6793.47648813065,    0.56466448494 11
  27.55454988600,    3.71540844820 12
  27.66676714572,   -0.02208470761 13
  27.44323926226,   -0.14858488959 14
1616.30271425126,   -1.57442821129 15
   6.85940288609,   -1.99087463366 16
   7.09581026566,   -0.59717712964 17
   9.55688676698,   -3.26482856710 18
   9.13295078376,   -0.11310149039 19
2190.35004466729,  155.86506684999 20
  27.21222081500,   -0.00699824168 21
   9.18484996200,    0.57002423329 22
  14.76532527164,    3.01901246301 23
  31.81208431695,    0.20855108194 24
   9.54346127285,    0.57181436287 25
  13.63341568476,   -0.17997880475 26
  26.98505934729, -180.75392041420 27
 365.24692677442,   -5.32239565171 28
 182.62346338721,    6.83759651910 29
 121.74897559147,    0.78341052594 30
   9.61373090693,    0.60011715314 31
3232.60542850251,  -24.49950513852 32
---- LTE ----
  -0.00623077989 :trend:
   0.00003059982 :accel:
  -0.04797122787 :K0:
  12.37559816241 :level:
   0.14549802539,    0.16996920827,   -0.51593388830 0
   0.80794068918,    0.28417572945,   -0.85695454070 0
   2.14201062918,    0.27911750638,    1.56793945101 0
  -4.86360037923,    0.20988714635,   -0.70110767611 0
  -1.27490407734,    0.26201785016,    1.87916410378 0
   2.94966556009,    0.34100392569,   -1.05858306023 0
  -2.30453059031,    0.47189167868,   -0.17995574136 0
   6.31110671797,    0.32595745399,   -1.72056331158 0
  -3.10073336751,    0.31931373808,    1.87786488577 0
  -4.00948372794,    0.42315526212,   -0.65326874858 0
  -1.44624710607,    0.14818542728,    1.75864704447 0
  -1.78111590751,    0.14051151892,   -0.01120265112 0
-894.28889938506,    0.35121701826,   -3.03327623803 1
-52763.04506371844,    0.25657451209,   -2.77156276127 59

CC   0.8038627136   0.2594480165   5 1
   0.00000000000:dLOD:
PS C:\Users\pp\github\pukpr\GEMa\GeoEnergyMath\eqlong>  ..\io\restore.bat 130_year_cal_amo_harm_nino34_relax_pdo_wow4_amo_try2_relax_pdo_lockt_relax_amo_lockt_relax1_pdo_lockt_relax_extra1_nino34_der_wow1_darwin_pt2_slopeplus2

@pukpr
Copy link
Author

pukpr commented Nov 11, 2023

AMO prediction

image

  -0.33045945085 :offset:
  -0.42132010636 :bg:
   4.15362205615 :impA:
   0.43215012024 :impB:
   0.00000000000 :impC:
   0.37688229113:delA:
   0.04731461377:delB:
   0.02504912914:asym:
  -0.33700267001:ann1:
  -6.47744778804:ann2:
  -0.06766374487:sem1:
   1.96885766471:sem2:
  -0.00296073076:year:
   0.02173436466:IR:
   0.00000000000 :mA:
   0.00114122577 :mP:
   0.00709886446 :shiftT:
  -0.00000000000 :init:
---- Tidal ----
   9.10846048884,   -0.22199719134 1
  29.53065053743,   -1.38416898508 2
  27.09267692660,    0.12408858564 3
   7.08840639938,   -7.37655224426 4
   6.85248390316,   -0.63598735794 5
  13.60611040750,    0.28554936998 6
  13.66083077700,   15.01177338789 7
3396.73824406533,    0.89663899165 8
   9.12068919638,    0.00268711864 9
6793.47648813065,    0.55422371202 11
  27.55454988600,    3.73055466288 12
  27.66676714572,   -0.01900705629 13
  27.44323926226,   -0.14589218893 14
1616.30271425126,   -1.56439453348 15
   6.85940288609,   -1.96844419755 16
   7.09581026499,   -0.65872437487 17
   9.55688676576,   -3.21781733757 18
   9.13295078376,   -0.11171426764 19
2190.35004466729,  156.21082724055 20
  27.21222081500,   -0.00702066091 21
   9.18484996200,    0.56979449476 22
  14.76532526872,    3.02063176673 23
  31.81208430337,    0.20835423705 24
   9.54346127163,    0.55519661295 25
  13.63341568476,   -0.17965634562 26
  26.98505934729, -180.74060942340 27
 365.24692766924,   -5.23844360474 28
 182.62346383462,    6.83906010597 29
 121.74897588975,    0.77912830087 30
   9.61373090569,    0.47395208342 31
3232.60542850251,  -24.40217743847 32
---- LTE ----
  -0.09809491950 :trend:
   0.00081032700 :accel:
   0.41249454859 :K0:
 183.97710821612 :level:
   0.11791321798,    1.40382109203,    0.96170358617 0
   0.25559838787,    0.43602776288,    1.26251943739 0
   1.17966429326,    0.65255029313,    0.59683015838 0
   3.91702339483,    0.44503267930,   -2.43146936168 0
  -1.76746688225,    0.93772874989,   -2.97845658452 0
  -3.00859600132,    0.43182615019,    1.91186462147 0
  -1.59509658896,    0.55959849984,    2.97402045801 0
   2.25841116676,    0.44974467396,    2.83841008218 0
 -17.48606161790,    0.68457757885,   -1.68393916956 0
 -13.37300525839,    0.34019129919,    1.49290501936 0
  -0.66467212242,    0.32121977573,    2.07913328749 0
 876.25080736031,    0.28233355038,   -2.28588387762 1
42936.28956065520,    0.24207216321,    0.38677843531 49
28916.27664289024,    0.30818655567,    2.31786679792 33
12267.51130304434,    0.22391537159,    0.44529406066 14

CC   0.8258724478   0.1926826412   1 1
   0.00000000000:dLOD:
PS C:\Users\pp\github\pukpr\GEMa\GeoEnergyMath\eqlong> ../io/backup 130_year_cal_amo_harm_nino34_relax_pdo_wow4_amo_try2_relax_pdo_lockt_relax_amo_lockt_relax1pt826

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