Pure-Python SVC HR-1024i hyperspectral .sig processing pipeline
Project description
SIG Processing Pipeline
A pure-Python pipeline for processing SVC HR-1024i field hyperspectral .sig files. Reads raw multi-detector spectra, performs sensor stitching and radiometric correction, applies resolution-matched Gaussian smoothing, and resamples onto a uniform 1 nm grid from 400–2500 nm. Numerically verified against the legacy R/spectrolab reference to better than 1 × 10⁻⁶ absolute reflectance.
This README is the canonical entry point for both humans and LLMs. Every directory in the repo has its own
README.mddescribing its contents in detail. Follow the links below — do not assume anything that is not stated here or in the linked docs.
Repository map
| Path | Purpose | Read me first |
|---|---|---|
TUTORIAL.md |
Beginner walkthrough — starts in the Jupyter notebook (gentle path), with an advanced CLI track. | Start here if new |
pyproject.toml |
Package metadata and svc-pipeline console script. |
This file ↓ |
pipeline/ |
Core Python package: CLI, SigFileProcessor, resample_spectra, SVCDataProcessor. |
pipeline/README.md |
tests/ |
Pytest suite, including the R-vs-Python parity test. | tests/README.md |
config/ |
Run configs + instrument calibration JSONs. | config/README.md |
docs/ |
Manuscript-grade methods, parity reports, LLM re-test prompt. | docs/README.md |
archived_r_scripts/ |
Frozen R/spectrolab reference (Pipeline A) — kept only for parity verification. |
archived_r_scripts/README.md |
notebooks/ |
Demo and visualization notebooks (not on the production path). | notebooks/README.md |
naming_ids/ |
Private CSV lookup tables for grouping scans into samples; only the schema README is tracked. | naming_ids/README.md |
FOLDER_STRUCTURE.md |
Authoritative tree + reading order. | — |
ACKNOWLEDGMENTS.md |
Attribution, third-party licenses, and citation. | — |
LICENSE |
GNU General Public License v3.0. | — |
Generated outputs (gitignored): pipeline_outputs/sig_processed/<run>/, pipeline_outputs/sig_resampled/<run>/.
Quick start
New to the pipeline?
TUTORIAL.mdstarts with the interactive Jupyter notebook (the gentle path) and has an advanced track for the CLI below.
Installed from PyPI, in a new project folder (no clone of this repo needed):
python3.11 -m venv .venv
source .venv/bin/activate
python -m pip install svc-processing # package name
svc-pipeline --init-config # command name — different from the package name above
# Edit config/config.json — replace "<PATH_TO_SIG_INPUT_ROOT>" with your data path.
svc-pipeline
Working from a clone of this repo (config/config.json already exists) — run the setup script once, then activate the environment it created:
./setup.sh # creates .venv and installs the project + notebook tools
# ./setup.sh --dev # add the test & lint tools for development
source .venv/bin/activate # macOS / Linux
# .venv\Scripts\activate # Windows PowerShell
# Edit config/config.json — replace "<PATH_TO_SIG_INPUT_ROOT>" with your data path.
svc-pipeline config.json
The script always installs into this repo's .venv no matter which folder you run
it from, so it avoids the "Directory '.' is not installable" and "No module named …"
errors that come from being in the wrong directory. Prefer to do it by hand?
python3.11 -m venv .venv
source .venv/bin/activate
python -m pip install -e ".[dev,demo]"
svc-pipeline config.json
Outputs land under pipeline_outputs/ by default. See config/README.md for every supported key.
Pipeline architecture
raw *.sig files (sig_input_dir)
│
▼
┌────────────────────────────────────┐
│ Stage 1: SigFileProcessor │ pipeline/sig_processor.py
│ - instrument-consistency check │
│ - truncate at calibration │
│ end-line wavelength │
│ - write summary CSV │
└────────────────────────────────────┘
│
▼ processed *.sig + *_processed_sig_summary.csv
┌────────────────────────────────────┐
│ Stage 2: resample_spectra() │ pipeline/resampler.py
│ - detect sensor segments │
│ - guess_splice_at + trim │
│ - match_sensors (iter = 1) │
│ - smooth_fwhm (k=3 kmeans) │
│ - Gaussian resample fwhm=10 │
│ onto 400–2500 nm @ 1 nm │
└────────────────────────────────────┘
│
▼ <run>_merged_spectra.csv
┌────────────────────────────────────┐
│ Stage 3 (post-hoc, optional): │ pipeline/processor.py
│ SVCDataProcessor / │ + notebooks/
│ SigSpectraAverager — group & │
│ average scans into samples. │
└────────────────────────────────────┘
The svc-pipeline console script runs Stages 1 and 2 through pipeline.cli,
and Stage 3 too once a groups_csv is configured (or passed via
--groups-csv) — see config/README.md.
Stage 3 is also available directly from notebooks against the Stage 2 output.
The pipeline is single-pass and idempotent per input directory — previous
processed .sig files in the target directory are deleted at the start of each
run.
For the formal algorithmic spec (every constant, every formula), read docs/supplementary_methods.md. That document — not this README — is the source of truth for what the code does.
Running the pipeline
svc-pipeline [config] [options]
| Argument | Meaning |
|---|---|
config |
Run-config JSON (positional, optional; default config/config.json). Bare names resolve under config/, so config.json, config, and config/config.json are equivalent. See config/README.md for schema. |
--input-dir <path> |
Override sig_input_dir and process only this directory. |
--step {1,2,3,all} |
1 = process + summary CSV only; 2 = resample only (requires Stage 1); 3 = group + average only (requires Stage 2 and groups_csv); all = every stage that's configured (default). |
--groups-csv <path> |
Override the config's groups_csv to group repeat scans and average them. |
--group-method {mean,median,sum,min,max} |
Override the config's group_agg_method for Stage 3 (default mean). |
--verbose |
Print INFO/DEBUG logs before and after each stage. |
Expected output layout
pipeline_outputs/
├── sig_processed/<input_dir_name>/
│ ├── <truncated *.sig files>
│ └── <input_dir_name>_processed_sig_summary.csv
└── sig_resampled/<input_dir_name>/
├── <input_dir_name>_merged_spectra.csv # 2101 columns (400–2500 nm)
└── <input_dir_name>_grouped_spectra.csv # only if groups_csv is configured
summary_csv_name, merged_csv_name, and grouped_csv_name in the run config are suffixes; the real filenames are prefixed with the input directory name. Verify your config in config/README.md.
Verification (R-vs-Python parity)
The Python resampler is verified against the legacy R/spectrolab script (archived_r_scripts/merge_resample_sig.R). Acceptance threshold: 1 × 10⁻³ absolute reflectance (0.1 %, well below the HR-1024i radiometric noise floor). Historical results:
| Dataset | Samples | Max abs diff | Mean abs diff |
|---|---|---|---|
| Silver instrument (Serial 1202103) | 66 | 1.10 × 10⁻⁶ | 4.0 × 10⁻⁸ |
Bronze instrument (Serial 2212118), a4any_sb_2025-cn_ch-svc-aviris_bottom |
15 | 9.4 × 10⁻⁷ | 3.4 × 10⁻⁸ |
Run the parity test (skipped automatically without reference data):
pytest tests/test_resampler_parity.py \
--r-reference-csv=/path/to/r_output/merged_spectra.csv \
--r-input-dir=/path/to/processed_sig_files/
To re-run parity on a new dataset, hand the prompt at docs/parity_retest_prompt.md to any capable coding LLM. Full details in tests/README.md and docs/README.md.
Public Python API
The most-used entry points (all importable from their concrete modules — pipeline/__init__.py is intentionally empty):
from pipeline.sig_processor import SigFileProcessor # truncation + instrument inspection
from pipeline.resampler import process_sig_file, resample_spectra
from pipeline.notebook import Spectrum, SpectraCollection, build_config
from pipeline.processor import (
SVCDataProcessor, # chainable load/group/average
SigSpectraAverager, # facade — pass a DataFrame, get aggregated DataFrame back
GroupSpec, # GroupSpec.from_csv("naming_ids/<file>.csv")
find_spectra_by_name, # cross-DataFrame name search
)
Detailed signatures and behavioural notes in pipeline/README.md.
For LLMs working in this repo
- Read
FOLDER_STRUCTURE.mdfirst — it lists every directory and the reading order. - Before modifying
pipeline/resampler.py, re-readdocs/supplementary_methods.md. The constants_FWHM_NM,_SIGMA_NM,_INTERP_WVL,_FIXED_SENSOR,_BAND_MIN,_BAND_MAX, and the algorithm steps are load-bearing for the parity claim. Changing any of them requires re-running the parity test and writing a newdocs/parity_<dataset>_<date>.md. - The R script at
archived_r_scripts/merge_resample_sig.Ris frozen. Treat it as a behavioural reference, not as live code to edit. - Never commit machine paths or private data. Use the placeholders already present in
config/config.jsonand the notebooks. - Run
pytestafter any change topipeline/. The parity test will skip if reference data is unavailable; the rest of the suite still runs.
Demo Notebook
notebooks/pipeline_demo.ipynb is designed to
be shared as a standalone file: its first code cell checks for the notebook
helpers, installs svc-processing[demo]>=0.1.5 into the current kernel when
needed, and falls back to the public GitHub source archive while that release is
not yet on PyPI. The tutorial assumes you have an authorized folder of raw
.sig scans; set DATA_FOLDER, OUTPUT_FOLDER, INSTRUMENT, and END_LINE in
the opening cells. Raw field scans are not shipped in the public repository
because their headers can contain time and GPS metadata.
See
notebooks/pipeline_demo/README.md.
Authorized parity work can still stage the separate external field dataset with
scripts/prepare_demo_data.py; those raw files
never enter the package or default notebook path.
Requirements
Python 3.11 is the supported runtime. Runtime, demo, and development
dependencies are declared in pyproject.toml.
numpy,scipy,pandas— numerical core.matplotlib,ipykernel— demo notebook plotting and execution.pytest>=8.3.0— test runner for local verification.
Install with python -m pip install -e ".[dev,demo]" for local development and
use svc-pipeline = "pipeline.cli:main" as the command-line entry point.
R is not required for the production pipeline. It is needed only to regenerate Pipeline A parity references; see archived_r_scripts/README.md.
License
Released under the GNU General Public License v3.0 © 2026 Cole
Regnier (regs08, nr466@cornell.edu), Gold Lab
(GrapeSPEC project), Cornell University. The package uses the SPDX expression
GPL-3.0-only, chosen for compatibility with the GPL-3 spectrolab reference
implementation.
Acknowledgments & Citation
This project is an independent reimplementation of the spectrolab algorithm
(no source copied) and builds on prior field-spectroscopy work. See
ACKNOWLEDGMENTS.md for full attribution, third-party
licenses, and how to cite this software and spectrolab.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file svc_processing-0.1.6.tar.gz.
File metadata
- Download URL: svc_processing-0.1.6.tar.gz
- Upload date:
- Size: 66.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3c1738d82d748318378ff350cd523c428d9365f114e38c12167a8b4f7bc99f5
|
|
| MD5 |
d857c3a8309b58c643bc201465202667
|
|
| BLAKE2b-256 |
5c86add576f456a787daf6ad6e83684049260ca0f499b1c43a0e2fb109ac11e1
|
Provenance
The following attestation bundles were made for svc_processing-0.1.6.tar.gz:
Publisher:
publish.yml on regs08/SVCProcessingPipeline
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
svc_processing-0.1.6.tar.gz -
Subject digest:
f3c1738d82d748318378ff350cd523c428d9365f114e38c12167a8b4f7bc99f5 - Sigstore transparency entry: 2169680441
- Sigstore integration time:
-
Permalink:
regs08/SVCProcessingPipeline@443f3f69722b90e6e49ef5f22a7fa37f3c8a3f60 -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/regs08
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@443f3f69722b90e6e49ef5f22a7fa37f3c8a3f60 -
Trigger Event:
push
-
Statement type:
File details
Details for the file svc_processing-0.1.6-py3-none-any.whl.
File metadata
- Download URL: svc_processing-0.1.6-py3-none-any.whl
- Upload date:
- Size: 56.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5be868d76cb88ddabf29dd6d18e173105d86db9a160e2772ac8eacc7752e121a
|
|
| MD5 |
7a269540c865958c38b8b32d28472a7f
|
|
| BLAKE2b-256 |
e1a757a0f4850fbfae0e016fd726e022338582837d026bb2775685cd3d942b22
|
Provenance
The following attestation bundles were made for svc_processing-0.1.6-py3-none-any.whl:
Publisher:
publish.yml on regs08/SVCProcessingPipeline
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
svc_processing-0.1.6-py3-none-any.whl -
Subject digest:
5be868d76cb88ddabf29dd6d18e173105d86db9a160e2772ac8eacc7752e121a - Sigstore transparency entry: 2169680466
- Sigstore integration time:
-
Permalink:
regs08/SVCProcessingPipeline@443f3f69722b90e6e49ef5f22a7fa37f3c8a3f60 -
Branch / Tag:
refs/tags/v0.1.6 - Owner: https://github.com/regs08
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@443f3f69722b90e6e49ef5f22a7fa37f3c8a3f60 -
Trigger Event:
push
-
Statement type: