Skip to main content

Python reader and verifier for the ISOF v1.0 format, open standard for geochemical isotopic data exchange

Project description

isof

Python reader and verifier for the ISOF v1.0 (ISotopic Open Format) format, an open standard for exchanging geochemical isotopic data.

This format allows exchanging in a single file the isotopic data along with all associated metadata (analytical methods used for each sample, purification yields, analysis pipeline...), while enabling traceability of modifications once files are produced and certifying the origin of the file (laboratory certification).

Sovereignty and Confidentiality: Signature verification is a 100% local process. No data is sent to a third-party server for validation.

import isof

report = isof.load("analyse_bolivie.isof")

if report.is_authentic():
    print(f"Signed by: {report.signature.signed_by}")

df = report.to_pandas()
print(df[["sample_name", "element", "ratio", "ratio_2se"]])

The ISOF format is used by IsoFind, but this parser is independent and can read any file compliant with the ISOF v1.0 specification.


Installation

pip install isof

With pandas support:

pip install isof[pandas]

Requires Python ≥ 3.9.


Usage

Load a file

import isof

report = isof.load("analyse.isof")
print(report)
# <ISOfDocument v1.0 — 12 échantillon(s) — IGE Grenoble>

From a JSON string (API, database):

with open("analyse.isof") as f:
    text = f.read()

report = isof.loads(text)

Verify integrity

# Simple check
if report.is_authentic():
    print("Data integrity confirmed")

# Detailed result
result = report.verify()
print(result.valid)      # bool
print(result.level)      # 1 (SHA-256) or 2 (IsoFind PKI)
print(result.signer)     # organisation or certificate CN
print(result.signed_at)  # ISO 8601 timestamp
print(result.reason)     # None if valid, error message otherwise

Two signature levels coexist in the format:

Level Mechanism Guarantee
1 SHA-256 over the data Integrity, file has not been modified since export
2 ECDSA P-256 + IsoFind PKI Authenticity, signed by a laboratory certified by IsoFind

Verification works offline: IsoFind certificates are embedded in the package.

Access data

# Sample list
for sample in report.samples:
    print(sample.id, sample.name, sample.classification)
    for iso in sample.isotope_data:
        print(f"  {iso.element} {iso.system} = {iso.ratio} ± {iso.ratio_2se}")

# Look up a sample by identifier
s = report.sample("BOL-24-01")

# Filter
sources = report.filter_samples(classification="source")
sb_samples = report.filter_samples(element="Sb")
combined = report.filter_samples(element="Pb", material_type="minerai")

# Metadata
print(report.created_by.organisation)
print(report.project.reference)
print(report.project.client)

Purification yields

# Yields for a sample
yields = report.yields_for_sample("BOL-24-01")
for y in yields:
    print(f"{y.element}: {y.value_pct}%")

# Contamination alerts (yield > 105%)
suspects = report.suspicious_yields()
for y in suspects:
    print(f"Possible contamination — {y.sample_id} / {y.element}: {y.value_pct}%")

Methods and pipelines

# Preparation methods
for key, method in report.methods.items():
    print(f"{key}{method.name} ({method.type})")
    if method.yield_min_pct:
        print(f"  Expected yield: {method.yield_min_pct}{method.yield_max_pct}%")

# Pipelines
for key, pipeline in report.pipelines.items():
    print(f"{pipeline.name} ({pipeline.element})")
    for stage in pipeline.stages:
        print(f"  {stage.order}. {stage.label}")

Export to pandas

df = report.to_pandas()

# One row per isotopic measurement, sample metadata included
df[["sample_name", "element", "ratio", "ratio_2se", "instrument"]]

# Standard pandas filtering
pb_data = df[df["element"] == "Pb"]
sources = df[df["classification"] == "source"]

CSV export

report.to_csv("export.csv")
# equivalent to report.to_pandas().to_csv("export.csv", index=False)

Error handling

from isof.exceptions import ISOfParseError, ISOfVersionError, ISOfSignatureError

try:
    report = isof.load("file.isof")
except ISOfVersionError as e:
    print(f"Version {e.found} not supported, please update python-isof")
except ISOfParseError as e:
    print(f"Invalid file: {e}")

# Corrupted vs. absent signature — two distinct cases
result = report.verify()
if result.level == 0:
    print("No signature in this file")
elif not result.valid:
    print(f"Signature present but invalid: {result.reason}")

ISOF format

Structure of an .isof document (JSON):

{
  "isof_version": "1.0",
  "created_at": "2025-03-10T14:32:00Z",
  "created_by": { "software", "operator", "organisation" },
  "project": { "name", "reference", "client", "classification" },
  "samples": [ ... ],       ← isotopic data per sample
  "methods": { ... },       ← preparation protocols
  "pipelines": { ... },     ← method sequences per element
  "purification": { ... },  ← measured yields per (sample, element)
  "assignments": [ ... ],   ← method ↔ sample links
  "signature": { ... }      ← optional
}

Full specification: isofind.tech/isof-spec


Development

git clone https://github.com/ColinFerrari/isof
cd isof
pip install -e ".[dev]"
pytest tests/ -v

License

MIT, see LICENSE.

This package is maintained by Colin Ferrari. The ISOF format is an open standard, third-party contributions and implementations are welcome.

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

isof-0.1.1.tar.gz (31.0 kB view details)

Uploaded Source

Built Distribution

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

isof-0.1.1-py3-none-any.whl (24.9 kB view details)

Uploaded Python 3

File details

Details for the file isof-0.1.1.tar.gz.

File metadata

  • Download URL: isof-0.1.1.tar.gz
  • Upload date:
  • Size: 31.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for isof-0.1.1.tar.gz
Algorithm Hash digest
SHA256 09b1274707491efddf683a4cb55eacf8a430e76db3b49840df27ff1c8164ae7c
MD5 e1e83803e8dfe18a739e091bfd8844ed
BLAKE2b-256 c4b7678fc700b29e32c3ed1e1ac2f3dcb12f9876c5e57ef0dc6300f4446971f9

See more details on using hashes here.

File details

Details for the file isof-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: isof-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 24.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for isof-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 faceea363f5529c1387d093e0781c851f42c7f4072b8a1e0c97faba595bbac81
MD5 d9ff42d0f064324519a73886dc8d4c31
BLAKE2b-256 dd75ebab3f331235f238de09685f9076f4b7072a5ffb8ffb19011c4e904075fd

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