Skip to content

Instantly share code, notes, and snippets.

View pukpr's full-sized avatar

Paul Pukite pukpr

View GitHub Profile
@pukpr
pukpr / SINDy.py
Last active November 14, 2025 02:45
SINDy example of a non-autonomous fit to a hidden latent layer
import numpy as np
from sklearn.linear_model import Lasso
# ----------------------------
# USER INPUT: hidden layer & target
# ----------------------------
# Example synthetic data (replace with your arrays)
N = 1000
t = np.linspace(0, 10, N)
hidden_layer = np.sin(2*np.pi*1*t) + 0.5*np.sin(2*np.pi*3*t) # latent forcing
@pukpr
pukpr / LTE_MLR.py
Last active November 10, 2025 19:45
LTE optimization with MLR on latent factors
#!/usr/bin/env python3
"""
timeseries_modeler.py
Read a two-column CSV (time, value). Read a JSON file with the same filename
appended by ".p" (e.g. data.csv.p) into a data dictionary. Create a clone of the
time-series and run a loop that steps through timestamps, calling a user-
customizable model-step function to produce a modeled series. At the end the
script computes Pearson's correlation coefficient and the variance of the
squared errors (and also MSE), using library routines.
@pukpr
pukpr / ts_lte.py
Created October 23, 2025 14:50
Descent optimized LTE annual time-series, Python
#!/usr/bin/env python3
"""
timeseries_modeler.py
Read a two-column CSV (time, value). Read a JSON file with the same filename
appended by ".p" (e.g. data.csv.p) into a data dictionary. Create a clone of the
time-series and run a loop that steps through timestamps, calling a user-
customizable model-step function to produce a modeled series. At the end the
script computes Pearson's correlation coefficient and the variance of the
squared errors (and also MSE), using library routines.
@pukpr
pukpr / 144d.dat.p
Created October 24, 2025 01:15
Descent optimized LTE annual time-series, Julia
{"PeriodsPhase":[13.599781479999999,7.510001926736354,18.679732370000025,7.195787246118572,20.998850680000004,9.392972953999996,6.001334823,10.345732619999998,9.26752208,6.276528506318169,6.158543069000001,15.797059490000018,5.047887753499271,7.347247053426061,1.7632983608814414,6.514613283064518,7.845674634],"Hold":0.0015847482104409999,"Initial":0.019102685632566375,"Imp_Stride":2,"LTE_Freq":182.73199150000377,"Periods":[27.2122,27.3216,27.5545,13.63339513,13.69114014,13.6061,13.6608,13.71877789,6795.985773,1616.215172,2120.513853,13.77725,3232.430344,9.132931547,9.108450374,9.120674533,27.0926041],"LTE_Amp":1.2282362293246383,"DeltaTime":0.0,"Imp_Amp":38.41771511999972,"AliasedPhase":[12.936492162500015,10.819234671777158,17.28825828537955,9.83624739277385,24.275678314901782,15.228945466500011,8.477116474739738,14.315824278046344,9.824004490952355,6.960279582531864,4.2964023424706665,19.297607654892147,3.967560759570126,22.113385778146025,8.444613035937136,4.885017823159738,10.475305999774953,6.49431729103
@pukpr
pukpr / 11a.csv
Created October 21, 2025 03:47
LTE model for tidal stations, example for Warnemunde (11)
1884.0000000000 0.4205700000
1884.0833333333 0.3868980000
1884.1666666667 0.7086080000
1884.2500000000 0.6610860000
1884.3333333333 0.7397180000
1884.4166666667 0.7168100000
1884.5000000000 0.8215940000
1884.5833333333 1.0048380000
1884.6666666667 1.0588480000
1884.7500000000 1.3143980000
@pukpr
pukpr / qv.py
Created September 7, 2025 04:13
Animation of QBO, opens window in Browser
from vpython import *
Running = True
def exit_app(evt):
global Running
if evt.key == 'q': # Press 'q' to quit
print("Exiting simulation...")
Running = False
@pukpr
pukpr / enso_periodogram_modify.py
Created July 2, 2025 01:40
ENSO power spectrum periodogram generated by ChatGPT
import numpy as np
import matplotlib.pyplot as plt
from scipy.signal import periodogram, windows
# Parameters
years = 500
dt = 1 / 365.25 # daily resolution
t = np.arange(0, years, dt)
fs = 1 / dt # sampling frequency in cycles per year
@pukpr
pukpr / GEM-Mix-Regression,adb
Created June 28, 2025 05:29
Regression fit for ENSO
with Text_IO;
with GEM.LTE.Primitives;
function GEM.Mix_Regression (File_Name : in String) return Gem.LTE.Period_Set is
use GEM.LTE, GEM.LTE.Primitives;
D : Data_Pairs := Make_Data(File_Name);
First, Last : Integer;
Singular : Boolean;
Forcing : Data_Pairs := D;
Model : Data_Pairs := D;
@pukpr
pukpr / Tide_Sum_Custom.adb
Created June 21, 2025 17:19
Reduced tide summation including mixed terms
function Tide_Sum_Custom (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;
Ext_Forcing : in Data_Pairs := Empty_Data;
Ext_Factor : in Long_Float := 0.0;
@pukpr
pukpr / extract_satellite_periods_harmonics.py
Created June 18, 2025 03:27
Demodulation of climate index using annual, etc carrier, optimized for impulse train
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
def load_signal(csv_path):
df = pd.read_csv(csv_path)
time = df.iloc[:, 0].values
signal = df.iloc[:, 1].values
return time, signal