Skip to content

Instantly share code, notes, and snippets.

@pukpr
Created June 17, 2024 22:48
Show Gist options
  • Save pukpr/3a3566b601a54da2724df9c29159ce16 to your computer and use it in GitHub Desktop.
Save pukpr/3a3566b601a54da2724df9c29159ce16 to your computer and use it in GitHub Desktop.
Flat tidal factor series, 2nd-order multiply 1st to 2nd partition
-- 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;
One : constant Long_Float := 1.0;
Partition : constant Integer := 7; -- 4
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 + Partition loop
declare
L : Amp_Phase renames Constituents(J);
Freq : Long_Float := Year_Len / Periods(J);
begin
if Aliased_Period then
Freq := Long_Float'Remainder(Freq,One);
end if;
if Cos_Phase then
TF1 := TF1 + L.Amplitude*(Cos(2.0*Pi*Freq*Time + L.Phase));
else
TF1 := TF1 + L.Amplitude*(Sin(2.0*Pi*Freq*Time + L.Phase));
end if;
end;
end loop;
for J in Constituents'First + Partition+1 .. Constituents'Last loop
declare
L : Amp_Phase renames Constituents(J);
Freq : Long_Float := Year_Len / Periods(J);
begin
if Aliased_Period then
Freq := Long_Float'Remainder(Freq,One);
end if;
if Cos_Phase then
TF2 := TF2 + L.Amplitude*(Cos(2.0*Pi*Freq*Time + L.Phase));
else
TF2 := TF2 + L.Amplitude*(Sin(2.0*Pi*Freq*Time + L.Phase));
end if;
end;
end loop;
Res(I) := (Time, TF1 + TF2 + Scaling * TF1 * 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 : Data_Pairs := Template;
begin
Res1 := Tide_Sum_Diff (Template, Constituents, Periods, 0.0, Scaling, Cos_Phase, Year_Len, Integ);
return Res1;
end Tide_Sum;
@pukpr
Copy link
Author

pukpr commented Jul 2, 2024

DTW=2

image

   0.04751432582 :impA:
   0.69533965873 :impB:
  -0.24732679053 :impC:
  -0.12415925709:delA:
   0.54630974681:delB:
   0.07630715158:asym:
   0.86223151225:ann2:
   0.20515566727:sem1:
  -3.10609765275:sem2:
   0.00001071614:year:
  -0.23514696896:IR:
  -0.02033889019 :mA:
  -0.00112782455 :mP:
   0.53820907670 :shiftT:
   0.00342475582 :init:
---- Tidal ----
  27.32166155400,   -0.24765084353,    3.52534133612,  1, -100989,  2.45469629903300E-04
  27.21222081500,   -2.26689449562,   13.39098472780,  2, -176450,  1.28545337997778E-03
1095.17502233364,    0.24710055226,   43.47957729342,  3,  221741,  1.11386097667308E-04
 346.61621461696,   -0.48708750304,   -2.02819369548,  4, -72132,  6.76207417772825E-04
 173.30810730848,   -1.82457129412,    0.88844753716,  5, -164311,  1.11111547537411E-03
  13.63341568476,    0.11256551105,   -5.81034509030,  6, -12,  1.27519604246483E-01
  13.66083077700,   -0.24758142574,    6.42509619401,  7, -178,  3.15871939013506E-01
  13.60611040750,    5.24729789108,    6.54842290019,  8,  54645,  9.58491200982993E-03
  27.55454988600,  -11.29185537740,    6.89209769666,  9, -13287,  8.56318638745967E-02
  13.77727494300,   -0.13035522164,   -7.56259874066,  10, -1073,  1.33918833558891E-02
   9.18484996200,    0.73395546342,   -7.95812726464,  11,  31558,  2.31839986620299E-03
-411.77898284155,   -1.85341313369,   -2.62811756496,  12, -905236,  2.04766297227512E-04
  27.09267692660,   -0.29911847723,  -27.87442532392,  13, -6281,  4.83927513690709E-03
-205.88949142077,   -4.91234274322,    3.14541777530,  14, -714462,  6.87654380550233E-04
  13.69115772864,    0.40680752259,    8.09594126967,  15,  13413,  3.01043583430323E-03
   9.10846048884,   -0.34835352761,    1.77486254421,  16, -12151,  2.89054775186580E-03
  27.44323926226,    0.66627834776,    8.64947651345,  17,  14571,  4.54141318361147E-03
  27.66676714572,    0.47543495666,   -0.81842117436,  18,  6439,  7.27116136581422E-03
2190.35004466729,   -0.35901721425,   -2.70545748506,  19, -65652,  5.47685143901565E-04
  26.87829334283,   -0.14033569845,   -2.11492180810,  20, -16182,  8.72627621787433E-04
---- LTE ----
  -0.01481311701 :trend:
   0.00012832258 :accel:
   0.65143385499 :K0:
  28.58773051618 :level:
  -0.73863631974,    0.12433814052,   -1.38839929168 7
  -0.09953911566,    1.20043537023,   -0.33298232101 1
 -16.02579762125,    0.12351786285,    2.19778748706 161
 -24.88477891498,    0.22548001713,    2.77503206802 250
 -22.49584013915,    0.31487345189,   -0.05528844696 226
 -29.86173469798,    0.46161303591,   -0.69012824464 300
 -11.64607653221,    0.24285926052,    2.33998849083 117
 -28.16956973176,    0.31487879447,    1.93472188900 283
 -15.22948469597,    0.09092641585,   -0.56428908579 153
 -17.41934524049,    0.23258994434,   -0.73191378014 175
 -19.11151020671,    0.24026291577,   -0.74442508047 192
  -9.35667687203,    0.31490519831,   -0.52830027288 94
 -27.47279592214,    0.26644651750,   -1.73223032183 276

DTW 0.6041530471 0.7440587325 4 1
PS C:\Users\pp\scratch\anom\run> $env:NUMBER_OF_PROCESSORS="8"
PS C:\Users\pp\scratch\anom\run> ..\backup bi_darwin_overfit_harm721c-1920-1980excl-dtw1fixharm_mod-overnight4aWOW1dtwccDTW_noharm1hi1cc-1940-1945CCbaddlowC

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