Skip to main content

Toolbox Python per l'analisi dei dati di laboratorio

Project description

mespy

Toolbox Python per l'analisi dei dati di laboratorio di meccanica.

L'obiettivo del progetto e' raccogliere in un unico package le utility che tornano spesso nei notebook di laboratorio: caricamento CSV, statistiche descrittive e pesate, istogrammi e fit lineare con incertezze.

Lo stato attuale e' ancora Alpha: il package e' gia' utilizzabile per casi semplici, ma l'API non va considerata stabile.

Cosa c'e' oggi

Il package espone direttamente:

  • load_csv
  • median
  • weighted_mean
  • variance
  • covariance
  • standard_deviation
  • histogram
  • lin_fit

I moduli attualmente presenti in src/mespy sono:

  • io_utils.py: lettura CSV con gestione di separatori, decimali, colonne richieste e missing values
  • stats_utils.py: funzioni statistiche di base, anche con pesi
  • plot_utils.py: istogrammi con media e banda ±1σ
  • fit_utils.py: fit lineare pesato con residui, incertezze sui parametri e grafico opzionale

Struttura del progetto

mespy/
├── src/mespy/            # package Python
├── tests/                # test pytest
├── notebooks/            # notebook di prova e dimostrazione
├── docs/                 # documentazione LaTeX e PDF
├── data/reference/       # dataset di riferimento per test/esempi
├── figures/              # figure esportate
├── tools/                # script di supporto
├── pyproject.toml        # metadata del package
└── Makefile              # comandi di setup e documentazione

Requisiti

  • Python >= 3.12
  • git
  • lualatex, latexmk e pygmentize solo se vuoi ricompilare la documentazione
  • font richiesti dalla build docs: Libertinus Serif, Libertinus Math, Libertinus Sans, JetBrains Mono, Inter Display

Installazione rapida

Clona il repository ed entra nella directory:

git clone https://github.com/giancarmine-sparso/mespy
cd mespy

Crea il virtualenv e installa il package con le dipendenze di sviluppo:

make setup

Questo installa anche gli strumenti usati per il check pre-release (build e twine).

Se vuoi attivare l'ambiente manualmente:

source .venv/bin/activate

Esempio minimo

from mespy import lin_fit, load_csv, weighted_mean

df = load_csv("data/reference/test_misure.csv", sep=",", decimal=".")

x = df["misura_n"].to_numpy(dtype=float)
y = df["lunghezza_mm"].to_numpy(dtype=float)
sigma_y = df["sigma_mm"].to_numpy(dtype=float)

y_bar = weighted_mean(y, 1 / sigma_y**2)

fit = lin_fit(
    x=x,
    y=y,
    sigma_y=sigma_y,
    xlabel="numero misura",
    ylabel="lunghezza [mm]",
    plot=False,
)

print("media pesata:", y_bar)
print("pendenza:", fit["m"])

Documentazione

La documentazione del package e' in docs/main.pdf.

Per ricompilarla:

make docs

Il target usa minted, quindi richiede anche pygmentize disponibile nel PATH. Inoltre il sorgente LaTeX usa i font Libertinus Serif, Libertinus Math, Libertinus Sans, JetBrains Mono e Inter Display. make check-tex verifica i comandi necessari e, se fc-match e' disponibile nel sistema, controlla anche la presenza di questi font.

Le sezioni attualmente documentate sono:

  • io_utils
  • stats_utils
  • plot_utils
  • fit_utils

Check pre-release

Per eseguire il gate completo di release PyPI in locale:

make release-check

Il comando esegue test, compileall, pip check, build di sdist e wheel, validazione con twine check e smoke test degli import a partire dalla wheel generata.

Comandi utili

Target Descrizione
make setup Crea il virtualenv e installa il package in editable mode con dipendenze dev
make venv Crea solo il virtualenv
make install Installa il package locale e le dipendenze
make test Esegue l'intera suite pytest
make dist Rigenera da zero sdist e wheel in dist/
make twine-check Valida solo gli artifact della versione corrente
make upload Carica su PyPI solo gli artifact della versione corrente
make release-check Esegue il gate completo pre-release per PyPI
make check-tex Verifica i prerequisiti LaTeX e, se possibile, i font richiesti
make docs Compila la documentazione PDF
make docs-clean Rimuove i file temporanei LaTeX
make dist-clean Rimuove gli artifact Python di build
make clean Esegue la pulizia generale

Note

  • I notebook in notebooks/ sono esempi di utilizzo e test esplorativi, non documentazione API stabile.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mespy-0.2.2.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mespy-0.2.2-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file mespy-0.2.2.tar.gz.

File metadata

  • Download URL: mespy-0.2.2.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for mespy-0.2.2.tar.gz
Algorithm Hash digest
SHA256 8d61270647b155afb12a77d2230736f61132e150f905ce42e228d794d620ae3f
MD5 81d606aa688a28d9c7cf68b3ce6bb774
BLAKE2b-256 82aeb9f781b2e6d139af69d6f2c1dadbbe1fc93517652b21b28e55d751cf23d6

See more details on using hashes here.

File details

Details for the file mespy-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: mespy-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for mespy-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 78689703b0a39f31c892d56031932cfaa634c68a563df7fc974ae21e0ee65315
MD5 85ef3ef442e8d83168a2dfc0fb1f9eea
BLAKE2b-256 46a97455605bbfc16e6ac0adacbce37f288e6fc2a6ec74bddd474ef3c01d9f2e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page