lagrangian-gradient-regression 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. lagrangian_gradient_regression-0.1.0.dist-info/METADATA +197 -0
  2. lagrangian_gradient_regression-0.1.0.dist-info/RECORD +71 -0
  3. lagrangian_gradient_regression-0.1.0.dist-info/WHEEL +4 -0
  4. lagrangian_gradient_regression-0.1.0.dist-info/licenses/LICENSE +21 -0
  5. lgr/__init__.py +213 -0
  6. lgr/array_api.py +866 -0
  7. lgr/backends/__init__.py +2 -0
  8. lgr/backends/jax_lgr.py +245 -0
  9. lgr/core/__init__.py +13 -0
  10. lgr/core/dataframe.py +174 -0
  11. lgr/core/particle.py +214 -0
  12. lgr/core/pipeline.py +528 -0
  13. lgr/data/__init__.py +28 -0
  14. lgr/data/base.py +45 -0
  15. lgr/data/erddap.py +243 -0
  16. lgr/data/glad.py +209 -0
  17. lgr/data/gridded.py +665 -0
  18. lgr/data/ingestion.py +180 -0
  19. lgr/experimental/__init__.py +43 -0
  20. lgr/experimental/bootstrap.py +262 -0
  21. lgr/experimental/regression.py +2651 -0
  22. lgr/experiments/__init__.py +43 -0
  23. lgr/experiments/artifacts.py +165 -0
  24. lgr/experiments/datasets.py +1053 -0
  25. lgr/experiments/double_gyre_benchmark.py +2657 -0
  26. lgr/experiments/evaluate.py +829 -0
  27. lgr/experiments/figures.py +739 -0
  28. lgr/experiments/flow_kernels.py +51 -0
  29. lgr/experiments/nonlinear_benchmark.py +2058 -0
  30. lgr/experiments/notebooks.py +39 -0
  31. lgr/flows/__init__.py +19 -0
  32. lgr/flows/abc_flow.py +135 -0
  33. lgr/flows/base.py +242 -0
  34. lgr/flows/bickley_jet.py +192 -0
  35. lgr/flows/gyre.py +117 -0
  36. lgr/flows/integration.py +2155 -0
  37. lgr/flows/jax_backend.py +209 -0
  38. lgr/flows/ocean.py +193 -0
  39. lgr/flows/registry.py +58 -0
  40. lgr/interpolation/__init__.py +11 -0
  41. lgr/interpolation/base.py +70 -0
  42. lgr/interpolation/griddata_interp.py +61 -0
  43. lgr/interpolation/rbf.py +106 -0
  44. lgr/metrics/__init__.py +21 -0
  45. lgr/metrics/base.py +107 -0
  46. lgr/metrics/cauchy_green.py +91 -0
  47. lgr/metrics/divergence.py +158 -0
  48. lgr/metrics/dra.py +85 -0
  49. lgr/metrics/ftle.py +91 -0
  50. lgr/metrics/lavd.py +92 -0
  51. lgr/metrics/uncertainty.py +274 -0
  52. lgr/metrics/vorticity.py +165 -0
  53. lgr/plotting/__init__.py +11 -0
  54. lgr/plotting/colormaps.py +154 -0
  55. lgr/plotting/fields.py +125 -0
  56. lgr/plotting/paper.py +344 -0
  57. lgr/plotting/trajectories.py +55 -0
  58. lgr/preprocessing/__init__.py +48 -0
  59. lgr/preprocessing/jacobians.py +266 -0
  60. lgr/preprocessing/trajectories.py +273 -0
  61. lgr/py.typed +0 -0
  62. lgr/regression/__init__.py +74 -0
  63. lgr/regression/base.py +116 -0
  64. lgr/regression/batched.py +1173 -0
  65. lgr/regression/epanechnikov.py +81 -0
  66. lgr/regression/gaussian.py +76 -0
  67. lgr/regression/gpr.py +160 -0
  68. lgr/regression/jets.py +275 -0
  69. lgr/regression/lowess.py +86 -0
  70. lgr/regression/pseudoinverse.py +54 -0
  71. lgr/regression/weights.py +364 -0
