noise-gating 0.1.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.
@@ -0,0 +1,84 @@
1
+ # Builds wheels for Linux, macOS and Windows, tests them, and publishes to PyPI
2
+ # when a version tag (v*) is pushed.
3
+ #
4
+ # Publishing uses PyPI trusted publishing: on pypi.org, add a "pending publisher"
5
+ # for project `noise-gating` with this repository, workflow `wheels.yml` and
6
+ # environment `pypi`. No API token is needed.
7
+ name: wheels
8
+
9
+ on:
10
+ push:
11
+ branches: [master]
12
+ tags: ["v*"]
13
+ pull_request:
14
+ workflow_dispatch:
15
+
16
+ permissions:
17
+ contents: read
18
+
19
+ jobs:
20
+ wheels:
21
+ name: wheel ${{ matrix.platform.name }}
22
+ runs-on: ${{ matrix.platform.runner }}
23
+ strategy:
24
+ fail-fast: false
25
+ matrix:
26
+ platform:
27
+ - { name: linux-x86_64, runner: ubuntu-latest, target: x86_64, manylinux: auto }
28
+ - { name: linux-aarch64, runner: ubuntu-24.04-arm, target: aarch64, manylinux: auto }
29
+ - { name: macos-x86_64, runner: macos-15-intel, target: x86_64 }
30
+ - { name: macos-arm64, runner: macos-latest, target: aarch64 }
31
+ - { name: windows-x86_64, runner: windows-latest, target: x64 }
32
+ steps:
33
+ - uses: actions/checkout@v4
34
+ - uses: actions/setup-python@v5
35
+ with:
36
+ python-version: "3.12"
37
+ - name: Build wheel
38
+ uses: PyO3/maturin-action@v1
39
+ with:
40
+ target: ${{ matrix.platform.target }}
41
+ manylinux: ${{ matrix.platform.manylinux }}
42
+ args: --release --out dist
43
+ - name: Test wheel
44
+ shell: bash
45
+ env:
46
+ TQDM_DISABLE: "1"
47
+ run: |
48
+ python -m pip install dist/*.whl pytest
49
+ cd tests # import the installed package, not the source tree
50
+ python -c "import noisegate; assert noisegate.rust_available(), 'Rust backend missing from wheel'"
51
+ python -m pytest -q .
52
+ - uses: actions/upload-artifact@v4
53
+ with:
54
+ name: wheel-${{ matrix.platform.name }}
55
+ path: dist/*.whl
56
+
57
+ sdist:
58
+ runs-on: ubuntu-latest
59
+ steps:
60
+ - uses: actions/checkout@v4
61
+ - name: Build sdist
62
+ uses: PyO3/maturin-action@v1
63
+ with:
64
+ command: sdist
65
+ args: --out dist
66
+ - uses: actions/upload-artifact@v4
67
+ with:
68
+ name: sdist
69
+ path: dist/*.tar.gz
70
+
71
+ publish:
72
+ name: Publish to PyPI
73
+ if: startsWith(github.ref, 'refs/tags/v')
74
+ needs: [wheels, sdist]
75
+ runs-on: ubuntu-latest
76
+ environment: pypi
77
+ permissions:
78
+ id-token: write
79
+ steps:
80
+ - uses: actions/download-artifact@v4
81
+ with:
82
+ path: dist
83
+ merge-multiple: true
84
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,4 @@
1
+ target/
2
+ __pycache__/
3
+ *.so
4
+ .pytest_cache/
@@ -0,0 +1,320 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 4
4
+
5
+ [[package]]
6
+ name = "autocfg"
7
+ version = "1.5.1"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
10
+
11
+ [[package]]
12
+ name = "crossbeam-deque"
13
+ version = "0.8.8"
14
+ source = "registry+https://github.com/rust-lang/crates.io-index"
15
+ checksum = "622f3fc73690be383c7214310406f28a90e6edeadc3cea882f9d71e495b9711a"
16
+ dependencies = [
17
+ "crossbeam-epoch",
18
+ "crossbeam-utils",
19
+ ]
20
+
21
+ [[package]]
22
+ name = "crossbeam-epoch"
23
+ version = "0.9.21"
24
+ source = "registry+https://github.com/rust-lang/crates.io-index"
25
+ checksum = "dc74980687109a3b14c72fd458107bf0baa1da1a1a805e178d15501ba9b86d9d"
26
+ dependencies = [
27
+ "crossbeam-utils",
28
+ ]
29
+
30
+ [[package]]
31
+ name = "crossbeam-utils"
32
+ version = "0.8.23"
33
+ source = "registry+https://github.com/rust-lang/crates.io-index"
34
+ checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6"
35
+
36
+ [[package]]
37
+ name = "either"
38
+ version = "1.19.0"
39
+ source = "registry+https://github.com/rust-lang/crates.io-index"
40
+ checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be"
41
+
42
+ [[package]]
43
+ name = "heck"
44
+ version = "0.5.0"
45
+ source = "registry+https://github.com/rust-lang/crates.io-index"
46
+ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
47
+
48
+ [[package]]
49
+ name = "libc"
50
+ version = "0.2.191"
51
+ source = "registry+https://github.com/rust-lang/crates.io-index"
52
+ checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
53
+
54
+ [[package]]
55
+ name = "matrixmultiply"
56
+ version = "0.3.11"
57
+ source = "registry+https://github.com/rust-lang/crates.io-index"
58
+ checksum = "3f607c237553f086e7043417a51df26b2eb899d3caff94e6a67592ff992fedc7"
59
+ dependencies = [
60
+ "autocfg",
61
+ "rawpointer",
62
+ ]
63
+
64
+ [[package]]
65
+ name = "ndarray"
66
+ version = "0.17.2"
67
+ source = "registry+https://github.com/rust-lang/crates.io-index"
68
+ checksum = "520080814a7a6b4a6e9070823bb24b4531daac8c4627e08ba5de8c5ef2f2752d"
69
+ dependencies = [
70
+ "matrixmultiply",
71
+ "num-complex",
72
+ "num-integer",
73
+ "num-traits",
74
+ "portable-atomic",
75
+ "portable-atomic-util",
76
+ "rawpointer",
77
+ ]
78
+
79
+ [[package]]
80
+ name = "noisegate_rs"
81
+ version = "0.1.0"
82
+ dependencies = [
83
+ "numpy",
84
+ "pyo3",
85
+ "rayon",
86
+ "rustfft",
87
+ ]
88
+
89
+ [[package]]
90
+ name = "num-complex"
91
+ version = "0.4.6"
92
+ source = "registry+https://github.com/rust-lang/crates.io-index"
93
+ checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"
94
+ dependencies = [
95
+ "num-traits",
96
+ ]
97
+
98
+ [[package]]
99
+ name = "num-integer"
100
+ version = "0.1.47"
101
+ source = "registry+https://github.com/rust-lang/crates.io-index"
102
+ checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b"
103
+ dependencies = [
104
+ "num-traits",
105
+ ]
106
+
107
+ [[package]]
108
+ name = "num-traits"
109
+ version = "0.2.19"
110
+ source = "registry+https://github.com/rust-lang/crates.io-index"
111
+ checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
112
+ dependencies = [
113
+ "autocfg",
114
+ ]
115
+
116
+ [[package]]
117
+ name = "numpy"
118
+ version = "0.30.0"
119
+ source = "registry+https://github.com/rust-lang/crates.io-index"
120
+ checksum = "aa0b9111761885449e894981fa8051dcf69e0bd114aecbd4bcdd830b6be4ed92"
121
+ dependencies = [
122
+ "libc",
123
+ "ndarray",
124
+ "num-complex",
125
+ "num-integer",
126
+ "num-traits",
127
+ "pyo3",
128
+ "pyo3-build-config",
129
+ "rustc-hash",
130
+ ]
131
+
132
+ [[package]]
133
+ name = "once_cell"
134
+ version = "1.21.4"
135
+ source = "registry+https://github.com/rust-lang/crates.io-index"
136
+ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
137
+
138
+ [[package]]
139
+ name = "portable-atomic"
140
+ version = "1.15.0"
141
+ source = "registry+https://github.com/rust-lang/crates.io-index"
142
+ checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
143
+
144
+ [[package]]
145
+ name = "portable-atomic-util"
146
+ version = "0.2.8"
147
+ source = "registry+https://github.com/rust-lang/crates.io-index"
148
+ checksum = "10ab3eb7f3becc3a1cbc4f2c6f20267996cfc1a6467a873763411b136a122715"
149
+ dependencies = [
150
+ "portable-atomic",
151
+ ]
152
+
153
+ [[package]]
154
+ name = "primal-check"
155
+ version = "0.3.4"
156
+ source = "registry+https://github.com/rust-lang/crates.io-index"
157
+ checksum = "dc0d895b311e3af9902528fbb8f928688abbd95872819320517cc24ca6b2bd08"
158
+ dependencies = [
159
+ "num-integer",
160
+ ]
161
+
162
+ [[package]]
163
+ name = "proc-macro2"
164
+ version = "1.0.107"
165
+ source = "registry+https://github.com/rust-lang/crates.io-index"
166
+ checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
167
+ dependencies = [
168
+ "unicode-ident",
169
+ ]
170
+
171
+ [[package]]
172
+ name = "pyo3"
173
+ version = "0.30.1"
174
+ source = "registry+https://github.com/rust-lang/crates.io-index"
175
+ checksum = "229ca13b8a15bb0d1487b81ab975bfcd97513416499a8312011b6036e42e0de4"
176
+ dependencies = [
177
+ "libc",
178
+ "once_cell",
179
+ "portable-atomic",
180
+ "pyo3-build-config",
181
+ "pyo3-ffi",
182
+ "pyo3-macros",
183
+ ]
184
+
185
+ [[package]]
186
+ name = "pyo3-build-config"
187
+ version = "0.30.1"
188
+ source = "registry+https://github.com/rust-lang/crates.io-index"
189
+ checksum = "70130e2b6dd1ee589a8788026a429561ca5c40fa7a2fa7914c2282eddae24700"
190
+ dependencies = [
191
+ "target-lexicon",
192
+ ]
193
+
194
+ [[package]]
195
+ name = "pyo3-ffi"
196
+ version = "0.30.1"
197
+ source = "registry+https://github.com/rust-lang/crates.io-index"
198
+ checksum = "5e7ff73c555c286d212d4ce7e5fbda845a973c4f61bd5f160f5f2c3c2a04d1c4"
199
+ dependencies = [
200
+ "libc",
201
+ "pyo3-build-config",
202
+ ]
203
+
204
+ [[package]]
205
+ name = "pyo3-macros"
206
+ version = "0.30.1"
207
+ source = "registry+https://github.com/rust-lang/crates.io-index"
208
+ checksum = "c46d2e5862c7bb8207e3b639f713dda3c499933444784154c11d013c5a691b60"
209
+ dependencies = [
210
+ "proc-macro2",
211
+ "pyo3-macros-backend",
212
+ "quote",
213
+ "syn",
214
+ ]
215
+
216
+ [[package]]
217
+ name = "pyo3-macros-backend"
218
+ version = "0.30.1"
219
+ source = "registry+https://github.com/rust-lang/crates.io-index"
220
+ checksum = "38b89f066f2ae72a2aef52d1537ca2fcd104440ebfadee06e97aa90738a25b9b"
221
+ dependencies = [
222
+ "heck",
223
+ "proc-macro2",
224
+ "quote",
225
+ "syn",
226
+ ]
227
+
228
+ [[package]]
229
+ name = "quote"
230
+ version = "1.0.47"
231
+ source = "registry+https://github.com/rust-lang/crates.io-index"
232
+ checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
233
+ dependencies = [
234
+ "proc-macro2",
235
+ ]
236
+
237
+ [[package]]
238
+ name = "rawpointer"
239
+ version = "0.2.1"
240
+ source = "registry+https://github.com/rust-lang/crates.io-index"
241
+ checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3"
242
+
243
+ [[package]]
244
+ name = "rayon"
245
+ version = "1.12.0"
246
+ source = "registry+https://github.com/rust-lang/crates.io-index"
247
+ checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d"
248
+ dependencies = [
249
+ "either",
250
+ "rayon-core",
251
+ ]
252
+
253
+ [[package]]
254
+ name = "rayon-core"
255
+ version = "1.13.0"
256
+ source = "registry+https://github.com/rust-lang/crates.io-index"
257
+ checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91"
258
+ dependencies = [
259
+ "crossbeam-deque",
260
+ "crossbeam-utils",
261
+ ]
262
+
263
+ [[package]]
264
+ name = "rustc-hash"
265
+ version = "2.1.3"
266
+ source = "registry+https://github.com/rust-lang/crates.io-index"
267
+ checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d"
268
+
269
+ [[package]]
270
+ name = "rustfft"
271
+ version = "6.4.1"
272
+ source = "registry+https://github.com/rust-lang/crates.io-index"
273
+ checksum = "21db5f9893e91f41798c88680037dba611ca6674703c1a18601b01a72c8adb89"
274
+ dependencies = [
275
+ "num-complex",
276
+ "num-integer",
277
+ "num-traits",
278
+ "primal-check",
279
+ "strength_reduce",
280
+ "transpose",
281
+ ]
282
+
283
+ [[package]]
284
+ name = "strength_reduce"
285
+ version = "0.2.4"
286
+ source = "registry+https://github.com/rust-lang/crates.io-index"
287
+ checksum = "fe895eb47f22e2ddd4dabc02bce419d2e643c8e3b585c78158b349195bc24d82"
288
+
289
+ [[package]]
290
+ name = "syn"
291
+ version = "3.0.10"
292
+ source = "registry+https://github.com/rust-lang/crates.io-index"
293
+ checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
294
+ dependencies = [
295
+ "proc-macro2",
296
+ "quote",
297
+ "unicode-ident",
298
+ ]
299
+
300
+ [[package]]
301
+ name = "target-lexicon"
302
+ version = "0.13.6"
303
+ source = "registry+https://github.com/rust-lang/crates.io-index"
304
+ checksum = "8c447be3a2abfa84b2d91680c56600bd6b2873866de27b36ec911be705e291da"
305
+
306
+ [[package]]
307
+ name = "transpose"
308
+ version = "0.2.3"
309
+ source = "registry+https://github.com/rust-lang/crates.io-index"
310
+ checksum = "1ad61aed86bc3faea4300c7aee358b4c6d0c8d6ccc36524c96e4c92ccf26e77e"
311
+ dependencies = [
312
+ "num-integer",
313
+ "strength_reduce",
314
+ ]
315
+
316
+ [[package]]
317
+ name = "unicode-ident"
318
+ version = "1.0.27"
319
+ source = "registry+https://github.com/rust-lang/crates.io-index"
320
+ checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
@@ -0,0 +1,21 @@
1
+ [package]
2
+ name = "noisegate_rs"
3
+ version = "0.1.0"
4
+ edition = "2021"
5
+ description = "Rust backend for the noise-gating algorithm of DeForest (2017)"
6
+ license = "MIT"
7
+
8
+ [lib]
9
+ name = "_rust"
10
+ crate-type = ["cdylib"]
11
+
12
+ [dependencies]
13
+ pyo3 = { version = "0.30", features = ["extension-module", "abi3-py39"] }
14
+ numpy = "0.30"
15
+ rustfft = "6.4"
16
+ rayon = "1.12"
17
+
18
+ [profile.release]
19
+ lto = "fat"
20
+ codegen-units = 1
21
+ opt-level = 3
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017-2026 James Marcus Hughes
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.
@@ -0,0 +1,114 @@
1
+ Metadata-Version: 2.4
2
+ Name: noise-gating
3
+ Version: 0.1.0
4
+ Classifier: Programming Language :: Python :: 3
5
+ Classifier: Programming Language :: Rust
6
+ Classifier: Topic :: Scientific/Engineering :: Astronomy
7
+ Classifier: Topic :: Scientific/Engineering :: Image Processing
8
+ Requires-Dist: numpy>=1.21
9
+ Requires-Dist: tqdm
10
+ Requires-Dist: astropy
11
+ Requires-Dist: pytest ; extra == 'test'
12
+ Provides-Extra: test
13
+ License-File: LICENSE
14
+ Summary: Noise gating of image sequences (DeForest 2017) with a fast Rust backend
15
+ Author: James Marcus Hughes
16
+ License-Expression: MIT
17
+ Requires-Python: >=3.9
18
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
19
+ Project-URL: Repository, https://github.com/jmbhughes/noise_gating
20
+
21
+ # Noise gater
22
+
23
+ > [!warning]
24
+ > This code is no longer maintained. I highly suggest using [Craig DeForest's Cython version now](https://github.com/drzowie/image-noise-gate).
25
+
26
+ ## Background
27
+ This is a python implementation of [DeForest (2017)'s approach](https://iopscience.iop.org/article/10.3847/1538-4357/aa67f1/pdf) to reducing noise in images using regional fourier
28
+ transforms to remove noise from images. For the full details of how it works, please refer to the original paper in
29
+ The Astrophysical Journal, Volume 838, Issue 2, article id. 155, 10 pp, 2017.
30
+
31
+ ## Setup
32
+ Since this was designed for astronomical usage, it only takes FITS as a file format.
33
+ For other uses, the code can easy be modified to read a different image format in as an array.
34
+ If you find need for this, please contact me.
35
+
36
+ ### Installing
37
+ ```
38
+ pip install noise-gating
39
+ ```
40
+ Prebuilt wheels include the compiled Rust backend for Linux (x86_64, aarch64), macOS (Intel, Apple Silicon)
41
+ and Windows (x86_64), for Python 3.9 and newer, so no Rust toolchain is needed.
42
+
43
+ To install straight from GitHub instead (this compiles the Rust backend, so it needs a
44
+ [Rust toolchain](https://rustup.rs)):
45
+ ```
46
+ pip install git+https://github.com/jmbhughes/noise_gating
47
+ ```
48
+
49
+ ### Rust backend
50
+ `calculate_beta` and `noise_gate` are implemented in Rust (`src/lib.rs`, via [PyO3](https://pyo3.rs) and
51
+ [maturin](https://www.maturin.rs)) and used automatically (`backend="auto"`). Pass `backend="python"` or
52
+ `backend="rust"` to choose explicitly, or `--backend` on the command line; `noisegate.rust_available()` reports
53
+ whether the compiled backend is present. The Rust backend runs tiles in parallel; set `RAYON_NUM_THREADS` to limit
54
+ the number of threads. It matches the Python output to about 1e-13 (see `tests/test_rust_backend.py`), and
55
+ benchmark results are in [`benchmarks/RESULTS.md`](benchmarks/RESULTS.md).
56
+
57
+ ### Developing
58
+ ```
59
+ pip install maturin
60
+ maturin develop --release # builds the extension into the current environment
61
+ pip install pytest && pytest tests
62
+ ```
63
+ Pushing a `v*` tag builds wheels for all platforms in GitHub Actions and publishes them to PyPI
64
+ (see `.github/workflows/wheels.yml`).
65
+
66
+ ## Running
67
+ The program has two required parameters:
68
+ * `__in_directory__`: directory containing FITS files to noise gate, order is determined by sorting on the filename
69
+ * `__out_directory__`: directory to save the noise gated FITS files in
70
+
71
+ The program has multiple optional parameters with defaults that can be viewed with `noisegate --help`:
72
+ * `__gamma__`: this indicates how much noise should be removed, for a more rigorous definition see DeForest (2017)
73
+ * `__beta_percentile__`: percentile used to determine the beta_approx, eqn 7 in DeForest (2017).
74
+ * `__beta_count__`: how many image tiles are used when calculating beta_aprox, eqn 7 in DeForest (2017)
75
+ * `__width__`: size of the image tile cubes used noise gating
76
+
77
+ Example call:
78
+ ```
79
+ noisegate IN_DIRECTORY OUT_DIRECTORY
80
+ ```
81
+ (`python run.py IN_DIRECTORY OUT_DIRECTORY` still works from a checkout once the package is installed.)
82
+
83
+ ## Results
84
+ You can see example.mp4 in this folder for the type of improvement expected.
85
+ A frame from this movie is shown below:
86
+
87
+ ![See examples/example.png](examples/example.png "example result")
88
+
89
+ The upper left is a good image, no cleaning necessary. However, we often see images like the upper right,
90
+ dominated by shot noise. This image is created by taking the image on the upper left and adding poisson noise with as
91
+ ignal-to-noise ratio of 2. The algorithm still performs even if it's worse, although be more careful about artifacts
92
+ showing up. I use DeForest's algorithm to create the cleaned image on the bottom left. This can be compared to simply
93
+ smoothing the image to decrease the noise as in the bottom right.
94
+
95
+ ![See examples/currentsheet_noisegated.png](examples/currentsheet_noisegated.png "example result")
96
+ In the above image, the left is real SUVI 131 angstroms image from at flare on 2017-09-10.
97
+ At right, is the noisegated result.
98
+
99
+ For more examples, see the `examples` folder.
100
+
101
+
102
+ ## Todo
103
+ There are many features not yet added to this code yet:
104
+ * correcting the edges of images and the time series, so they aren't blacked out
105
+ * writing a 2D version
106
+ * comparing results to DeForest's PDL version for correctness
107
+
108
+ ## Author
109
+ James Marcus Hughes
110
+ hughes.jmb@gmail.com
111
+
112
+ ## License
113
+ MIT, see [LICENSE](LICENSE).
114
+
@@ -0,0 +1,49 @@
1
+ # Benchmark results: Python vs Rust backend
2
+
3
+ Generated by `python benchmarks/benchmark.py`. Raw numbers are in `results.json`.
4
+
5
+ ## Setup
6
+
7
+ - **date_utc**: 2026-12-03 00:38
8
+ - **cpu**: Intel(R) Xeon(R) Processor @ 2.10GHz
9
+ - **logical_cpus**: 4
10
+ - **os**: Linux 6.18.44-fc-v1157
11
+ - **python**: 3.13.18
12
+ - **numpy**: 2.5.5
13
+ - **rustc**: rustc 1.97.0 (2d8144b78 2026-07-07)
14
+ - **build**: maturin develop --release (lto=fat, codegen-units=1)
15
+ - **beta_count**: 10000
16
+ - **gamma**: 3.0
17
+ - **width**: 12
18
+ - **repeats**: best of 3
19
+ - **data**: synthetic cube, a moving Gaussian blob plus a constant background with Poisson noise (`make_cube`)
20
+ - **timing**: wall-clock seconds for `define_image_coordinates` + `calculate_beta` + `noise_gate`, tqdm disabled. Rust thread counts set with `RAYON_NUM_THREADS`.
21
+
22
+ ## End-to-end time (seconds)
23
+
24
+ | cube (x, y, t) | tiles | Python | Rust, 1 thread | Rust, 4 threads | speedup (1 thread) | speedup (4 threads) |
25
+ |---|---:|---:|---:|---:|---:|---:|
26
+ | 64x64x32 | 2,268 | 1.626 | 0.428 | 0.128 | 3.8x | 12.7x |
27
+ | 128x128x48 | 18,252 | 3.522 | 0.826 | 0.259 | 4.3x | 13.6x |
28
+ | 256x256x64 | 121,032 | 16.308 | 3.211 | 1.118 | 5.1x | 14.6x |
29
+
30
+ ## Per stage (seconds)
31
+
32
+ | cube | stage | Python | Rust, 1 thread | Rust, 4 threads |
33
+ |---|---|---:|---:|---:|
34
+ | 64x64x32 | beta | 1.346 | 0.374 | 0.107 |
35
+ | 64x64x32 | gate | 0.280 | 0.054 | 0.021 |
36
+ | 128x128x48 | beta | 1.344 | 0.383 | 0.107 |
37
+ | 128x128x48 | gate | 2.175 | 0.441 | 0.150 |
38
+ | 256x256x64 | beta | 1.392 | 0.440 | 0.128 |
39
+ | 256x256x64 | gate | 14.898 | 2.757 | 0.978 |
40
+
41
+ ## Agreement with the Python implementation
42
+
43
+ Same random seed for the beta tile selection in both backends.
44
+
45
+ | cube | max abs diff (beta) | max abs diff (gated) | max diff / max(gated) |
46
+ |---|---:|---:|---:|
47
+ | 64x64x32 | 1.29e-14 | 1.42e-13 | 5.64e-16 |
48
+ | 128x128x48 | 1.73e-14 | 1.99e-13 | 8.32e-16 |
49
+ | 256x256x64 | 1.20e-14 | 1.71e-13 | 7.21e-16 |