Skip to main content

midas-zipper

Standalone zarr-zip generation for MIDAS FF/PF workflows.

pip install midas-zipper works with no MIDAS source tree and no compiled C binaries — it depends only on numpy, h5py, zarr, numcodecs, numba, and pillow, plus the system zip/bzip2 tools.

It packages the zarr ingest that the FF and PF pipelines need to turn raw detector data (HDF5/GE/TIFF) into the *.MIDAS.zip files the rest of MIDAS consumes — previously the source-tree script utils/ffGenerateZipRefactor.py, which broke pip-only installs because it lived outside any package.

Notebooks

Worked-example Jupyter notebooks live in notebooks/. They are not shipped with pip install — get them by cloning the MIDAS repository.

CLI

# FF zarr-zip generation (formerly ffGenerateZipRefactor.py)
midas-ff-zip -resultFolder <dir> -paramFN <params.txt> -LayerNr <n>

# Update a key inside an existing Zarr.zip
midas-update-zarr -fn <file.MIDAS.zip> -keyToUpdate <key> -updatedValue <...>

Both are also runnable as modules:

python -m midas_zipper.ff_zip   -resultFolder ... -paramFN ... -LayerNr ...
python -m midas_zipper.update_zarr -fn ... -keyToUpdate ... -updatedValue ...

Lossless archive zips

-preProcThresh zeroes pixels, and with a dark file the multi-file readers (GE binary, TIFF, CBF) also clip negative residuals to 0, so those zips cannot give back the raw frames. For an archive that can, add -archiveLossless:

midas-ff-zip -resultFolder <dir> -paramFN <params.txt> -LayerNr <n> -archiveLossless auto

Each frame is stored as zigzag(frame - background), a bijection on n-bit words, so the raw frames come back bit for bit. The background is the stored dark (dark), the per-pixel median of evenly spaced frames of the scan (median, the only choice when there is no dark file, as for NF), or whichever is smaller (auto). A few frames are trial-encoded first: if nothing beats the raw frames by 2 % the zip is left as an ordinary zip, and for cameras that store 12 bits in 16 the background is rounded onto the data's bit grid (a dark that is off the grid makes things worse otherwise). Every chunk is decoded and compared with its source while writing.

The gain is measured against the uncorrected ordinary zip (raw frames plus the real dark, Blosc zstd level 1 bitshuffle), not against the lossy dark-corrected zip the default path writes with a dark file, which is smaller (Varex: 4.5x against 3.2x for the archive). On the study slabs (one scan per detector) the ratio rose from 3.2x to 5.4x on GE, 2.3x to 3.2x on Varex, 10.6x to 11.6x on Pilatus and 2.9x to 3.8x on an NF detector, and every frame decoded bit-exact. Part of the Pilatus gain is the -1 gap pixels being recoded, not background. The median background holds about 8 to 20 frames at once on very large detectors (Eiger2), by design.

An archive zip has no exchange/data; it has exchange/data_resid and exchange/background, so a reader that does not know the encoding stops with a KeyError instead of reading residuals. To read it:

from midas_zipper.archive import read_frames, restore_zip
frames = read_frames("scan.MIDAS.zip", 0, 10)        # raw frames
restore_zip("scan.MIDAS.zip", "scan.ordinary.zip")   # ordinary zip, for the pipeline

or midas-zip-archive convert|restore, which works on any existing zip that has exchange/data (and exchange/dark if there is a dark). Results from the compression study behind this are provisional (dev/compression_study).

Python API

from midas_zipper import generate_ff_zip

generate_ff_zip(
    result_folder="/path/to/scan",
    param_file="/path/to/Parameters.txt",
    layer_nr=1,
)

Scope

This package intentionally excludes AutoCalibrateZarr.py: that tool drives the C/OpenMP calibration binaries (CalibrantPanelShiftsOMP, CalibrantIntegratorOMP, GetHKLList) and so cannot be pip-portable. It stays with the calibration workflow.

Metadata

Release files for midas-zipper 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for midas-zipper 0.6.0
File Size Uploaded Provenance Actions
midas_zipper-0.6.0.tar.gz 64.4 kB With provenance Details for midas_zipper-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for midas-zipper 0.6.0
File Interpreter ABI Platform Actions
midas_zipper-0.6.0-py3-none-any.whl Python 3 none any Details for midas_zipper-0.6.0-py3-none-any.whl

Total release size: 116.9 kB

Release files / midas_zipper-0.6.0.tar.gz

Download URL midas_zipper-0.6.0.tar.gz
Size 64.4 kB
Tags Source
SHA-256 checksum
How to use checksums
aa5344b4e07765b3a1afa583032630d9a76ad7b94699b48baa6952d813476c49
BLAKE2b-256 checksum
How to use checksums
3cb5355a1d1732f38885322380eef59ff8f0d01bfd0db249bbe0a624ac804ad3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / midas_zipper-0.6.0-py3-none-any.whl

Download URL midas_zipper-0.6.0-py3-none-any.whl
Size 52.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
82a2112fa19e3d37193302ced7b4e914d778874ef613f9aa15a5a1c97c830796
BLAKE2b-256 checksum
How to use checksums
4ad5ae926bb8ede3402cafe6fb0eb6d751a2b15fb61d036c8e615475842c824b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Security for midas-zipper 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for midas_zipper-0.6.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page