Skip to main content

chnet-xrf-raw-data-converter (import: xrfraw)

Convertitore raw MA-XRF (Fi MA-XRF, INFN-CHNet) → NPZ/HDF5/OME-TIFF comuni: datacube di eventi per pixel in ordine (y, x, channel), indici canale ADC, assi spaziali, maschera di acquisizione, metadati serializzati, con calibrazione energia come allegato (energy[i] = m·i + q, conteggi element-identical).

Status: M6 (2026-11-17) — converter + UI completi; v0.1.0 pubblicato su PyPI e TestPyPI (2026-11-18): dist name chnet-xrf-raw-data-converter, workflow Trusted Publishing in .github/workflows/, vedi deploy/how_to_deploy_pip.md.

Cosa fa

  • Legge le due varianti di file raw (XML+dati e solo-dati) — grammatica in data_format.md; valida prima di allocare il cubo (inspect_raw).
  • Costruisce il datacube (Y, X, n_channels) con dtype a scelta: uint32 (default), uint16, float32, float64 (per consumer che richiedono floating, es. dash-xrf-visualizer) — profondità esatta: l'output è sempre (Y, X, n_channels); default strumentale 16384 (UNVERIFIED), canali finali a zero.
  • Calibrazione energia come allegato: i conteggi non cambiano (il legacy ne perdeva silenziosamente — legacy_audit.md L4).
  • Nessun auto-rebinning / auto energy-crop (contratto kickstart); rebin esplicito (sum/mean) e rebin a profondità target (rebin_to) solo su richiesta.
  • Scrive .h5, .npz o .ome.tif (OME-TIFF/BigTIFF) con lo stesso schema logico — output_schema.md.
  • UI minimale Dash (DARKLY, accent #4196B4, embeddabile in Jupyter): from xrfraw.ui import build_app (sezione UI).

Setup (uv)

uv sync
.venv/bin/python -m pytest -q

Install (pip)

python -m pip install "chnet-xrf-raw-data-converter[ui]"
# senza UI: python -m pip install chnet-xrf-raw-data-converter

Dettaglio in deploy/how_to_deploy_pip.md.

Uso

CLI (exit code 0 ok / 1 errori di conversione / 2 usage; nessuna overwrite silenziosa — --overwrite per sostituire):

xrf-raw-to-h5 FILE_OR_DIR -o OUT_DIR --format h5|npz|ome \
    [--n-channels N] [--dtype uint32|uint16|float32|float64] [--metadata meta.json] \
    [--rebin N sum|mean] [--rebin-to 512|1024|2048|4096|8192] \
    [--compress 0-9] [--overwrite]

Se m/q sono noti (XML o JSON esterni) la calibrazione viene applicata come allegato (with_calibration); altrimenti l'output è non calibrato (asse channel, nessun energy).

API:

from xrfraw import inspect_raw, read_raw, with_calibration, rebin, rebin_to
from xrfraw.io import write_dataset

report = inspect_raw("mappa11.txt")            # validazione, nessuna allocazione
ds = read_raw("mappa11.txt")                   # (NY, NX, NC) + assi + mask + metadati
ds = with_calibration(ds, 0.00259259, -0.0355556, provenance="xml")  # conteggi intatti
ds = rebin(ds, 2)                              # opzionale, esplicito (sum|mean)
ds = rebin_to(ds, 2048)                        # opzionale: profondità target
write_dataset(ds, "mappa11.h5", fmt="h5", compress=4)  # o fmt="npz"/"ome"; compress 0-9
read_ome("mappa11.ome.tif")   # round-trip: OME-TIFF -> Dataset (Y, X, C) + metadati (OME-XML XSD 2016-06)

UI minimale (Dash, DARKLY, accent #4196B4) — la CLI grafica per convert_file, con il template grafico di dash-xrf-visualizer:

path_to_file = "./data_example/mappa11.txt"
from xrfraw.ui import build_app

app = build_app(src=path_to_file)     # src precompila path_to_file
app.run()                             # browser
app.run(jupyter_mode="inline", jupyter_height=800)  # notebook (vedi example.ipynb)

Carica il raw (upload, load from link o path_to_file), espone ogni parametro di convert_file come input (out_path, fmt, n_channels, dtype, metadata, rebin_spec, rebin_to, cal m/q, compress, overwrite), Convert e Download file per l'output .h5/.npz/.ome.tif. Tooltip su ogni campo; spinner (dcc.Loading) durante i callback; al click su Convert: status immediato "conversione in corso" + tasto disabilitato fino al termine (anti doppio-click: un solo Convert alla volta). Upload limitato a ~48 MB (il browser base64-izza il file in memoria): per i file grandi usa path_to_file.

Verified vs UNVERIFIED

  • Verified (M0): grammatica degli input sui 2 file di esempio (data_format.md §4, 5 passate streaming: eventi 19 825 090 / 56 661 209, max canale 15902/15999, griglie, anomalie localizzate); audit del legacy (legacy_audit.md); crash legacy sul formato B riprodotto (ParseError, 2026-11-17); CI verde su GitHub Actions (push + publish v0.1.0, 2026-11-18).
  • UNVERIFIED: NC strumentale 16384 (N1); unità µm/µm/s (N4); deploy docker/apptainer/wslc (NOT TESTED, no daemon in questo ambiente).

Layout e repo map

Vedi operational_plan.md §3.

path ruolo
AGENTS.md regole agent (leggere prima di tutto)
operational_plan.md decisioni, milestone, criteri di accettazione, domande aperte
legacy_audit.md problemi legacy verificati + differenze intenzionali
data_format.md grammatica degli input (formati A/B, stream eventi, NC)
output_schema.md schema comune NPZ/HDF5/OME-TIFF
scientific_notes.md calibrazione, conteggi, assi, precisione
to_do.md Now/Next/Later/Blocked + verification log
timeline.md storico append-only datato
example.ipynb notebook demo: CLI + UI embeddata (Jupyter)
user_guide.md guida operativa: cosa fare, ingressi, parametri, limiti
simple_guide.md guida utente da zero: install uv, ambiente, UI, notebook Python, CLI (copy-paste)
deploy/ ricetta per backend con status verificato / NOT TESTED
original_code/ legacy di riferimento (gitignored, sola lettura)
data_example/ 2 file di esempio (gitignored, mai caricati in massa)

Metadata

Release files for chnet-xrf-raw-data-converter 0.1.2

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

Source distribution (sdist)

Source distribution for chnet-xrf-raw-data-converter 0.1.2
File Size Uploaded Provenance Actions
chnet_xrf_raw_data_converter-0.1.2.tar.gz 138.5 kB With provenance Details for chnet_xrf_raw_data_converter-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for chnet-xrf-raw-data-converter 0.1.2
File Interpreter ABI Platform Actions
chnet_xrf_raw_data_converter-0.1.2-py3-none-any.whl Python 3 none any Details for chnet_xrf_raw_data_converter-0.1.2-py3-none-any.whl

Total release size: 169.8 kB

Release files / chnet_xrf_raw_data_converter-0.1.2.tar.gz

Download URL chnet_xrf_raw_data_converter-0.1.2.tar.gz
Size 138.5 kB
Tags Source
SHA-256 checksum
How to use checksums
8a279f4e08d1cb1177ac660a9dcb21e938af447a358779053c20356529f87407
BLAKE2b-256 checksum
How to use checksums
cb010a12c1054ccd6901268bd7054c887c92ee4046129d1e77ffee8ab5f41386
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 26, 2026.

Transparency log

Release files / chnet_xrf_raw_data_converter-0.1.2-py3-none-any.whl

Download URL chnet_xrf_raw_data_converter-0.1.2-py3-none-any.whl
Size 31.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
05c97255ebb028d15ed5b9d3436add1a936ebae69796c81dc93c78a4c99a9e4c
BLAKE2b-256 checksum
How to use checksums
39c3ec80c43fb6db9edac9041f7ad2da51c9e06e0b6e858447ba297d29132c38
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 26, 2026.

Transparency log

Security for chnet-xrf-raw-data-converter 0.1.2

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 chnet_xrf_raw_data_converter-0.1.2.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 26, 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