enufft 1.0.0__tar.gz

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 (35) hide show
  1. enufft-1.0.0/CITATION.cff +19 -0
  2. enufft-1.0.0/LICENSE +190 -0
  3. enufft-1.0.0/MANIFEST.in +10 -0
  4. enufft-1.0.0/NOTICE +15 -0
  5. enufft-1.0.0/PKG-INFO +232 -0
  6. enufft-1.0.0/README.md +198 -0
  7. enufft-1.0.0/docs/API.md +83 -0
  8. enufft-1.0.0/examples/polygon_enufft_demo.py +45 -0
  9. enufft-1.0.0/proof/figures/enufft_proof_ems.pdf +0 -0
  10. enufft-1.0.0/proof/figures/enufft_proof_ems.png +0 -0
  11. enufft-1.0.0/proof/figures/enufft_proof_nufft.pdf +0 -0
  12. enufft-1.0.0/proof/figures/enufft_proof_nufft.png +0 -0
  13. enufft-1.0.0/proof/figures/enufft_proof_polygon.pdf +0 -0
  14. enufft-1.0.0/proof/figures/enufft_proof_polygon.png +0 -0
  15. enufft-1.0.0/proof/figures/proof_summary.txt +7 -0
  16. enufft-1.0.0/pyproject.toml +54 -0
  17. enufft-1.0.0/scripts/make_proof_plots.py +381 -0
  18. enufft-1.0.0/setup.cfg +4 -0
  19. enufft-1.0.0/src/enufft/__init__.py +77 -0
  20. enufft-1.0.0/src/enufft/analysis.py +328 -0
  21. enufft-1.0.0/src/enufft/ems.py +365 -0
  22. enufft-1.0.0/src/enufft/geometry.py +346 -0
  23. enufft-1.0.0/src/enufft/nufft.py +307 -0
  24. enufft-1.0.0/src/enufft/plotting.py +66 -0
  25. enufft-1.0.0/src/enufft/synthetic.py +114 -0
  26. enufft-1.0.0/src/enufft.egg-info/PKG-INFO +232 -0
  27. enufft-1.0.0/src/enufft.egg-info/SOURCES.txt +33 -0
  28. enufft-1.0.0/src/enufft.egg-info/dependency_links.txt +1 -0
  29. enufft-1.0.0/src/enufft.egg-info/requires.txt +8 -0
  30. enufft-1.0.0/src/enufft.egg-info/top_level.txt +1 -0
  31. enufft-1.0.0/tests/test_analysis.py +35 -0
  32. enufft-1.0.0/tests/test_ems.py +43 -0
  33. enufft-1.0.0/tests/test_geometry.py +34 -0
  34. enufft-1.0.0/tests/test_nufft.py +51 -0
  35. enufft-1.0.0/tests/test_public_api.py +25 -0