@@ -0,0 +1,197 @@
1
+ Metadata-Version: 2.5
2
+ Name: lagrangian-gradient-regression
3
+ Version: 0.1.0
4
+ Summary: Lagrangian Gradient Regression for the detection of Lagrangian Coherent Structures from sparse trajectory data.
5
+ Project-URL: Repository, https://github.com/TannerHarms/Lagrangian-Gradient-Regression
6
+ Project-URL: Paper, https://doi.org/10.1098/rsos.240586
7
+ Project-URL: Issues, https://github.com/TannerHarms/Lagrangian-Gradient-Regression/issues
8
+ Author: Tanner Harms
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: FTLE,coherent structures,fluid dynamics,gradient regression,lagrangian
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Scientific/Engineering :: Physics
18
+ Requires-Python: >=3.12
19
+ Requires-Dist: matplotlib>=3.6
20
+ Requires-Dist: numpy>=1.23
21
+ Requires-Dist: pandas>=1.5
22
+ Requires-Dist: scikit-learn>=1.1
23
+ Requires-Dist: scipy>=1.9
24
+ Requires-Dist: sympy>=1.11
25
+ Provides-Extra: cuda
26
+ Requires-Dist: jax[cuda12]>=0.4; (platform_system == 'Linux') and extra == 'cuda'
27
+ Provides-Extra: dev
28
+ Requires-Dist: pytest-cov; extra == 'dev'
29
+ Requires-Dist: pytest>=7; extra == 'dev'
30
+ Requires-Dist: ruff; extra == 'dev'
31
+ Provides-Extra: gpu
32
+ Requires-Dist: jax[cuda12]>=0.4; (platform_system == 'Linux') and extra == 'gpu'
33
+ Provides-Extra: jax
34
+ Requires-Dist: jax>=0.4; extra == 'jax'
35
+ Provides-Extra: ocean
36
+ Requires-Dist: netcdf4>=1.6; extra == 'ocean'
37
+ Requires-Dist: requests>=2.28; extra == 'ocean'
38
+ Requires-Dist: xarray>=2022.9; extra == 'ocean'
39
+ Provides-Extra: rocm
40
+ Requires-Dist: jax[rocm]>=0.4; (platform_system == 'Linux') and extra == 'rocm'
41
+ Description-Content-Type: text/markdown
42
+
43
+ # Lagrangian Gradient Regression (LGR)
44
+
45
+ A modular Python package for estimating flow-map Jacobians from sparse Lagrangian trajectory data and computing Lagrangian Coherent Structure (LCS) diagnostics.
46
+
47
+ ## Reference
48
+
49
+ > Harms, T. D., Brunton, S. L., & McKeon, B. J. (2024). [Lagrangian gradient regression for the detection of coherent structures from sparse trajectory data](https://doi.org/10.1098/rsos.240586). *R. Soc. Open Sci.* **11**, 240586.
50
+
51
+ The nonlinear estimators (higher-order polynomial libraries, Gaussian-process local models and the
52
+ composed higher derivatives of the flow map) are described in *Nonlinear Lagrangian Gradient
53
+ Regression* (in preparation). The code and data that reproduce that paper's figures are in
54
+ [Nonlinear-LGR-Paper](https://github.com/TannerHarms/Nonlinear-LGR-Paper).
55
+
56
+ ## Installation
57
+
58
+ ```bash
59
+ pip install lagrangian-gradient-regression
60
+ ```
61
+
62
+ The package is imported as `lgr`. It is distributed under its full name because the name `lgr`
63
+ on PyPI belongs to an unrelated project; do not `pip install lgr`. Python 3.12 or newer.
64
+
65
+ Optional extras: `[ocean]` for the gridded ocean-data readers and `[jax]` for the JAX backend.
66
+
67
+ To work on the library itself, install from a clone:
68
+
69
+ ```bash
70
+ git clone https://github.com/TannerHarms/Lagrangian-Gradient-Regression.git
71
+ cd Lagrangian-Gradient-Regression
72
+ pip install -e ".[dev]"
73
+ ```
74
+
75
+ ## Quick Start
76
+
77
+ LGR works on a plain `(n_particles, n_times, dim)` array of positions. Nothing
78
+ else is required — no wrapper objects, no DataFrame.
79
+
80
+ ```python
81
+ import numpy as np
82
+ from lgr import (
83
+ fit_library_deformation, compute_lcs_metrics, estimate_error,
84
+ )
85
+ from lgr.flows import DoubleGyre
86
+
87
+ # 1. Trajectories: any (n_particles, n_times, dim) array will do.
88
+ flow = DoubleGyre()
89
+ ics = np.random.rand(500, 2) * [2, 1] # random seeds in [0,2]x[0,1]
90
+ times = np.linspace(0, 10, 101)
91
+ positions = flow.integrate_trajectories(ics, times)
92
+
93
+ # 2. Fit local deformation gradients. `order=1` is standard LGR; raising it
94
+ # fits a richer local flow map and differentiates that at the tracer,
95
+ # which is what reduces finite-neighbourhood bias on sparse data.
96
+ fit = fit_library_deformation(positions, times=times, order=2, k_neighbors=20)
97
+
98
+ fit.F # (n_particles, n_intervals, dim, dim)
99
+ fit.valid # which fits passed the rank/conditioning gates
100
+ fit.normalized_dof_residual # residual, comparable across polynomial orders
101
+ fit.hessian # the second derivative, free once order >= 2
102
+
103
+ # 3. LCS diagnostics from the deformation gradients.
104
+ metrics = compute_lcs_metrics(fit.to_deformation_result(), metrics=("ftle",))
105
+ metrics.ftle # (n_particles, n_intervals)
106
+ ```
107
+
108
+ Missing observations are supported directly — leave them as `NaN` and they are
109
+ excluded from every neighbourhood:
110
+
111
+ ```python
112
+ positions[10, 40:50] = np.nan # this tracer is simply not seen for a while
113
+ ```
114
+
115
+ Kernel weighting, a Gaussian-process local model, and uncertainty are all
116
+ one argument away:
117
+
118
+ ```python
119
+ from lgr import fit_anchored_gp_deformation, WEIGHT_KERNELS
120
+
121
+ fit_library_deformation(positions, times=times, order=2, k_neighbors=20,
122
+ weights="gaussian", bandwidth=0.7)
123
+ gp = fit_anchored_gp_deformation(positions, times=times, k_neighbors=20)
124
+ gp.F_variance # posterior variance of the gradient
125
+ ```
126
+
127
+ ## Package Architecture
128
+
129
+ ```
130
+ src/lgr/
131
+ ├── array_api.py # TrajectoryData, neighbour search, fit_deformation, metrics
132
+ ├── regression/ # local estimators: batched kernels, weights, libraries, GP
133
+ ├── metrics/ # LCS diagnostics (FTLE, LAVD, DRA, vorticity, uncertainty)
134
+ ├── flows/ # analytical flows + batched integration and composition
135
+ ├── interpolation/ # scattered-to-grid interpolation
136
+ ├── plotting/ # colormaps, fields, trajectories, paper figure style
137
+ ├── preprocessing/ # trajectory and Jacobian cleaning
138
+ └── core/ # legacy Particle/DataFrame pipeline (see below)
139
+ ```
140
+
141
+ The array-first API above is the supported path. The `Particle` /
142
+ `generate_dataframe` / `compute_jacobians` pipeline in `lgr.core` predates it
143
+ and is retained for existing scripts; it is slower, holds the whole history in
144
+ a pandas frame, and does not expose the nonlinear estimators. New code should
145
+ use `lgr.PRIMARY_API`.
146
+
147
+ ### Extension Points
148
+
149
+ Every major subsystem is built around an **abstract base class** so new
150
+ components can be added without modifying existing code:
151
+
152
+ | Extension Point | ABC | Example Subclasses |
153
+ |----------------|-----|-------------------|
154
+ | Jacobian estimation | `RegressionKernel` | `PseudoinverseRegression`, `GaussianKernelRegression` |
155
+ | Local libraries | `LocalBasis` | `PolynomialBasis` |
156
+ | LCS metrics | `LagrangianMetric` | `FTLEMetric`, `LAVDMetric`, `DRAMetric`, `VorticityMetric` |
157
+ | Flow models | `FlowBase` | `DoubleGyre`, `BickleyJet`, `ABCFlow` |
158
+ | Interpolation | `Interpolator` | `GridDataInterpolator`, `RBFInterpolator` |
159
+
160
+ ## Examples
161
+
162
+ Jupyter notebook demonstrations are in the `examples/` directory:
163
+
164
+ - **`LCS_from_velocity_gradients.ipynb`** — FTLE from known analytical velocity gradients
165
+ - **`LGR_on_Random_Sparse_Data.ipynb`** — Full LGR pipeline on sparse/random particle data
166
+ - **`nonlinear_order_benchmark_paper_example.ipynb`** — Paper figure workflow for nonlinear polynomial and GP regression comparisons
167
+
168
+ ## Experiment Artifacts
169
+
170
+ The experiment scripts generate NPZ/JSON artifacts, run the array-first LGR
171
+ workflow, and create static figures without changing package source code:
172
+
173
+ ```bash
174
+ python scripts/experiments/generate_dataset.py --config configs/experiments/datasets/linear3d_random_tiny.json --output-dir artifacts/datasets
175
+ python scripts/experiments/run_lgr_experiment.py --config configs/experiments/models/array_lgr_default.json --dataset artifacts/datasets/analytic3d_linear3d_random_tiny_seed0.npz --output-dir artifacts/results
176
+ python scripts/experiments/make_figures.py --config configs/experiments/figures/default_report.json --results artifacts/results/analytic3d_linear3d_random_tiny_seed0_array_lgr_default.npz --output-dir artifacts/figures
177
+ ```
178
+
179
+ Synthetic LPT artifacts and nonlinear model configs are included:
180
+
181
+ ```bash
182
+ python scripts/experiments/generate_dataset.py --config configs/experiments/datasets/synthetic_lpt_double_gyre_tiny.json --output-dir artifacts/datasets
183
+ python scripts/experiments/run_lgr_experiment.py --config configs/experiments/models/array_lgr_polynomial_order2.json --dataset artifacts/datasets/synthetic_lpt_double_gyre_random_tiny_seed0.npz --output-dir artifacts/results
184
+ python scripts/experiments/run_lgr_experiment.py --config configs/experiments/models/array_lgr_model_selection.json --dataset artifacts/datasets/synthetic_lpt_double_gyre_random_tiny_seed0.npz --output-dir artifacts/results
185
+ ```
186
+
187
+ Slurm and Flux launcher templates are in `configs/experiments/launchers/`.
188
+
189
+ ## Running Tests
190
+
191
+ ```bash
192
+ pytest
193
+ ```
194
+
195
+ ## License
196
+
197
+ MIT License — see [LICENSE](https://github.com/TannerHarms/Lagrangian-Gradient-Regression/blob/main/LICENSE) for details.
@@ -0,0 +1,71 @@
1
+ lgr/__init__.py,sha256=UhVJW5W37N5l_LDbJ0PBDhA8ey3RCXeDvpNw5nWRWDI,6126
2
+ lgr/array_api.py,sha256=of35BUoSm9oTx5oCfaAOu4X7QlACgbRqGs3YYjDcwfo,32556
3
+ lgr/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ lgr/backends/__init__.py,sha256=66Tl_M77YqCpco5DnkeKZJs8Wbtw7EsiAxIvsd3mAUU,67
5
+ lgr/backends/jax_lgr.py,sha256=yno5aWxT5P61nIeY0wkiKHnVpv96zuqmlpt3TtvEGwE,8499
6
+ lgr/core/__init__.py,sha256=V1JKX2ZlcR7wMU7Fux1PYZ1DQcWwcquSeoCiyTM5B6Y,395
7
+ lgr/core/dataframe.py,sha256=ZoN5gCOQ2ockJPejH4M5M5No6hoGQZLkEt8L6D3NeVY,5678
8
+ lgr/core/particle.py,sha256=-x9Gw-47MPfwHYJwTIyFTNQghR615HKNWFhtGfeQOJI,7302
9
+ lgr/core/pipeline.py,sha256=ZYpZyUxzQrMLiQU5fy0Nn09md7dWVmCu6oeZq-zizwY,18948
10
+ lgr/data/__init__.py,sha256=0Cl5Y1HCBVQ3vfytdEyFqZB8pJcTf1HSisTdHMnMNnk,746
11
+ lgr/data/base.py,sha256=9FBLr62v9Fp0au88hK_jLz3WTH8ZAcJ-ce5k3c9yG4o,1204
12
+ lgr/data/erddap.py,sha256=kjMzcT6K-P9f_1wO3MV1SFBLnq77F8LUno9Vogu7KoE,8019
13
+ lgr/data/glad.py,sha256=99lD2PKUcXUO3Hkl19pI66RuWFwYz7ASp91ibivV2wY,8877
14
+ lgr/data/gridded.py,sha256=3pS89qz6WZaNwbMkxK7OWLIc2izSoI8PegVTEW27PuU,24531
15
+ lgr/data/ingestion.py,sha256=alto79fqlHtG5Ymtwj5mFSNvIL4PlvX2d9Xo0nVGSFk,5099
16
+ lgr/experimental/__init__.py,sha256=YIATwG2UY8rAw41-IZZ2kPyK8ihB4U94BepybQg8PvM,1264
17
+ lgr/experimental/bootstrap.py,sha256=dGVs9QMoDIcj5wOFg6z5FOQkpE75XtbZzP-thBm-7ew,10436
18
+ lgr/experimental/regression.py,sha256=X9pAd7Tn5ufuMsH4THkFDEwXTEW3xIg6S7kGm9-chfI,102013
19
+ lgr/experiments/__init__.py,sha256=pppQzHn1JvnlUBhRuD2o1EFnQ__MNMiirI2Zs9anCaw,1339
20
+ lgr/experiments/artifacts.py,sha256=493gO-jIp1HkdRKrUngX3kEXl2hlC8RD0zFadWbAxag,4917
21
+ lgr/experiments/datasets.py,sha256=pb2DMmN1aKvd4dWUCNmZvqvlkKOvqvr1_O9hflafKGo,37859
22
+ lgr/experiments/double_gyre_benchmark.py,sha256=k4gJ-tfbrRBsZTANgM0xZ65eKeozhZm4JwxqvW0OWVs,95613
23
+ lgr/experiments/evaluate.py,sha256=NGlGQpfT5ZmjbMlWyQ2lj8s3OHto3WVGewKokeE0yTM,32719
24
+ lgr/experiments/figures.py,sha256=P91UXOYPG82TxCzkV8FQCSkjTSuQOffDFNhZ9ntaOtw,24012
25
+ lgr/experiments/flow_kernels.py,sha256=POIT_rCl6CDElnUKCma73vSm6vjMQ0qeocl9kxRHOZo,1381
26
+ lgr/experiments/nonlinear_benchmark.py,sha256=_f3L67mXA50ECJvhEmSxNtIhwm66kPRgpek21yw7oXc,73499
27
+ lgr/experiments/notebooks.py,sha256=27KBSjf8jlw9YgCvdxktIelynU8A-TMQTpc5J0dcI_4,1183
28
+ lgr/flows/__init__.py,sha256=7O26UVvHyXFa4ofPoi-swfKrv1fyaQcFLuT-RVM5Ovs,521
29
+ lgr/flows/abc_flow.py,sha256=cX2abMpyws1HhEYc3QVoKzpnnRxsQaFg5_RafwqERXQ,4258
30
+ lgr/flows/base.py,sha256=cCi_HajVRVg6OtfhHIc8qCUO9thXrikYV4uvv0-N8Xk,7904
31
+ lgr/flows/bickley_jet.py,sha256=fPPblGs7VA6EzqzpbMVV8EKllMERXd3BK1rbXqASkmI,6310
32
+ lgr/flows/gyre.py,sha256=8Qi9woiiEmMzrhVNxy-FlXqp66-MgbmuJOBZAAWZPck,3445
33
+ lgr/flows/integration.py,sha256=ml-TISPWCKLJhkmQgYY3GTD3YI6z-9Wmc87ICJUoUNQ,100427
34
+ lgr/flows/jax_backend.py,sha256=bA1vWfdgJX4T1m_n_08g3zq3WTMbJwt2XlZILk3dAsQ,7508
35
+ lgr/flows/ocean.py,sha256=sU73v7Og4OKjiIjT9LV2bNH-Iu51WtSYNDr4NwW1eSs,7524
36
+ lgr/flows/registry.py,sha256=MyQwFZ8hggVyIjcT-uMwqJ7KYpMsGC9ZEruzrtoGU-U,1380
37
+ lgr/interpolation/__init__.py,sha256=I_olHjyRsfAzP6pObfDyOO1baN8kH7taq65sndbfkKE,331
38
+ lgr/interpolation/base.py,sha256=KPIZZbYzDtchpZLHJBLBVSU6aKfjHevSJaWyGZlxnU8,1907
39
+ lgr/interpolation/griddata_interp.py,sha256=4brSE5-hOS387gkohk8V5LJ1MhEPYJf4sJmnRx60Ix4,1533
40
+ lgr/interpolation/rbf.py,sha256=GvJAG8tUMgJFtyM58Gf-tXxQJy4bOiy7VTYeESPYIRw,3351
41
+ lgr/metrics/__init__.py,sha256=oQPUye81tLHD3BeNuY-tMj49h3FsJnlX5OlyYjubuBc,637
42
+ lgr/metrics/base.py,sha256=G6d6cBSMHHvYlm1HsEUAeGA6dh3_wYalHjCR9WA1N9I,2556
43
+ lgr/metrics/cauchy_green.py,sha256=-OHDL-85kU2sUrMT4xWE3Uel8hV0E4o9QwBHANYSXZA,2716
44
+ lgr/metrics/divergence.py,sha256=OZw1nB-wBklVTzt6MPTTqOyoYMK2WEwJOvMum4zBA3w,4933
45
+ lgr/metrics/dra.py,sha256=ZW2mS_E35jvQJZ5-H9cHMeqlAEu-iybkbyWtYPdkD6o,2371
46
+ lgr/metrics/ftle.py,sha256=oMYOZWuA5tNz3pbYBaczu9PH8zaYVB8z8j3WxcNFRoM,2704
47
+ lgr/metrics/lavd.py,sha256=PcvcAR9tBChY9wscqRSl7wcD1moUe2RYKyr7boXUr4I,2924
48
+ lgr/metrics/uncertainty.py,sha256=jaoEJantRZFROb9E8WIU3xapkALRP2ue8b-7imgGD_o,8301
49
+ lgr/metrics/vorticity.py,sha256=Y0OCKBcyy_ZkWSuimYMRgpfnVObA8lKiASYpY9xK0mA,5954
50
+ lgr/plotting/__init__.py,sha256=scVmNxYoUhLw5t_LBfkZ0piaqzQqdDML0RzLu2mKP3g,329
51
+ lgr/plotting/colormaps.py,sha256=gWK3WTqL3gZB0bfY37-sw7buIOapTbz22vfDawzZQ4A,4489
52
+ lgr/plotting/fields.py,sha256=oPydbVkbeEdaPSetdY92Pi9to62kppuh1A2pAUHWMAQ,3568
53
+ lgr/plotting/paper.py,sha256=gUSP7m2sf3ybPuhIeQHcbHHYI83h8s4c_tZjltaJfOA,11902
54
+ lgr/plotting/trajectories.py,sha256=I58JP-oqKWfl67b4GvnGsjpQWvc4VUAcTmZnyE-DvyM,1294
55
+ lgr/preprocessing/__init__.py,sha256=uwYL2hP6iR5NC7c0LKVWfbAuU7uX1QQWirJ2T-nxsiE,1786
56
+ lgr/preprocessing/jacobians.py,sha256=oIiJcD4O4FV_yz1DKaSg9oohyj72wFbcUUWxNWazy_I,8584
57
+ lgr/preprocessing/trajectories.py,sha256=7myF-xapNvQj_ocOLHnzvasRTBv7TyPQRjiPHmT1EpU,8369
58
+ lgr/regression/__init__.py,sha256=O8VWlWtx65sjkj1NTl_xUEHB4UJybT8fPu9z37a3ENo,2294
59
+ lgr/regression/base.py,sha256=EAFnUM4xWpWbfmw-uFJG5Un34uKDqbnlFgFOcnTPHRs,3950
60
+ lgr/regression/batched.py,sha256=5K_AomeAsyJye11Sz5E0N92P3kaUB_2jgf9Nz_9L9H4,50362
61
+ lgr/regression/epanechnikov.py,sha256=VqLrgnul5-s3TMas8dTTOMunSn9l_1ZtVVf3ppim5w4,2628
62
+ lgr/regression/gaussian.py,sha256=ybREJbw58cE-PlCbBnjslXKCFZZlKrKY8Fg1ZzJr3v0,2491
63
+ lgr/regression/gpr.py,sha256=kgqE2c-vnkZBMNw-9u1EqmZFzSwm8GEVq_bVA-buXmQ,5966
64
+ lgr/regression/jets.py,sha256=V4Pcuos7-5kOawcVc_gPpVPyLzWHy6l7-WVUZxAGfzc,11137
65
+ lgr/regression/lowess.py,sha256=CdO4e5w3NU8aRovga5vA9fK03rbZMnH8rmQN-CKSH2M,2885
66
+ lgr/regression/pseudoinverse.py,sha256=f3WKJ45IAqbq3Yr_kvF0p22D_3goG3jOweDdwBhbUXM,1575
67
+ lgr/regression/weights.py,sha256=DGM6I7GU6WAG4vj5GSn4ZHS_H5iuO64rUelpWZ6h5z4,14645
68
+ lagrangian_gradient_regression-0.1.0.dist-info/METADATA,sha256=F7NIBWZ6nHurgYRfc-UzlLtHUJ3iS7h6ZON8zGZ5hGo,8875
69
+ lagrangian_gradient_regression-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
70
+ lagrangian_gradient_regression-0.1.0.dist-info/licenses/LICENSE,sha256=CNFO41-GTn4-V-8a-I5ERsDnms7p-xW2nhr32gwI5dY,1069
71
+ lagrangian_gradient_regression-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Tanner Harms
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
lgr/__init__.py ADDED
@@ -0,0 +1,213 @@
1
+ """
2
+ LGR — Lagrangian Gradient Regression
3
+ =====================================
4
+
5
+ A modular Python package for estimating flow-map Jacobians from sparse
6
+ Lagrangian trajectory data and computing Lagrangian coherent structure (LCS)
7
+ diagnostics.
8
+
9
+ Reference
10
+ ---------
11
+ Harms, T. D., Brunton, S. L., & McKeon, B. J. (2024).
12
+ *Lagrangian gradient regression for the detection of coherent structures
13
+ from sparse trajectory data*. R. Soc. Open Sci. **11**, 240586.
14
+ https://doi.org/10.1098/rsos.240586
15
+ """
16
+
17
+ from __future__ import annotations
18
+
19
+ __version__ = "0.1.0"
20
+
21
+ # Core
22
+ from lgr.core.particle import Particle
23
+ from lgr.core.dataframe import generate_dataframe
24
+ from lgr.core.pipeline import compute_jacobians, compute_metrics, generate_fields
25
+ from lgr.array_api import (
26
+ DeformationResult,
27
+ ErrorResult,
28
+ MetricResult,
29
+ NeighborResult,
30
+ TrajectoryData,
31
+ as_trajectory_data,
32
+ build_knn_neighbors,
33
+ compute_lcs_metrics,
34
+ estimate_error,
35
+ fit_deformation,
36
+ fit_deformation_from_dataframe,
37
+ neighbors_from_dataframe,
38
+ trajectory_data_from_dataframe,
39
+ )
40
+
41
+ # Regression kernels
42
+ from lgr.regression.base import RegressionKernel
43
+ from lgr.regression.pseudoinverse import PseudoinverseRegression
44
+ from lgr.regression.gaussian import GaussianKernelRegression
45
+ from lgr.regression.epanechnikov import EpanechnikovRegression
46
+ from lgr.regression.lowess import LOWESSRegression
47
+ from lgr.regression.gpr import GPRegression
48
+ from lgr.regression import (
49
+ WEIGHT_KERNELS,
50
+ WeightSpec,
51
+ AnchoredGPDeformationRegression,
52
+ BootstrapDeformationEstimator,
53
+ BootstrapDeformationResult,
54
+ BootstrapResult,
55
+ LibraryDeformationRegression,
56
+ LibraryDeformationResult,
57
+ LocalLibraryDeformationResult,
58
+ ModelSelectionDeformationEstimator,
59
+ ModelSelectionDeformationResult,
60
+ PolynomialBasis,
61
+ PolynomialDeformationRegression,
62
+ # Deliberate compatibility re-export: a bare alias of
63
+ # `LocalLibraryDeformationResult`, importable but no longer
64
+ # advertised in `__all__`.
65
+ PolynomialDeformationResult as PolynomialDeformationResult,
66
+ degree_penalty,
67
+ effective_sample_size,
68
+ fit_anchored_gp_deformation,
69
+ fit_library_deformation,
70
+ neighbourhood_weights,
71
+ neighbourhood_weight_matrix,
72
+ psd_matrix_sqrt,
73
+ solve_weighted_ridge,
74
+ validate_psd_weight_matrix,
75
+ weight_matrix_effective_sample_size,
76
+ weighted_residual_rms,
77
+ )
78
+
79
+ # Metrics
80
+ from lgr.metrics.base import LagrangianMetric, get_metric, registered_metrics
81
+ from lgr.metrics.ftle import FTLEMetric
82
+ from lgr.metrics.lavd import LAVDMetric
83
+ from lgr.metrics.dra import DRAMetric
84
+ from lgr.metrics.vorticity import VorticityMetric
85
+ from lgr.metrics.cauchy_green import CauchyGreenTensor
86
+ from lgr.metrics.divergence import DivergenceMetric
87
+ from lgr.metrics.uncertainty import UncertaintyMetric
88
+
89
+ # Data ingestion
90
+ from lgr.data.ingestion import from_csv, from_parquet
91
+
92
+ # Preprocessing
93
+ from lgr.preprocessing import (
94
+ remove_outlier_particles,
95
+ smooth_trajectories,
96
+ remove_stalled_particles,
97
+ clip_to_domain,
98
+ filter_jacobians_by_det,
99
+ smooth_velocity_gradients,
100
+ filter_displacement_coherence,
101
+ )
102
+
103
+ # Flows
104
+ from lgr.flows.base import FlowBase
105
+ from lgr.flows.gyre import DoubleGyre
106
+ from lgr.flows.bickley_jet import BickleyJet
107
+ from lgr.flows.abc_flow import ABCFlow
108
+ from lgr.flows.ocean import GulfStreamJet
109
+ from lgr.flows.registry import get_flow, registered_flows
110
+
111
+ # Interpolation
112
+ from lgr.interpolation.base import Interpolator
113
+ from lgr.interpolation.griddata_interp import GridDataInterpolator
114
+ from lgr.interpolation.rbf import RBFInterpolator
115
+
116
+ #: The array-first API most users need. Everything else in ``__all__`` is
117
+ #: either a building block for these or a legacy DataFrame-era entry point.
118
+ PRIMARY_API: tuple[str, ...] = (
119
+ "TrajectoryData",
120
+ "build_knn_neighbors",
121
+ "fit_deformation",
122
+ "fit_library_deformation",
123
+ "fit_anchored_gp_deformation",
124
+ "compute_lcs_metrics",
125
+ "estimate_error",
126
+ )
127
+
128
+ __all__ = [
129
+ # Core
130
+ "Particle",
131
+ "generate_dataframe",
132
+ "compute_jacobians",
133
+ "compute_metrics",
134
+ "generate_fields",
135
+ "TrajectoryData",
136
+ "NeighborResult",
137
+ "DeformationResult",
138
+ "MetricResult",
139
+ "ErrorResult",
140
+ "as_trajectory_data",
141
+ "build_knn_neighbors",
142
+ "fit_deformation",
143
+ "compute_lcs_metrics",
144
+ "estimate_error",
145
+ "trajectory_data_from_dataframe",
146
+ "neighbors_from_dataframe",
147
+ "fit_deformation_from_dataframe",
148
+ # Regression
149
+ "RegressionKernel",
150
+ "PseudoinverseRegression",
151
+ "GaussianKernelRegression",
152
+ "EpanechnikovRegression",
153
+ "LOWESSRegression",
154
+ "GPRegression",
155
+ "PolynomialBasis",
156
+ "LibraryDeformationRegression",
157
+ "LocalLibraryDeformationResult",
158
+ "LibraryDeformationResult",
159
+ "PolynomialDeformationRegression",
160
+ "AnchoredGPDeformationRegression",
161
+ "BootstrapDeformationEstimator",
162
+ "BootstrapDeformationResult",
163
+ "BootstrapResult",
164
+ "ModelSelectionDeformationEstimator",
165
+ "ModelSelectionDeformationResult",
166
+ "fit_library_deformation",
167
+ "fit_anchored_gp_deformation",
168
+ "WEIGHT_KERNELS",
169
+ "WeightSpec",
170
+ "neighbourhood_weights",
171
+ "neighbourhood_weight_matrix",
172
+ "effective_sample_size",
173
+ "weight_matrix_effective_sample_size",
174
+ "weighted_residual_rms",
175
+ "degree_penalty",
176
+ "validate_psd_weight_matrix",
177
+ "psd_matrix_sqrt",
178
+ "solve_weighted_ridge",
179
+ # Metrics
180
+ "LagrangianMetric",
181
+ "FTLEMetric",
182
+ "LAVDMetric",
183
+ "DRAMetric",
184
+ "VorticityMetric",
185
+ "CauchyGreenTensor",
186
+ "DivergenceMetric",
187
+ "UncertaintyMetric",
188
+ "get_metric",
189
+ "registered_metrics",
190
+ # Flows
191
+ "FlowBase",
192
+ "DoubleGyre",
193
+ "BickleyJet",
194
+ "ABCFlow",
195
+ "GulfStreamJet",
196
+ "get_flow",
197
+ "registered_flows",
198
+ # Interpolation
199
+ "Interpolator",
200
+ "GridDataInterpolator",
201
+ "RBFInterpolator",
202
+ # Data ingestion
203
+ "from_csv",
204
+ "from_parquet",
205
+ # Preprocessing
206
+ "remove_outlier_particles",
207
+ "smooth_trajectories",
208
+ "remove_stalled_particles",
209
+ "clip_to_domain",
210
+ "filter_jacobians_by_det",
211
+ "smooth_velocity_gradients",
212
+ "filter_displacement_coherence",
213
+ ]