fitscube 2.11.0__tar.gz → 2.12.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.
- {fitscube-2.11.0 → fitscube-2.12.0}/.github/workflows/cd.yml +1 -1
- {fitscube-2.11.0 → fitscube-2.12.0}/PKG-INFO +1 -1
- {fitscube-2.11.0 → fitscube-2.12.0}/fitscube/_version.py +2 -2
- {fitscube-2.11.0 → fitscube-2.12.0}/fitscube/compress.py +14 -3
- {fitscube-2.11.0 → fitscube-2.12.0}/tests/test_compress.py +26 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/.github/CONTRIBUTING.md +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/.github/dependabot.yml +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/.github/release.yml +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/.github/workflows/ci.yml +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/.gitignore +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/.pre-commit-config.yaml +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/CHANGELOG.md +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/LICENSE +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/README.md +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/fitscube/__init__.py +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/fitscube/asyncio.py +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/fitscube/bounding_box.py +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/fitscube/cli.py +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/fitscube/combine_fits.py +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/fitscube/exceptions.py +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/fitscube/extract.py +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/fitscube/logging.py +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/fitscube/version.pyi +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/noxfile.py +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/pyproject.toml +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/tests/__init__.py +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/tests/conftest.py +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/tests/data/cube.zip +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/tests/data/images.zip +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/tests/data/time_images.zip +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/tests/data/timecube.zip +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/tests/test_bb.py +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/tests/test_combine.py +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/tests/test_combine_guards.py +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/tests/test_combine_layouts.py +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/tests/test_extract.py +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/tests/test_frequencies.py +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/tests/test_package.py +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/tests/test_racs_all.py +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/tests/test_times.py +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/tests/test_zero_beams.py +0 -0
- {fitscube-2.11.0 → fitscube-2.12.0}/uv.lock +0 -0
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '2.
|
|
22
|
-
__version_tuple__ = version_tuple = (2,
|
|
21
|
+
__version__ = version = '2.12.0'
|
|
22
|
+
__version_tuple__ = version_tuple = (2, 12, 0)
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|
|
@@ -126,6 +126,7 @@ def gzip2_tiles(
|
|
|
126
126
|
GZIP_2 gzips the big-endian bytes of the tile, shuffled so that all the first
|
|
127
127
|
bytes of each value come first, then all the second bytes, and so on.
|
|
128
128
|
"""
|
|
129
|
+
# A view, not a copy, for a plane read straight from a FITS file
|
|
129
130
|
big_endian = plane.astype(plane.dtype.newbyteorder(">"), copy=False)
|
|
130
131
|
itemsize = big_endian.dtype.itemsize
|
|
131
132
|
tiles = []
|
|
@@ -201,8 +202,14 @@ def compress_plane(
|
|
|
201
202
|
scales=[],
|
|
202
203
|
zeros=[],
|
|
203
204
|
)
|
|
205
|
+
# astropy wants native byte order; only this path pays for the copy
|
|
204
206
|
compressed, _ = astropy_compress_plane(
|
|
205
|
-
plane
|
|
207
|
+
plane.astype(plane.dtype.newbyteorder("="), copy=False),
|
|
208
|
+
fits.Header(),
|
|
209
|
+
compression_type,
|
|
210
|
+
quantize_level,
|
|
211
|
+
tile_shape,
|
|
212
|
+
dither_seed,
|
|
206
213
|
)
|
|
207
214
|
return compressed
|
|
208
215
|
|
|
@@ -260,7 +267,11 @@ def compressed_planes(
|
|
|
260
267
|
gzip_level: int,
|
|
261
268
|
max_workers: int,
|
|
262
269
|
) -> Iterator[CompressedPlane]:
|
|
263
|
-
"""Compress every plane of `image` across threads, yielding them in order.
|
|
270
|
+
"""Compress every plane of `image` across threads, yielding them in order.
|
|
271
|
+
|
|
272
|
+
Planes are handed over as read, big-endian, which is the order GZIP_2 shuffles:
|
|
273
|
+
the lossless path never copies a plane.
|
|
274
|
+
"""
|
|
264
275
|
with ThreadPoolExecutor(max_workers) as pool:
|
|
265
276
|
pending: deque[Future[CompressedPlane]] = deque()
|
|
266
277
|
for plane_index, index in enumerate(np.ndindex(image.shape[:-2])):
|
|
@@ -268,7 +279,7 @@ def compressed_planes(
|
|
|
268
279
|
pending.append(
|
|
269
280
|
pool.submit(
|
|
270
281
|
compress_plane,
|
|
271
|
-
plane
|
|
282
|
+
plane,
|
|
272
283
|
compression_type,
|
|
273
284
|
quantize_level,
|
|
274
285
|
tile_shape,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
import tracemalloc
|
|
5
6
|
from collections.abc import Callable, Iterator
|
|
6
7
|
from pathlib import Path
|
|
7
8
|
from typing import Any
|
|
@@ -13,8 +14,10 @@ from fitscube import compress as compress_module
|
|
|
13
14
|
from fitscube.cli import cli
|
|
14
15
|
from fitscube.combine_fits import combine_fits
|
|
15
16
|
from fitscube.compress import (
|
|
17
|
+
CompressedPlane,
|
|
16
18
|
CompressMethod,
|
|
17
19
|
compress_cube,
|
|
20
|
+
compress_plane,
|
|
18
21
|
decompress_cube,
|
|
19
22
|
tile_compress_cube,
|
|
20
23
|
)
|
|
@@ -137,6 +140,29 @@ def test_tile_compress_is_the_same_for_any_worker_count(tmp_path: Path) -> None:
|
|
|
137
140
|
assert outputs[0] == outputs[1]
|
|
138
141
|
|
|
139
142
|
|
|
143
|
+
def test_gzip2_shuffles_a_big_endian_plane_without_copying_it() -> None:
|
|
144
|
+
"""Planes come off the file big-endian, the order GZIP_2 shuffles, so no copy is needed"""
|
|
145
|
+
plane = np.full((256, 1024), 1.5, dtype=">f4")
|
|
146
|
+
|
|
147
|
+
def compress(plane: np.ndarray) -> CompressedPlane:
|
|
148
|
+
return compress_plane(plane, "GZIP_2", 0.0, (16, 1024), 1, 6)
|
|
149
|
+
|
|
150
|
+
tracemalloc.start()
|
|
151
|
+
compressed = compress(plane)
|
|
152
|
+
_, peak = tracemalloc.get_traced_memory()
|
|
153
|
+
tracemalloc.stop()
|
|
154
|
+
assert peak < plane.nbytes / 2
|
|
155
|
+
|
|
156
|
+
# The control: a native-order plane has to be copied back to big-endian
|
|
157
|
+
native = plane.astype("<f4")
|
|
158
|
+
tracemalloc.start()
|
|
159
|
+
from_native = compress(native)
|
|
160
|
+
_, native_peak = tracemalloc.get_traced_memory()
|
|
161
|
+
tracemalloc.stop()
|
|
162
|
+
assert native_peak >= plane.nbytes
|
|
163
|
+
assert from_native == compressed
|
|
164
|
+
|
|
165
|
+
|
|
140
166
|
def test_tile_compress_refuses_compressed_input(tmp_path: Path) -> None:
|
|
141
167
|
write_noise_cube(tmp_path / "cube.fits")
|
|
142
168
|
compressed = tile_compress_cube(tmp_path / "cube.fits")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|