Sandbox — LSD is in active testing. All systems operational·payments are test-mode (no real charges).
Overview Use Cases News Docs Tool Store Support Community Get LSD
Use cases/ Scientific Computing/ Reducing a season of spectrometer runs, reproducibly
Stacked spectrum overlaid on 900 raw runs, with cached correction steps in the node graph replace with clip · 1600 × 900

Reducing a season of spectrometer runs, reproducibly

Drag a season of spectrometer runs — 900 CSVs — onto the canvas beside the day's calibration NetCDF, and reduce them all in one pipeline. Dark and flat correction, wavelength calibration, then stacking run as live nodes with every intermediate cached. The result is a set of publication-ready spectra and a dataset export anyone can re-run against next season's runs.

▶ Video walkthrough Intermediate ⏱ 30 min spectroscopynetcdfcalibrationreproducibilitybatch

A season is a stack, not a script#

Nine hundred exposures come off the instrument over a run season, and the science lives in their stacked average — not in any one frame. The usual reduction is a folder of Python that grew a new flag every observing night, until nobody can say whether last month's spectra used the old flat or the new one. The frames hold the answer; the reduction has just become unauditable.

Why calibration is the hard part#

Darks and flats change with temperature, and the wavelength solution drifts as lamps age, so the right calibration is the one taken that day — not the one hard-coded three months ago. Loading the calibration NetCDF as its own node makes that explicit. Swap the file, and every corrected frame, every stacked spectrum, and the exported dataset recompute from it, with the provenance sitting right there in the graph.

What you'll need#

Any per-exposure CSVs with a wavelength or pixel axis and a counts column will load, plus a calibration set with darks, flats, and a wavelength solution. This walkthrough uses a season of long-slit runs and a nightly calibration NetCDF, but the pipeline doesn't care which instrument wrote the frames — point it at next season's folder and the same nodes reduce it.

Step by step

How it's built

  1. #066 · Load 01

    Drop the season's run folder on the canvas

    Drag the folder of 900 instrument CSVs onto the canvas. The @load node groups them into one runs entity keyed by timestamp, infers the wavelength and counts columns, and previews the first rows. Nothing parses fully until a step downstream asks for it, so the whole season opens in seconds.

    900 raw runs grouped into one timestamped entity with column previews replace with screenshot · 1200 × 750
  2. 02

    Bring in the calibration set

    Drag the day's calibration NetCDF next to the runs. Dark frames, the flat-field response, and the wavelength solution appear as named variables straight from the file headers. A second @load node keeps them separate, so you can swap in a different calibration later and rerun the whole reduction.

    Calibration NetCDF variables — darks, flats, wavelength solution — beside the runs replace with screenshot · 1200 × 750
  3. #067 · Shape 03

    Subtract darks and divide by flats

    Add a @shape node that subtracts the matched dark frame and divides by the flat-field response for every run. The corrected preview updates live as you choose which dark to pair by exposure time. The full corrected stack becomes a cached intermediate, so every step after it stays instant.

    Per-run dark subtraction and flat division previewing live replace with screenshot · 1200 × 750
  4. 04

    Map pixels to wavelengths

    Chain a calibration node that applies the NetCDF wavelength solution, turning pixel index into nanometres for every run at once. Drop a couple of known emission lines on the plot to check the fit, and nudge the solution if a lamp drifted overnight. Every run recolors onto the same wavelength axis.

    All runs resampled onto a common nanometre axis with reference lines replace with screenshot · 1200 × 750
  5. #068 · Shape 05

    Stack the season into one spectrum

    Add a stacking node and choose a robust mean with outlier rejection across the 900 corrected, calibrated runs. Because each upstream step is cached, changing the rejection threshold restacks in a blink instead of rereading a single CSV. The combined spectrum and its per-wavelength spread appear together.

    900 runs collapsed into one stacked spectrum with an uncertainty band replace with screenshot · 1200 × 750
  6. #069 · Deliver 06

    Export the spectra and the dataset

    Finish with a @deliver node. Render the stacked spectrum as a publication figure with labelled axes and the uncertainty band, then export the corrected, calibrated dataset as NetCDF alongside it. The pipeline file travels with the export, so a reviewer can rebuild every spectrum from the raw CSVs.

    Publication figure beside the exported NetCDF dataset and pipeline file replace with screenshot · 1200 × 750
The pipeline

Every step used, at a glance

Load

Runs + calibration

Read 900 instrument CSVs and the day's calibration NetCDF as separate, lazily-parsed entities.

CSVNetCDF
Shape

Correct, calibrate, stack

Apply dark/flat correction and the wavelength solution, then stack every run with cached intermediates.

Deliver

Spectra + dataset

Render publication-ready spectra and export the reduced dataset with its pipeline attached.

NetCDFCSV
900 → 1
runs stacked into one spectrum
Cached
restacks instantly when you retune
Reproducible
raw CSVs to figure in one file

More use cases