chnet-xrf-raw-data-converter (import: xrfraw)
Convertitore raw MA-XRF (Fi MA-XRF, INFN-CHNet) → NPZ/HDF5 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; packaging PyPI
preparato (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.mdL4). - Nessun auto-rebinning / auto energy-crop (contratto kickstart); rebin
esplicito (sum/mean) e rebin a profondità target (
rebin_to) solo su richiesta. - Scrive
.h5o.npzcon 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, dopo la pubblicazione PyPI)
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 \
[--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"; compress 0-9
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. 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). - UNVERIFIED: NC strumentale 16384 (N1); unità µm/µm/s (N4); deploy docker/apptainer/wslc (NOT TESTED, no daemon in questo ambiente); esecuzione CI (workflow pushato, repo privato — da verificare su GitHub Actions).
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 |
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 |
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.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| chnet_xrf_raw_data_converter-0.1.0.tar.gz | 121.2 kB | With provenance | Details for chnet_xrf_raw_data_converter-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| chnet_xrf_raw_data_converter-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for chnet_xrf_raw_data_converter-0.1.0-py3-none-any.whl |
Total release size: 148.5 kB
Release files / chnet_xrf_raw_data_converter-0.1.0.tar.gz
| Download URL | chnet_xrf_raw_data_converter-0.1.0.tar.gz |
|---|---|
| Size | 121.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
03699ac3e55d7446520d0e98dd8ec2d3bff5ee488b44a0ab50e344a855a73dcb
|
|
BLAKE2b-256 checksum How to use checksums |
f4f65b8fc6d148bfb4c59ac320b0cff4ba0d5d0b05292dcbab569d909eb80dd5
|
| 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 20, 2026.
Transparency logRelease files / chnet_xrf_raw_data_converter-0.1.0-py3-none-any.whl
| Download URL | chnet_xrf_raw_data_converter-0.1.0-py3-none-any.whl |
|---|---|
| Size | 27.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
80342b46be0a92c41aafcf14ab8bf79d99120a15ac9284a021fca91d6916e3ca
|
|
BLAKE2b-256 checksum How to use checksums |
778bd6a4faa38bd47fd2d46817146ff803f7659c6f24bbf0d5bdf7fa45bac8c1
|
| 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 20, 2026.
Transparency logSecurity for chnet-xrf-raw-data-converter 0.1.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.
Attestation for chnet_xrf_raw_data_converter-0.1.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 20, 2026.
Transparency logA 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.