Skip to content

Instantly share code, notes, and snippets.

@pukpr
Created June 15, 2023 03:05
Show Gist options
  • Save pukpr/91241973cb825abd663484a884c8a2d8 to your computer and use it in GitHub Desktop.
Save pukpr/91241973cb825abd663484a884c8a2d8 to your computer and use it in GitHub Desktop.
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;
K2 : Long_Float := Constituents(2).Value;
TA : Long_Float := Constituents(3).Value;
TP : Long_Float := Constituents(4).Value;
AA : Long_Float := Constituents(5).Value;
AP : Long_Float := Constituents(6).Value;
T2A : Long_Float := Constituents(7).Value;
T2P : Long_Float := Constituents(8).Value;
SA : Long_Float := Constituents(9).Value;
SP : Long_Float := Constituents(10).Value;
A2A : Long_Float := Constituents(11).Value;
SYA : Long_Float := Constituents(12).Value;
SYP : Long_Float := Constituents(13).Value;
EA : Long_Float := Constituents(14).Value;
EP : Long_Float := Constituents(15).Value;
E2A : Long_Float := Constituents(16).Value;
YA : Long_Float := Constituents(17).Value;
YP : Long_Float := Constituents(18).Value;
Q1 : Long_Float := Constituents(19).Value;
Q2 : Long_Float := Constituents(20).Value;
DA : Long_Float := Constituents(21).Value;
DP : Long_Float := Constituents(22).Value;
K3 : Long_Float := Constituents(23).Value;
NA : Long_Float := Constituents(24).Value;
NP : Long_Float := Constituents(25).Value;
PA : Long_Float := Constituents(26).Value;
PP : Long_Float := Constituents(27).Value;
N2A : Long_Float := Constituents(28).Value;
N2P : Long_Float := Constituents(29).Value;
function Ds is new gsin (DA, 2.0*Drac, DP); -- = A*sin(2*Drac*(x+p));
function Ts is new gsin (TA, 2.0*Trop, TP); -- = A*sin(2*Trop*(x+p))
function T2s is new gsin (T2A, Trop+Drac, T2P); -- = 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);
Msm : Long_Float := Evect(Time);
Mfp : Long_Float := T2s(Time + A2A*Mm + E2A*Msm);
Mf : Long_Float := Ts(Time + A2A*Mm + E2A*Msm);
Mfd : Long_Float := Ds(Time + A2A*Mm + E2A*Msm);
Msf : Long_Float := Syn(Time + Q1*Mf + Q2*Mfp);
begin
return Mf + Mfp + Mfd + Semi(Time) + Annual(Time) + Msm + Msf + N(Time) + N2(Time) + P(Time) +
As(Time + K1*(Mf+Mfp+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 Jun 20, 2023

Using a sin^N delta of power N= 15

PS C:\Users\pp\github\pukpr\GEM2\GeoEnergyMath\eqlong> ......\GeoEnergyMath\io\backup.bat darwin_constituents2crossvalid3bSINcomplement

Delta variant
2390 ......\GeoEnergyMath\io\restore.bat darwin_constituents2crossvalid3b
2392 ......\GeoEnergyMath\io\restore.bat darwin_constituents2crossvalid3b
2393 $env:CC_START="1880"
2394 $env:CC_END="1932"
2400 ......\GeoEnergyMath\io\backup.bat darwin_constituents2crossvalid3bSIN
2404 ......\GeoEnergyMath\io\backup.bat darwin_constituents2crossvalid3bSINhigh
2406 ......\GeoEnergyMath\io\backup.bat darwin_constituents2crossvalid3bSINhigh-pt8
2408 ......\GeoEnergyMath\io\backup.bat darwin_constituents2crossvalid3bSINhigh-pt85worse
2409 ......\GeoEnergyMath\io\restore.bat darwin_constituents2crossvalid3bSIN

2410 $env:CC_END="2015"
2411 $env:CC_START="1935"
2414 ......\GeoEnergyMath\io\backup.bat darwin_constituents2crossvalid3bSINcomplement
2415 .\enso_opt.exe

image

  0.00111916648 :offset:
   0.00000000000 :bg:
  -9.10072106846 :impA:
   0.28438035101 :impB:
  14.99048476157 :impC:
  -9.09960468396:delA:
   0.27676443679:delB:
   9.17134999257:asym:
   0.07094617114:ann1:
  -2.81079818916:ann2:
  -0.15325271031:sem1:
   0.82592576109:sem2:
   0.00009296189:year:
   0.16091717257:IR:
   0.00001536702 :mA:
  -0.00084083884 :mP:
   0.00860963428 :shiftT:
  -0.59680237727 :init:
---- Tidal ----
   9.10846048884,    0.01735147656 1
  29.53063057588,   -0.02841717728 2
  27.09267692660,    0.34212651950 3
   7.08840409913,    0.98902914949 4
   6.85248390316,    0.10124629564 5
  13.60611040750,    1.02538819660 6
  13.66083077700,    0.12810273401 7
3396.73824406533,    1.42401647831 8
   9.12068919638,    0.01132689320 9
  13.77727494300,   -0.00129361749 10
6793.47648813065,   -0.00141824121 11
  27.55454988600,    0.00154127154 12
  27.66676714572,    1.04013588153 13
  27.44323926226,    0.04801111162 14
1616.30271425126,    0.82350083257 15
   6.85940288609,    0.00477189186 16
   7.09580795993,    0.00053293671 17
   9.55688258446,    0.47846435153 18
   9.13295078376,    0.11822503299 19
2190.35004466729,    0.08081744484 20
  27.21222081500,    0.01239904500 21
   9.18484996200,    0.94334717135 22
  14.76531528794,   -0.36577320399 23
  31.81203797339,    0.01780510042 24
   9.54345710207,  -35.06822898616 25
  13.63341568476,   -0.02476631047 26
  26.98505934729,    3.07001049660 27
 365.24998136189,    0.00486549849 28
 182.62499068094,   -4.22040260892 29
---- LTE ----
   0.00000000000 :trend:
   0.00000000000 :accel:
   0.02960125178 :K0:
   0.26312236581 :level:
   0.09829301324,    0.12809910700,   -0.43097963143 1
   0.19658602648,    0.11265463505,   -1.90715906435 2
   0.29487903972,    0.12366899916,    2.53306413829 3
   0.39317205296,    0.13115016410,   -1.00123312594 4
   0.49146506620,    0.09832753942,   -2.41960389136 5
   0.58975807944,    0.05829593852,    0.87636664162 6
   0.68805109268,    0.06254261335,    0.76857327396 7
   0.78634410592,    0.13035683320,   -0.53500952585 8
   0.88463711916,    0.07085795920,    2.69514441824 9
   0.98293013240,    0.10572920781,    1.50357447397 10
   1.08122314564,    0.09659980480,    0.27879539477 11
   1.17951615888,    0.07741724101,   -1.55555411855 12
   1.27780917212,    0.10110073886,   -0.92953866256 13
   1.37610218536,    0.09717414843,    2.82266415713 14
   1.47439519860,    0.20512998393,    0.54275260650 15
   1.57268821184,    0.10603572259,   -0.97981187486 16
   1.67098122508,    0.05799658566,   -0.89035815650 17
   1.76927423832,    0.07720518497,    0.46976104366 18
   1.86756725156,    0.12519995028,   -2.14973644482 19
   1.96586026480,    0.09429808065,   -1.16526740575 20
   2.06415327804,    0.16079515683,    1.56047312721 21
   2.16244629128,    0.14044981063,   -1.51094107709 22
   2.26073930452,    0.10259274726,   -2.43552323023 23
   2.35903231776,    0.05793799112,    1.90795379664 24
   2.45732533100,    0.14164047023,   -1.80620850855 25
   2.55561834424,    0.00420607273,    2.89569948071 26
   2.65391135748,    0.07049823326,   -1.37420827228 27
   2.75220437072,    0.13149912518,    0.08227794618 28
CC   0.4425475022   0.6975592971   6 1

image

  0.00110985420 :offset:
   0.00000000000 :bg:
  -9.10596735501 :impA:
   0.28457288762 :impB:
  14.90969085924 :impC:
  -9.09960468396:delA:
   0.27676443679:delB:
   9.17134999257:asym:
   0.09724201034:ann1:
  -3.04928964789:ann2:
  -0.14742732792:sem1:
   0.86686044813:sem2:
   0.00009287011:year:
   0.17721500732:IR:
   0.00001526087 :mA:
  -0.00083037102 :mP:
   0.00861491148 :shiftT:
  -0.60991844542 :init:
---- Tidal ----
   9.10846048884,    0.01846597017 1
  29.53063057648,   -0.03394950807 2
  27.09267692660,    0.34203486752 3
   7.08840409920,    0.98902914949 4
   6.85248390316,    0.09944457395 5
  13.60611040750,    1.02523107011 6
  13.66083077700,    0.12861229547 7
3396.73824406533,    1.42401647831 8
   9.12068919638,    0.01270231406 9
  13.77727494300,   -0.00126833170 10
6793.47648813065,   -0.00134537377 11
  27.55454988600,    0.00155005248 12
  27.66676714572,    1.04000442849 13
  27.44323926226,    0.04962952737 14
1616.30271425126,    0.82351149714 15
   6.85940288609,    0.00454258727 16
   7.09580795999,    0.00053422352 17
   9.55688258458,    0.48212442132 18
   9.13295078376,    0.11812462122 19
2190.35004466729,    0.07932590507 20
  27.21222081500,    0.01287833701 21
   9.18484996200,    0.94434959805 22
  14.76531528824,   -0.36575811194 23
  31.81203797478,    0.02360084843 24
   9.54345710219,  -35.06931620105 25
  13.63341568476,   -0.02518887575 26
  26.98505934729,    2.96969415112 27
 365.24998127011,    0.00427406948 28
 182.62499063506,   -4.35248443878 29
---- LTE ----
   0.00000000000 :trend:
   0.00000000000 :accel:
   0.02810361321 :K0:
   0.26042392472 :level:
   0.09835892336,    0.10525471578,   -0.80460442819 1
   0.19671784672,    0.10439747689,   -1.37300148009 2
   0.29507677007,    0.12683353431,    2.67708204217 3
   0.39343569343,    0.11129386927,   -1.12267685907 4
   4.81958724454,    0.11890742254,   -3.05129070775 49
   0.59015354015,    0.03436432985,    1.20037230725 6
   0.68851246351,    0.08199904050,    0.26497494707 7
   5.21302293797,    0.00479807367,   -0.39225118556 53
   2.95076770074,    0.08866196614,    0.91687894118 30
   0.98358923358,    0.15147976695,    1.49927932639 10
   1.08194815694,    0.06397850461,    0.53860107841 11
   1.18030708029,    0.08787268363,   -1.21055053995 12
   3.73763908760,    0.05950573892,    2.93847148446 38
   1.37702492701,    0.10244065999,   -2.64154640632 14
   1.47538385037,    0.13721345635,    1.04845284335 15
   1.57374277373,    0.07196677228,   -0.78516733690 16
   1.67210169708,    0.09032295539,    0.27646572433 17
   3.54092124088,    0.02439358742,    2.88964533141 36
   3.93435693431,    0.03646694797,    0.82434107520 40
   1.96717846716,    0.09618113945,   -0.08917390613 20
   2.06553739052,    0.19205911552,    2.44930592731 21
   2.16389631387,    0.11084363883,   -1.09774459741 22
   2.26225523723,    0.07339497541,   -1.13121489440 23
   2.36061416059,    0.10706568280,    2.19062642602 24
   2.45897308395,    0.17359820240,   -1.17766558835 25
   4.42615155110,    0.16680404172,   -1.96922413621 45
   2.65569093066,    0.03948719888,   -0.98296303915 27
   2.75404985402,    0.11549894513,    0.81862339353 28
CC   0.5313022260   0.8067687281   4 1
   0.00000000000:dLOD:
PS C:\Users\pp\github\pukpr\GEM2\GeoEnergyMath\eqlong> ..\..\..\GeoEnergyMath\io\restore.bat  darwin_constituents2crossvalid3bSINhigh-pt8

complement

image

PS C:\Users\pp\github\pukpr\GEM2\GeoEnergyMath\eqlong> $env:CC_START="1935"
PS C:\Users\pp\github\pukpr\GEM2\GeoEnergyMath\eqlong> $env:CC_END="2015"
PS C:\Users\pp\github\pukpr\GEM2\GeoEnergyMath\eqlong> ..\..\..\GeoEnergyMath\io\restore.bat  darwin_constituents2crossvalid3bSINcomplement

   0.00111410351 :offset:
   0.00000000000 :bg:
  -9.10159665685 :impA:
   0.29100278069 :impB:
  15.00099325490 :impC:
  -9.09960468396:delA:
   0.27676443679:delB:
   9.17239635150:asym:
   0.05359581574:ann1:
  -2.40364058872:ann2:
  -0.05127054039:sem1:
   1.86746940586:sem2:
   0.00010058079:year:
   0.08634772665:IR:
   0.00001720056 :mA:
   0.00084345706 :mP:
   0.00859911890 :shiftT:
  -0.43543304884 :init:
---- Tidal ----
   9.10846048884,    0.01803272019 1
  29.53063052608,   -0.03658112291 2
  27.09267692660,    0.34112909106 3
   7.08840409339,    0.98910415544 4
   6.85248390316,    0.10175600791 5
  13.60611040750,    1.02592115418 6
  13.66083077700,    0.12791759738 7
3396.73824406533,    1.42197611951 8
   9.12068919638,    0.01788987735 9
  13.77727494300,   -0.00605340828 10
6793.47648813065,   -0.00145833085 11
  27.55454988600,    0.00151198479 12
  27.66676714572,    1.03895065084 13
  27.44323926226,    0.05075911753 14
1616.30271425126,    0.82355871052 15
   6.85940288609,    0.00320896705 16
   7.09580795417,    0.00053410739 17
   9.55688257403,    0.57306744100 18
   9.13295078376,    0.12435688738 19
2190.35004466729,    0.10023747605 20
  27.21222081500,    0.01365874938 21
   9.18484996200,    0.94249414112 22
  14.76531526304,   -0.33085511500 23
  31.81203785780,    0.01437373677 24
   9.54345709166,  -35.15834522678 25
  13.63341568476,   -0.02561841048 26
  26.98505934729,    2.66228966886 27
 365.24998898079,    0.01042655187 28
 182.62499449039,   -2.06877620682 29
---- LTE ----
   0.00000000000 :trend:
   0.00000000000 :accel:
   0.01627185181 :K0:
   0.24607100842 :level:
   0.09821737513,    0.12982921648,    0.37864452113 1
   0.19643475026,    0.09495160464,    0.53876964029 2
   0.29465212539,    0.05200158278,   -1.73246801232 3
   0.39286950052,    0.15327436844,    2.93128993582 4
   0.49108687565,    0.12116171640,   -0.61026199805 5
   0.58930425078,    0.16826850214,    2.72831836262 6
   0.68752162591,    0.16201386758,    0.50713272508 7
   0.78573900104,    0.09778749475,   -2.54260767908 8
   0.88395637617,    0.10042271599,   -2.82285366034 9
   0.98217375130,    0.06308774705,   -2.65791921994 10
   1.08039112643,    0.05307354995,    3.01091203331 11
   1.17860850156,    0.10959776635,    0.89530367263 12
   1.27682587669,    0.12269611081,    2.05908982701 13
   1.37504325182,    0.14001996377,   -0.75310837014 14
   1.47326062695,    0.05450698278,    0.00570651443 15
   1.57147800208,    0.05791597434,    0.85654285798 16
   1.66969537721,    0.15447576611,    0.12500089638 17
   1.76791275234,    0.15176765519,   -2.67725363810 18
   1.86613012747,    0.06050471512,    2.24851720732 19
   1.96434750260,    0.01117398781,   -0.33024610614 20
   2.06256487773,    0.06161422446,   -2.38631185710 21
   2.16078225286,    0.22410084932,   -1.63859807521 22
   2.25899962799,    0.06850570208,    0.75543081880 23
   2.35721700312,    0.13480200795,    1.64377951810 24
   2.45543437825,    0.08348829256,   -0.55605911354 25
   2.55365175338,    0.15922125348,   -1.34910826202 26
   2.65186912851,    0.20931998383,    2.10276326277 27
   2.75008650364,    0.28512382344,    0.52740751024 28
CC   0.3048770993   0.7029153436   2 1

compare to delta version
image

PS C:\Users\pp\github\pukpr\GEM2\GeoEnergyMath\eqlong> ......\GeoEnergyMath\io\restore.bat darwin_constituents2crossvalid3b
PS C:\Users\pp\github\pukpr\GEM2\GeoEnergyMath\eqlong> $env:CC_START="1880"
PS C:\Users\pp\github\pukpr\GEM2\GeoEnergyMath\eqlong> $env:CC_END="1932"

   0.00109088247 :offset:
   0.00000000000 :bg:
   0.00000000000 :impA:
   0.00000000000 :impB:
   0.00000000000 :impC:
  -9.09960468396:delA:
   0.27676443679:delB:
   9.17134999257:asym:
   0.06889137968:ann1:
  -2.27376860093:ann2:
  -0.15715015236:sem1:
   0.92513196376:sem2:
   0.00008029612:year:
   0.06650862460:IR:
   0.00001532610 :mA:
  -0.00082255133 :mP:
   0.00852819665 :shiftT:
  -0.72843188072 :init:
---- Tidal ----
   9.10846048884,    0.01755781878 1
  29.53063065867,   -0.02837080741 2
  27.09267692660,    0.34519971062 3
   7.08840410867,    1.01123278425 4
   6.85248390316,    0.09753091315 5
  13.60611040750,    1.02538182651 6
  13.66083077700,    0.12773101598 7
3396.73824406533,    1.42389799800 8
   9.12068919638,    0.00964048632 9
  13.77727494300,   -0.03355442307 10
6793.47648813065,   -0.00183211491 11
  27.55454988600,    0.00154686936 12
  27.66676714572,    1.04662152018 13
  27.44323926226,    0.04871832111 14
1616.30271425126,    0.82350083257 15
   6.85940288609,    0.00506536922 16
   7.09580796949,    0.00053185233 17
   9.55688260180,    0.56622942023 18
   9.13295078376,    0.11822295260 19
2190.35004466729,    0.07507394684 20
  27.21222081500,    0.01181143551 21
   9.18484996200,    0.93943288590 22
  14.76531532934,   -0.28076102127 23
  31.81203816555,    0.00468638492 24
   9.54345711936,  -34.69940596576 25
  13.63341568476,   -0.02367995865 26
  26.98505934729,    2.61832577375 27
 365.24996869612,    0.00632525027 28
 182.62498434806,   -4.35727303373 29
---- LTE ----
   0.00000000000 :trend:
   0.00000000000 :accel:
  -0.04154440309 :K0:
   0.32272740167 :level:
   0.09945049539,    0.14233495792,    2.82293339007 1
   0.19890099078,    0.04074860781,   -1.18095774486 2
   0.29835148617,    0.07736963942,    0.22509833347 3
   0.39780198156,    0.01801059313,    0.95928086552 4
   0.49725247695,    0.09577604899,    1.01439357459 5
   0.59670297234,    0.06282921208,   -0.62233294256 6
   0.69615346773,    0.12472337575,   -1.60605415489 7
   0.79560396312,    0.13116440049,    2.61309540850 8
   0.89505445851,    0.07699326678,    1.18684004096 9
   0.99450495390,    0.17352383322,    1.51341038983 10
   1.09395544929,    0.09750132014,    0.59655667129 11
   1.19340594468,    0.06280150681,   -1.79792613936 12
   1.29285644007,    0.13311197174,   -2.57370048704 13
   1.39230693546,    0.07227354075,   -0.75952872923 14
   1.49175743085,    0.15196195110,   -0.77599806381 15
   1.59120792624,    0.18134615860,   -2.24338876599 16
   1.69065842163,    0.16815721263,   -0.72839865759 17
   1.79010891702,    0.05043092479,    2.62748007942 18
   1.88955941241,    0.15429751798,    0.67546858462 19
   1.98900990780,    0.18528345314,    3.03613883875 20
   2.08846040319,    0.07829199998,   -1.87386005882 21
   2.18791089858,    0.07744109973,   -2.46782574971 22
   2.28736139397,    0.00467212630,    1.31626589276 23
   2.38681188936,    0.15861118711,    0.72053297557 24
   2.48626238475,    0.15835312136,   -2.98697579417 25
   2.58571288014,    0.17772235712,   -1.98248117218 26
   2.68516337553,    0.26258090863,   -2.78194228824 27
   2.78461387092,    0.11031703379,    1.66223720371 28
CC   0.0675539728   0.8460361054   2 1


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