API Reference

This is the class and function reference page of SpecDAL.

Operators

Specdal’s operators perform on both pandas and specdal objects. In the following operations, pandas series and dataframes correspond to specdal’s spectrum and collection, respectively (except get_column_types - TODO: move this function to utils module).

specdal.operator.derivative(series)

Calculate the spectral derivative. Not Implemented Yet.

specdal.operator.get_column_types(df)

Returns a tuple (wvl_cols, meta_cols), given a dataframe.

Notes

Wavelength column is defined as columns with a numerical name (i.e. decimal). Everything else is considered metadata column.

specdal.operator.interpolate(series, spacing=1, method='slinear')

Interpolate the array into given spacing

Parameters:series: pandas.Series object
specdal.operator.jump_correct(series, splices, reference, method='additive')

Correct for jumps in non-overlapping wavelengths

Parameters:

splices: list

list of wavelength values where jumps occur

reference: int

position of the reference band (0-based)

specdal.operator.jump_correct_additive(series, splices, reference)

Perform additive jump correction (ASD)

specdal.operator.proximal_join(base_df, rover_df, on='gps_time_tgt', direction='nearest')

Perform proximal join and return a new dataframe.

Returns:

proximal: pandas.DataFrame object

proximally processed dataset ( rover_df / base_df )

Notes

As a side-effect, the rover dataframe is sorted by the key Both base_df and rover_df must have the column specified by on. This column must be the same type in base and rover.

specdal.operator.stitch(series, method='max')

Stitch the regions with overlapping wavelength

Parameters:series: pandas.Series object

Spectrum

class specdal.spectrum.Spectrum(name=None, filepath=None, measurement=None, measure_type='pct_reflect', metadata=None, interpolated=False, stitched=False, jump_corrected=False, verbose=False)

Class that represents a single spectrum

Parameters:

name: string

Name of the spectrum.

filepath: string (optional)

Path to the file to read from.

measurement: pandas.Series

Spectral measurement

metadata: OrderedDict

Metadata associated with spectrum

Notes

Spectrum object stores a single spectral measurement using pandas.Series with index named: “wavelength”.

Methods

interpolate(spacing=1, method='slinear')
jump_correct(splices, reference, method='additive')
read(filepath, measure_type, verbose=False)

Read measurement from a file.

stitch(method='mean')

Collection

class specdal.collection.Collection(name, directory=None, spectra=None, measure_type='pct_reflect', metadata=None, flags=None)

Represents a dataset consisting of a collection of spectra

Attributes

Methods

append(spectrum)

insert spectrum to the collection

data

Get measurements as a Pandas.DataFrame

data_with_meta(data=True, fields=None)

Get dataframe with additional columns for metadata fields

Parameters:

data: boolean

whether to return the measurement data or not

fields: list

names of metadata fields to include as columns. If None, all the metadata will be included.

Returns:

pd.DataFrame: self.data with additional columns

flags

A dict of flags for each spectrum in the collection

groupby(separator, indices, filler=None)

Group the spectra using a separator pattern

Returns:

OrderedDict consisting of specdal.Collection objects for each group

key: group name value: collection object

interpolate(spacing=1, method='slinear')
jump_correct(splices, reference, method='additive')
max(append=False)
mean(append=False)
median(append=False)
min(append=False)
plot(*args, **kwargs)
read(directory, measure_type='pct_reflect', ext=['.asd', '.sed', '.sig', '.pico', '.light'], recursive=False, verbose=False)

read all files in a path matching extension

spectra

A list of Spectrum objects in the collection

std(append=False)
stitch(method='max')
to_csv(*args, **kwargs)