Want to talk about soil? Join us for Open Call every Tuesday until Mar. 30 and our kick-off call on this topic on Feb. 2! Click here for details on how to join!

# Spectral Workbench Operations

A major change in Spectral Workbench 2 is a system called Operations (previously known as PowerTags). When you save a spectrum, you usually have to perform additional operations, sometimes setting a cross section, certainly calibrating, and sometimes then smoothing or otherwise manipulating the data. But for various reasons, you often want to record and even revert some of those changes. Maybe you want to do them differently, or to recalibrate. cr Operations are the new way to do this. Each time you apply an operation, the resulting dataset is saved in a snapshot, so that a copy is archived and available in the database without having to run each calculation every time. operations typically feature a key:value pair.

### How to use operations

Creating operations is easy; the Tools menu below each spectrum guides you through creating them with simple toolpanes. Learn about using Spectral Workbench 2's tools here.

Watch this video about using Operations via the toolpanes:

## Available operations

Operations include:

#### calibrate

calibrate:<id> - Copies calibration from spectrum with given <id>.

#### linearCalibration

linearCalibration:<b2>,<g2> - Manually calibrated with two reference points <b2> and <g2>, which correspond to known positions 435.83 and 546.07, respectively. This should be the first operation, as it works best on sharp, full-width data that has not been range-limited or smoothed. However, if a crossSection or forked operation precedes it, that's acceptable.

#### range

range:<min>-<max> - Limits wavelength range to specified <min>-<max>, in nanometers, or if data is uncalibrated, then in pixels.

#### smooth

smooth:<amount> - Rolling average smoothing by given # <amount> of pixels.

#### subtract

subtract:<id> - Subtracts spectrum with given <id> from the current spectrum. Should point at a specific snapshot with syntax subtract:<id>#<snapshot_id>

#### crossSection

crossSection:<height> - Sets the row of pixels, counting pixels from top row, used to generate the graph. The default for any spectrum is the top row of pixels, the equivalent of crossSection:0, whereas crossSection:20 would measure the brightness of each pixel in the 21st row down from the top (since we begin counting at 0). Please read this section about what the cross section represents, as it may vary based on how you are capturing.

#### transform

transform:<expression> - Filters this spectrum with a math <expression>, by running the brightness of each pixel through the math expression. More on this soon.

#### blend

blend:<expression> - Filters this spectrum with a math <expression>, like transform:, but in combination with data from a given second spectrum. This allows for, for example, multiplying or dividing two spectra.

## Passive Operations

Some operations don't affect the data at all; it's not clear if we're going to make these appear in the Tags listing instead. For now, these are generated automatically at various steps, and provide metadata about the spectrum, but aren't used to change the data:

#### forked

forked:<id> - Spectrum is a forked copy of the Spectrum with given <id>. Generated automatically when you fork a spectrum.

#### error

error:<amount> - Scores a calibration 'fit' by comparison to a known reference; lower is better, zero is perfect. Generated by the linear calibration tool.

#### calibrationQuality

calibrationQuality:<quality> - Roughly indicates how good a calibration 'fit' is, in qualitative terms good for <12, medium for <16 and poor for anything higher/worse. Generated by the linear calibration tool.

## Contributing

The Operations framework is designed to be flexible and extensible, as we add more abilities to Spectral Workbench. Please contact the developers list with ideas and suggestions for new features and future versions, and check out Spectral Workbench on Github at https://github.com/publiclab/spectral-workbench.

Also check out our Contributing to Public Lab Software page.