specio.core.Spectrum¶
-
class
specio.core.
Spectrum
(amplitudes, wavelength, meta=None)[source][source]¶ Class containing the spectrum information.
This data structure is used and returned by
specio.specread()
.Parameters: amplitudes : ndarray, shape (n_wavelength) or (n_spectra, n_wavelength)
The amplitudes or counts.
wavelength : ndarray, shape (n_wavelength,)
The corresponding wavelength.
meta : dict or tuple of dict
The dictionary containing the meta data. When several spectrum have been compressed, a tuple of dictionary is returned.
Notes
See General presentation of the Spectrum data structure.
Methods
__init__
(amplitudes, wavelength[, meta])to_csv
(filename)Export the Spectrum into CSV. to_dataframe
()Export the Spectrum to a pandas DataFrame. -
to_csv
(filename)[source][source]¶ Export the Spectrum into CSV.
Parameters: filename : str
File path
Returns: None
-
to_dataframe
()[source][source]¶ Export the Spectrum to a pandas DataFrame.
Returns: df_spectrum : DataFrame,
A pandas DataFrame containing the information from a Spectrum. The index corresponds to the filename and the columns corresponds to the wavelengths.
Examples
>>> from specio import specread >>> from specio.datasets import load_spc_path >>> spectra = specread(load_spc_path()) x-y(1) >>> df = spectra.to_dataframe() >>> df.loc[:, df.columns < 410] # print a subset of the DataFrame 400.621094 402.943848 405.267212 407.588501 409.910400 spectra.spc 1487.0 1385.0 1441.0 1504.0 1509.0
-