Skip to main content

Experimental data utilities: error propagation and LaTeX table generator

Project description

lab-data-utils

Laboratory Data Utilities

A Python library for experimental data analysis and reporting.
Includes tools for outlier detection, error propagation and LaTeX-ready table formatting.

Features

  • Error propagation via finite difference derivatives, with correct significant figures.
  • LaTeX table generation with support for merged value ± error columns.
  • Designed for clarity and reproducibility in lab reports.

Installation

pip install labdatautils

Function Reference

1. propagate(func, *args)

Arguments:

  • func (callable) — Function whose result and uncertainty are to be calculated.
  • *args — Values and uncertainties, alternating: val1, err1, val2, err2, ...
    Each can be a float, list, or NumPy array (all arrays must have the same length).

Returns:

  • values (ndarray) — Computed function results.
  • errors (ndarray) — Propagated uncertainties.

2. generate_latex_table(column_headers, data_columns, **kwargs)

Arguments:

  • column_headers (list of str) — Ordered list of column names to display.
  • data_columns (sequence of arrays) — One array per column, in the same order as column_headers.
    Each array should contain the values for that column.
  • caption (str, optional) — Table caption. Default: "Data Table".
  • label (str, optional) — LaTeX label for referencing. Default: "tab:data".
  • error_map (dict or list of str, optional) — Maps error columns to their associated value column.
    Example: {"dx": "x", "dy": "y"} or ["dx:x", "dy:y"].
  • merge_error_style (str, optional) — How to display value and error pairs:
    "separate" (two columns), "pm" (e.g. 1.23 ± 0.04), "paren" (e.g. 1.23(4)). Default: `"separate"

3. Outlier Detection

The library provides three layers of functionality for multiple methods, z-score, modified (MAD) z-score, IQR and Grubb's test:


a) compute_* (e.g. compute_zscores(x, **kwargs))

Arguments:

  • x (array-like) — Input data.
  • **kwargs — Method-specific options (e.g. ddof for z-scores, threshold for IQR).

Returns:

  • scores (ndarray) — Raw scores for each point (z-scores, MAD-scores, IQR-scores, or Grubbs’ G values).

b) detect_outliers_* (e.g. detect_outliers_zscore(x, **kwargs))

Arguments:

  • x (array-like) — Input data.
  • threshold (float, optional) — Criterion for outliers. Default depends on method
    (3.0 for z, 3.5 for MAD, 1.5 for IQR, significance level α=0.05 for Grubbs).
  • verbose (bool, optional) — If True, prints detected outliers. Default: True.

Returns:

  • mask (ndarray of bool) — Boolean array, True where the input is an outlier.

c) remove_outliers_* (e.g. remove_outliers_iqr(x, **kwargs))

Arguments:

  • x (array-like) — Input data.
  • threshold (float, optional) — Same meaning as in detect_outliers_*.
  • verbose (bool, optional) — If True, prints which points were removed. Default: True.

Returns:

  • cleaned (ndarray) — Input data with outliers removed.

General entry points

Instead of calling method-specific functions, you can use the general function which have the different methods as arguments, for example:

from lab_data_utils import detect_outliers, remove_outliers

mask = detect_outliers(data, method="iqr", threshold=1.5)
cleaned = remove_outliers(data, method="iqr", threshold=1.5)

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

lab_data_utils-0.2.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

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

lab_data_utils-0.2.0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file lab_data_utils-0.2.0.tar.gz.

File metadata

  • Download URL: lab_data_utils-0.2.0.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for lab_data_utils-0.2.0.tar.gz
Algorithm Hash digest
SHA256 aff6a93ee4b0fb554d980b1157ea11136957b69d183c66f2f5eea075e85dd23f
MD5 f52acf345314e05af902503887809cda
BLAKE2b-256 b0e3a0365b7ecd3da385bb974c7f27937a1e6debac5d8d6fad3f05e4dd2243da

See more details on using hashes here.

Provenance

The following attestation bundles were made for lab_data_utils-0.2.0.tar.gz:

Publisher: publish.yml on Pablo-CastroPerez/lab-data-utils

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lab_data_utils-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: lab_data_utils-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for lab_data_utils-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 653e886e8adf6aeff2bbd2a2dc3172db4bfe8c77d8546539bd20427b2fd389a7
MD5 05d023395864b3120c2c1ceacd7c81f3
BLAKE2b-256 0e6d6146861967fe31943e15f15908f53a31586785e6e412d5721e87986e0984

See more details on using hashes here.

Provenance

The following attestation bundles were made for lab_data_utils-0.2.0-py3-none-any.whl:

Publisher: publish.yml on Pablo-CastroPerez/lab-data-utils

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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