pop_analysis_pipeline (analysis-pipeline, module spectra_core)
Core runtime of the spectral processing pipelines shared by ONE-PIX and PRO-PIX: plugin discovery, a pipeline of plugins, and a runner for real measurements.
pip install analysis-pipeline # or, for development: pip install -e .
Python 3.8 or later. Only dependency: numpy.
Plugins
Plugins are packages declared on the spectra.providers entry point. Every module
of the package that defines name and transform (or analyze) is a plugin:
[project.entry-points."spectra.providers"]
basic_treatments = "basic_treatments"
name = "crop"
def transform(spectrum, wavelengths, min_wl: float = 500.0, max_wl: float = 700.0):
...
return new_spectrum, new_wavelengths # transform: a spectrum on a grid
name = "indices"
def analyze(spectrum, wavelengths, indices: Optional[List[Literal["ndvi", "savi"]]] = None):
return {"ndvi": 0.72} # analysis: {name: number}
One spectrum at a time (1D arrays). The parameters are described from the signature
(discover_transforms() / discover_analyses() fill TRANSFORMS / ANALYSES
with {"fn", "params": {name: {"type", "default"}}}). A Literal annotation adds
"options" (the values to pick from) and "multiple" (a list of them); "type"
and "default" are unchanged.
Existing providers: basic-treatments (crop, smoothing, SNV, derivative...),
spectral-indices (NDVI, PRI, Brix...).
Pipeline
from spectra_core.data import SpectralData
from spectra_core.pipeline import Pipeline
from spectra_core.plugins.discovery import discover_transforms, discover_analyses
discover_transforms(); discover_analyses()
result = Pipeline([("snv", {}), ("crop", {"min_wl": 600, "max_wl": 1800}),
("indices", {"indices": ["ndvi"]})]).run(SpectralData(values, wavelengths))
# transforms only: SpectralData; with analyses: one {index: value} per spectrum
Transforms first, then analyses. Pipeline.run processes the matrix as it is: a
spectrum with a missing band (NaN) gives NaN.
Runner for real measurements (spectra_core.engine)
The plugins are not NaN-safe, while real spectra have bands that were not measured
(beyond a detector, too little light...). run handles them, checks the pipeline,
and processes identical spectra once:
from spectra_core.engine import run, validate, PipelineError
res = run(values, wavelengths, steps, missing="per_spectrum") # (n, bands), NaN allowed
res.kind # "spectra" or "indices"
res.values, res.wavelengths # transformed spectra (n, bands'), NaN where not processed
res.indices["ndvi"] # one value per spectrum
res.to_legacy() # what Pipeline.run returns
missing |
Use | What it does |
|---|---|---|
"per_spectrum" (default) |
a few spectra, exact | each spectrum alone, on its measured bands; one output grid |
"fill" |
thousands of spectra (hypercubes) | leaves out bands measured in < 50 % of the spectra and spectra measured in < 80 % of the other bands, interpolates the few NaN left, runs once; interpolated values are NaN again in the transformed spectra |
unique=True processes identical spectra once. The result is compact
(rows / row_indices: one row per distinct spectrum, row_of: the row of each
input spectrum) and is expanded only by values / indices.
validate(steps, allow_analyses=True) raises PipelineError for an unknown plugin,
a transform after an analysis, or analyses where they are not allowed; res.notes
says what was left out or interpolated.
Tests
python -m pytest tests # tests/test_engine.py: fake plugins, no provider needed
Release
Every push to main builds the package and uploads it to PyPI (.gitlab-ci.yml):
change version in pyproject.toml first.
Metadata
Release files for analysis-pipeline 0.2.2
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 |
|---|---|---|---|---|
| analysis_pipeline-0.2.2.tar.gz | 14.6 kB | Without provenance | Details for analysis_pipeline-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| analysis_pipeline-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for analysis_pipeline-0.2.2-py3-none-any.whl |
Total release size: 27.4 kB
Release files / analysis_pipeline-0.2.2.tar.gz
| Download URL | analysis_pipeline-0.2.2.tar.gz |
|---|---|
| Size | 14.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c49c4bfb53eb1df3e5290bf1953141113156d49116da8a7f1ff7fdcb321b05c9
|
|
BLAKE2b-256 checksum How to use checksums |
685b9cf42ffe0e7c31a0134f92015e7b2ee197335e4adb1fb3f791f16199dea2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.22
|
Release files / analysis_pipeline-0.2.2-py3-none-any.whl
| Download URL | analysis_pipeline-0.2.2-py3-none-any.whl |
|---|---|
| Size | 12.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0b9107de71999c8c9ac2ba580519005986777ee0a4bfe7ababd5cf2501389006
|
|
BLAKE2b-256 checksum How to use checksums |
65b3213de7dac20ec860589334ea6a5c11aba4c47ec68d03cbabba460d3abb8f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.22
|
Security for analysis-pipeline 0.2.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.