@@ -0,0 +1,19 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use this framework in scholarly, published, or publicly distributed work, please cite it using these metadata."
3
+ title: "Elastic Non-Uniform FFT (ENUFFT)"
4
+ authors:
5
+ - family-names: "Banerjee"
6
+ given-names: "Tridib"
7
+ repository-code: "https://github.com/TridibBanerjee/Elastic-Non-Uniform-FFT"
8
+ url: "https://github.com/TridibBanerjee/Elastic-Non-Uniform-FFT"
9
+ doi: "10.5281/zenodo.20544458"
10
+ version: "1.0.0"
11
+ date-released: "2026-06-07"
12
+ license: "Apache-2.0"
13
+ keywords:
14
+ - nufft
15
+ - fourier
16
+ - terrain
17
+ - spectral-analysis
18
+ - elastic-mode-selection
19
+ abstract: "Elastic Non-Uniform FFT (ENUFFT) is a numerical framework for local Fourier analysis of irregular DEM samples and elastic mode selection."
enufft-1.0.0/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 Tridib Banerjee
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, this work
187
+ is distributed under the License on an "AS IS" BASIS, WITHOUT WARRANTIES
188
+ OR CONDITIONS OF ANY KIND, either express or implied. See the License
189
+ for the specific language governing permissions and limitations under
190
+ the License.
@@ -0,0 +1,10 @@
1
+ include README.md
2
+ include LICENSE
3
+ include NOTICE
4
+ include CITATION.cff
5
+ include pyproject.toml
6
+ include docs/API.md
7
+ recursive-include examples *.py
8
+ recursive-include proof/figures *.png *.pdf *.txt
9
+ recursive-include scripts *.py
10
+ recursive-include tests *.py
enufft-1.0.0/NOTICE ADDED
@@ -0,0 +1,15 @@
1
+ Elastic Non-Uniform FFT (ENUFFT)
2
+
3
+ Copyright 2026 Tridib Banerjee
4
+
5
+ ENUFFT is a numerical framework developed by Tridib Banerjee.
6
+ Redistributions and derivative works must retain the applicable copyright,
7
+ license, and attribution notices for this framework.
8
+
9
+ If this framework is used to produce scholarly, published, or publicly
10
+ distributed results, please cite the ENUFFT paper and/or the repository
11
+ citation metadata in CITATION.cff.
12
+
13
+ The PinCFlow-EMS submodule is a separate project with its own license. See
14
+ https://github.com/TridibBanerjee/PinCFlow-EMS/blob/EMS/LICENSE.md for the
15
+ license terms that apply to that submodule.
enufft-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,232 @@
1
+ Metadata-Version: 2.4
2
+ Name: enufft
3
+ Version: 1.0.0
4
+ Summary: Elastic non-uniform FFT and elastic mode selection for polygonal terrain windows.
5
+ Author: Tridib Banerjee
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/TridibBanerjee/Elastic-Non-Uniform-FFT
8
+ Project-URL: Source, https://github.com/TridibBanerjee/Elastic-Non-Uniform-FFT
9
+ Project-URL: Issues, https://github.com/TridibBanerjee/Elastic-Non-Uniform-FFT/issues
10
+ Project-URL: DOI, https://doi.org/10.5281/zenodo.20544458
11
+ Keywords: nufft,fourier,terrain,orography,spectral-analysis
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Programming Language :: Python :: 3 :: Only
21
+ Classifier: Topic :: Scientific/Engineering
22
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
23
+ Requires-Python: >=3.10
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ License-File: NOTICE
27
+ Requires-Dist: numpy>=1.24
28
+ Requires-Dist: scipy>=1.10
29
+ Provides-Extra: test
30
+ Requires-Dist: pytest>=8.0; extra == "test"
31
+ Provides-Extra: plots
32
+ Requires-Dist: matplotlib>=3.7; extra == "plots"
33
+ Dynamic: license-file
34
+
35
+ # ENUFFT
36
+
37
+ [![PyPI](https://img.shields.io/pypi/v/enufft.svg)](https://pypi.org/project/enufft/)
38
+ [![Python](https://img.shields.io/pypi/pyversions/enufft.svg)](https://pypi.org/project/enufft/)
39
+ [![License](https://img.shields.io/badge/License-Apache--2.0-red.svg)](https://github.com/TridibBanerjee/Elastic-Non-Uniform-FFT/blob/main/package/LICENSE)
40
+ [![DOI](https://img.shields.io/badge/DOI-10.5281%2Fzenodo.20544458-blue.svg)](https://doi.org/10.5281/zenodo.20544458)
41
+
42
+ **ENUFFT** is a Python package for local Fourier analysis on irregularly sampled
43
+ terrain, polygonal cells, and other scattered two-dimensional fields.
44
+
45
+ It combines two pieces of the Elastic Non-Uniform FFT framework:
46
+
47
+ - A Kaiser-Bessel non-uniform FFT path for estimating local Fourier
48
+ coefficients directly from scattered samples.
49
+ - Elastic Mode Selection (EMS), which compresses the spectrum to an adaptive
50
+ number of physically paired retained modes.
51
+
52
+ The canonical research repository, derivation, case studies, and citation
53
+ metadata live at
54
+ [TridibBanerjee/Elastic-Non-Uniform-FFT](https://github.com/TridibBanerjee/Elastic-Non-Uniform-FFT).
55
+
56
+ ## Install
57
+
58
+ ```bash
59
+ pip install enufft
60
+ ```
61
+
62
+ Optional extras:
63
+
64
+ ```bash
65
+ pip install "enufft[plots]"
66
+ pip install "enufft[test]"
67
+ ```
68
+
69
+ Install the package directly from the repository:
70
+
71
+ ```bash
72
+ pip install "git+https://github.com/TridibBanerjee/Elastic-Non-Uniform-FFT.git#subdirectory=package"
73
+ ```
74
+
75
+ ENUFFT requires Python 3.10 or newer, NumPy, and SciPy.
76
+
77
+ ## Quick Start
78
+
79
+ ```python
80
+ import numpy as np
81
+ from enufft import EMSConfig, WindowConfig, enufft_on_polygon
82
+
83
+ polygon = np.array([
84
+ [0.10, 0.16],
85
+ [1.35, 0.02],
86
+ [1.72, 0.82],
87
+ [1.05, 1.55],
88
+ [0.16, 1.18],
89
+ ])
90
+
91
+ rng = np.random.default_rng(8)
92
+ points = rng.uniform([-0.45, -0.45], [2.05, 2.05], size=(3600, 2))
93
+ values = np.cos(2.0 * np.pi * (3.0 * points[:, 0] + 2.0 * points[:, 1]))
94
+
95
+ result = enufft_on_polygon(
96
+ points,
97
+ values,
98
+ polygon,
99
+ mode_limit=6,
100
+ window_config=WindowConfig(
101
+ support="square",
102
+ alignment="centroid",
103
+ expansion=1.42,
104
+ ),
105
+ ems_config=EMSConfig(k_min=1, k_max=6, alpha_min=0.0, alpha_max=0.78),
106
+ weight_type="voronoi",
107
+ )
108
+
109
+ print(result.selected_modes)
110
+ print(result.mode_pair_count, result.signed_mode_count)
111
+ print(result.power_retained)
112
+ ```
113
+
114
+ ## What You Get
115
+
116
+ - Exact scattered-point DFT coefficients for reference calculations.
117
+ - Kaiser-Bessel NUFFT coefficient blocks for faster local spectral analysis.
118
+ - Polygon-derived square analysis windows with square, polygon, or circular
119
+ sample supports.
120
+ - Uniform or local Voronoi-style quadrature weights.
121
+ - EMS diagnostics for any nonnegative spectrum.
122
+ - Pair-aware EMS for signed Fourier coefficient blocks.
123
+ - Sparse inverse reconstruction at arbitrary local coordinates.
124
+
125
+ ## Public API
126
+
127
+ The most useful entry points are:
128
+
129
+ | Function or class | Purpose |
130
+ | --- | --- |
131
+ | `enufft_on_polygon` | Compute polygon-windowed NUFFT coefficients and apply EMS. |
132
+ | `nufft_on_polygon` | Compute the raw polygon-windowed NUFFT coefficient block. |
133
+ | `compute_nufft_coefficients` | Compute a Kaiser-Bessel NUFFT block from explicit samples and modes. |
134
+ | `compute_direct_dft_coefficients` | Compute the exact scattered direct DFT block. |
135
+ | `elastic_mode_selection` | Run EMS on a one-dimensional nonnegative spectrum. |
136
+ | `select_sparse_conjugate_modes` | Apply EMS to signed Fourier coefficients by conjugate mode pair. |
137
+ | `reconstruct_at_points` | Evaluate an inverse Fourier series at local coordinates. |
138
+ | `WindowConfig`, `NUFFTConfig`, `EMSConfig` | Configure windowing, NUFFT, and EMS behavior. |
139
+
140
+ See the
141
+ [API notes](https://github.com/TridibBanerjee/Elastic-Non-Uniform-FFT/blob/main/package/docs/API.md)
142
+ for additional examples.
143
+
144
+ ## EMS On A Supplied Spectrum
145
+
146
+ ```python
147
+ import numpy as np
148
+ from enufft import EMSConfig, elastic_mode_selection
149
+
150
+ energy = np.array([10.0, 3.0, 1.0, 0.4, 0.1])
151
+ diagnostics = elastic_mode_selection(
152
+ energy,
153
+ EMSConfig(k_min=1, k_max=5, alpha_min=0.0, alpha_max=0.7),
154
+ )
155
+
156
+ print(diagnostics.retain_count("pairs"))
157
+ print(diagnostics.retain_count("signed"))
158
+ ```
159
+
160
+ ## Coefficient Convention
161
+
162
+ ENUFFT follows the sample-mean Fourier convention used by the research code:
163
+
164
+ ```text
165
+ h_hat[m, n] = mean_q h_q exp[-i(k_m x_q + l_n y_q)]
166
+ k_m = 2 pi m / Lx
167
+ l_n = 2 pi n / Ly
168
+ ```
169
+
170
+ Optional sample weights are normalized into the same sample-mean convention
171
+ before direct DFT or NUFFT evaluation.
172
+
173
+ ## Method
174
+
175
+ The NUFFT path spreads irregular samples to an oversampled auxiliary grid with a
176
+ compact Kaiser-Bessel kernel, applies `fft2`, deconvolves the kernel transform,
177
+ and extracts the requested signed mode block.
178
+
179
+ EMS sorts nonnegative mode or pair energies, computes a participation-ratio
180
+ effective count, measures local spectral smoothness from adjacent energy gaps,
181
+ and selects the smallest admissible retained count that satisfies the resulting
182
+ adaptive retained-power target.
183
+
184
+ For signed Fourier coefficient blocks, non-DC modes are grouped as conjugate
185
+ pairs `(m, n)` and `(-m, -n)`. Retaining both signs keeps inverse
186
+ reconstructions real-valued and keeps energy accounting consistent.
187
+
188
+ ## Validation Figures
189
+
190
+ The repository includes proof plots generated from synthetic fields and
191
+ polygonal cells.
192
+
193
+ The NUFFT proof compares accelerated coefficients against exact direct DFT
194
+ coefficients across three synthetic terrain fields.
195
+
196
+ ![NUFFT proof](https://raw.githubusercontent.com/TridibBanerjee/Elastic-Non-Uniform-FFT/main/package/proof/figures/enufft_proof_nufft.png)
197
+
198
+ The EMS proof evaluates the retained-count rule across analytical spectra. The
199
+ red dashed line marks the selected retained count.
200
+
201
+ ![EMS proof](https://raw.githubusercontent.com/TridibBanerjee/Elastic-Non-Uniform-FFT/main/package/proof/figures/enufft_proof_ems.png)
202
+
203
+ The polygon proof shows the supplied samples, raw Fourier block, EMS-selected
204
+ pair, sparse reconstruction, and sorted pair-energy decay for one polygonal
205
+ cell.
206
+
207
+ ![Polygon proof](https://raw.githubusercontent.com/TridibBanerjee/Elastic-Non-Uniform-FFT/main/package/proof/figures/enufft_proof_polygon.png)
208
+
209
+ Regenerate the proof artifacts from a source checkout with:
210
+
211
+ ```bash
212
+ python package/scripts/make_proof_plots.py
213
+ ```
214
+
215
+ ## Citation
216
+
217
+ If you use ENUFFT in scholarly, published, or publicly distributed work, cite
218
+ the framework metadata in
219
+ [CITATION.cff](https://github.com/TridibBanerjee/Elastic-Non-Uniform-FFT/blob/main/package/CITATION.cff):
220
+
221
+ ```text
222
+ Banerjee, Tridib. Elastic Non-Uniform FFT (ENUFFT).
223
+ https://github.com/TridibBanerjee/Elastic-Non-Uniform-FFT
224
+ DOI: 10.5281/zenodo.20544458
225
+ ```
226
+
227
+ ## License
228
+
229
+ Released under the Apache License 2.0. See
230
+ [LICENSE](https://github.com/TridibBanerjee/Elastic-Non-Uniform-FFT/blob/main/package/LICENSE)
231
+ and
232
+ [NOTICE](https://github.com/TridibBanerjee/Elastic-Non-Uniform-FFT/blob/main/package/NOTICE).
enufft-1.0.0/README.md ADDED
@@ -0,0 +1,198 @@
1
+ # ENUFFT
2
+
3
+ [![PyPI](https://img.shields.io/pypi/v/enufft.svg)](https://pypi.org/project/enufft/)
4
+ [![Python](https://img.shields.io/pypi/pyversions/enufft.svg)](https://pypi.org/project/enufft/)
5
+ [![License](https://img.shields.io/badge/License-Apache--2.0-red.svg)](https://github.com/TridibBanerjee/Elastic-Non-Uniform-FFT/blob/main/package/LICENSE)
6
+ [![DOI](https://img.shields.io/badge/DOI-10.5281%2Fzenodo.20544458-blue.svg)](https://doi.org/10.5281/zenodo.20544458)
7
+
8
+ **ENUFFT** is a Python package for local Fourier analysis on irregularly sampled
9
+ terrain, polygonal cells, and other scattered two-dimensional fields.
10
+
11
+ It combines two pieces of the Elastic Non-Uniform FFT framework:
12
+
13
+ - A Kaiser-Bessel non-uniform FFT path for estimating local Fourier
14
+ coefficients directly from scattered samples.
15
+ - Elastic Mode Selection (EMS), which compresses the spectrum to an adaptive
16
+ number of physically paired retained modes.
17
+
18
+ The canonical research repository, derivation, case studies, and citation
19
+ metadata live at
20
+ [TridibBanerjee/Elastic-Non-Uniform-FFT](https://github.com/TridibBanerjee/Elastic-Non-Uniform-FFT).
21
+
22
+ ## Install
23
+
24
+ ```bash
25
+ pip install enufft
26
+ ```
27
+
28
+ Optional extras:
29
+
30
+ ```bash
31
+ pip install "enufft[plots]"
32
+ pip install "enufft[test]"
33
+ ```
34
+
35
+ Install the package directly from the repository:
36
+
37
+ ```bash
38
+ pip install "git+https://github.com/TridibBanerjee/Elastic-Non-Uniform-FFT.git#subdirectory=package"
39
+ ```
40
+
41
+ ENUFFT requires Python 3.10 or newer, NumPy, and SciPy.
42
+
43
+ ## Quick Start
44
+
45
+ ```python
46
+ import numpy as np
47
+ from enufft import EMSConfig, WindowConfig, enufft_on_polygon
48
+
49
+ polygon = np.array([
50
+ [0.10, 0.16],
51
+ [1.35, 0.02],
52
+ [1.72, 0.82],
53
+ [1.05, 1.55],
54
+ [0.16, 1.18],
55
+ ])
56
+
57
+ rng = np.random.default_rng(8)
58
+ points = rng.uniform([-0.45, -0.45], [2.05, 2.05], size=(3600, 2))
59
+ values = np.cos(2.0 * np.pi * (3.0 * points[:, 0] + 2.0 * points[:, 1]))
60
+
61
+ result = enufft_on_polygon(
62
+ points,
63
+ values,
64
+ polygon,
65
+ mode_limit=6,
66
+ window_config=WindowConfig(
67
+ support="square",
68
+ alignment="centroid",
69
+ expansion=1.42,
70
+ ),
71
+ ems_config=EMSConfig(k_min=1, k_max=6, alpha_min=0.0, alpha_max=0.78),
72
+ weight_type="voronoi",
73
+ )
74
+
75
+ print(result.selected_modes)
76
+ print(result.mode_pair_count, result.signed_mode_count)
77
+ print(result.power_retained)
78
+ ```
79
+
80
+ ## What You Get
81
+
82
+ - Exact scattered-point DFT coefficients for reference calculations.
83
+ - Kaiser-Bessel NUFFT coefficient blocks for faster local spectral analysis.
84
+ - Polygon-derived square analysis windows with square, polygon, or circular
85
+ sample supports.
86
+ - Uniform or local Voronoi-style quadrature weights.
87
+ - EMS diagnostics for any nonnegative spectrum.
88
+ - Pair-aware EMS for signed Fourier coefficient blocks.
89
+ - Sparse inverse reconstruction at arbitrary local coordinates.
90
+
91
+ ## Public API
92
+
93
+ The most useful entry points are:
94
+
95
+ | Function or class | Purpose |
96
+ | --- | --- |
97
+ | `enufft_on_polygon` | Compute polygon-windowed NUFFT coefficients and apply EMS. |
98
+ | `nufft_on_polygon` | Compute the raw polygon-windowed NUFFT coefficient block. |
99
+ | `compute_nufft_coefficients` | Compute a Kaiser-Bessel NUFFT block from explicit samples and modes. |
100
+ | `compute_direct_dft_coefficients` | Compute the exact scattered direct DFT block. |
101
+ | `elastic_mode_selection` | Run EMS on a one-dimensional nonnegative spectrum. |
102
+ | `select_sparse_conjugate_modes` | Apply EMS to signed Fourier coefficients by conjugate mode pair. |
103
+ | `reconstruct_at_points` | Evaluate an inverse Fourier series at local coordinates. |
104
+ | `WindowConfig`, `NUFFTConfig`, `EMSConfig` | Configure windowing, NUFFT, and EMS behavior. |
105
+
106
+ See the
107
+ [API notes](https://github.com/TridibBanerjee/Elastic-Non-Uniform-FFT/blob/main/package/docs/API.md)
108
+ for additional examples.
109
+
110
+ ## EMS On A Supplied Spectrum
111
+
112
+ ```python
113
+ import numpy as np
114
+ from enufft import EMSConfig, elastic_mode_selection
115
+
116
+ energy = np.array([10.0, 3.0, 1.0, 0.4, 0.1])
117
+ diagnostics = elastic_mode_selection(
118
+ energy,
119
+ EMSConfig(k_min=1, k_max=5, alpha_min=0.0, alpha_max=0.7),
120
+ )
121
+
122
+ print(diagnostics.retain_count("pairs"))
123
+ print(diagnostics.retain_count("signed"))
124
+ ```
125
+
126
+ ## Coefficient Convention
127
+
128
+ ENUFFT follows the sample-mean Fourier convention used by the research code:
129
+
130
+ ```text
131
+ h_hat[m, n] = mean_q h_q exp[-i(k_m x_q + l_n y_q)]
132
+ k_m = 2 pi m / Lx
133
+ l_n = 2 pi n / Ly
134
+ ```
135
+
136
+ Optional sample weights are normalized into the same sample-mean convention
137
+ before direct DFT or NUFFT evaluation.
138
+
139
+ ## Method
140
+
141
+ The NUFFT path spreads irregular samples to an oversampled auxiliary grid with a
142
+ compact Kaiser-Bessel kernel, applies `fft2`, deconvolves the kernel transform,
143
+ and extracts the requested signed mode block.
144
+
145
+ EMS sorts nonnegative mode or pair energies, computes a participation-ratio
146
+ effective count, measures local spectral smoothness from adjacent energy gaps,
147
+ and selects the smallest admissible retained count that satisfies the resulting
148
+ adaptive retained-power target.
149
+
150
+ For signed Fourier coefficient blocks, non-DC modes are grouped as conjugate
151
+ pairs `(m, n)` and `(-m, -n)`. Retaining both signs keeps inverse
152
+ reconstructions real-valued and keeps energy accounting consistent.
153
+
154
+ ## Validation Figures
155
+
156
+ The repository includes proof plots generated from synthetic fields and
157
+ polygonal cells.
158
+
159
+ The NUFFT proof compares accelerated coefficients against exact direct DFT
160
+ coefficients across three synthetic terrain fields.
161
+
162
+ ![NUFFT proof](https://raw.githubusercontent.com/TridibBanerjee/Elastic-Non-Uniform-FFT/main/package/proof/figures/enufft_proof_nufft.png)
163
+
164
+ The EMS proof evaluates the retained-count rule across analytical spectra. The
165
+ red dashed line marks the selected retained count.
166
+
167
+ ![EMS proof](https://raw.githubusercontent.com/TridibBanerjee/Elastic-Non-Uniform-FFT/main/package/proof/figures/enufft_proof_ems.png)
168
+
169
+ The polygon proof shows the supplied samples, raw Fourier block, EMS-selected
170
+ pair, sparse reconstruction, and sorted pair-energy decay for one polygonal
171
+ cell.
172
+
173
+ ![Polygon proof](https://raw.githubusercontent.com/TridibBanerjee/Elastic-Non-Uniform-FFT/main/package/proof/figures/enufft_proof_polygon.png)
174
+
175
+ Regenerate the proof artifacts from a source checkout with:
176
+
177
+ ```bash
178
+ python package/scripts/make_proof_plots.py
179
+ ```
180
+
181
+ ## Citation
182
+
183
+ If you use ENUFFT in scholarly, published, or publicly distributed work, cite
184
+ the framework metadata in
185
+ [CITATION.cff](https://github.com/TridibBanerjee/Elastic-Non-Uniform-FFT/blob/main/package/CITATION.cff):
186
+
187
+ ```text
188
+ Banerjee, Tridib. Elastic Non-Uniform FFT (ENUFFT).
189
+ https://github.com/TridibBanerjee/Elastic-Non-Uniform-FFT
190
+ DOI: 10.5281/zenodo.20544458
191
+ ```
192
+
193
+ ## License
194
+
195
+ Released under the Apache License 2.0. See
196
+ [LICENSE](https://github.com/TridibBanerjee/Elastic-Non-Uniform-FFT/blob/main/package/LICENSE)
197
+ and
198
+ [NOTICE](https://github.com/TridibBanerjee/Elastic-Non-Uniform-FFT/blob/main/package/NOTICE).