from fastcore.test import *Datasets
Toy spectral datasets that ship with the package
Exported source
def load_toy_mir():
"Load the toy MIR dataset."
df_mir = pd.read_csv(files('soilspectfm')/'data'/'toy_mir.csv.gz')
ws = df_mir.columns.astype(int).to_numpy()
X = df_mir.values
return X, wsload_toy_mir returns 50 MIR spectra as X, with shape (50, 1701), and their wavenumbers ws, from 600 to 4000 cm⁻¹ every 2 cm⁻¹. The data ships with the package, so it loads without a network connection:
X, ws = load_toy_mir()
test_eq(X.shape, (50, 1701))
ws[[0, -1]]array([ 600, 4000])
load_toy_noisy_mir
def load_toy_noisy_mir():Load the toy noisy MIR dataset: spectra, wavenumbers and sample IDs
Exported source
def load_toy_noisy_mir():
"Load the toy noisy MIR dataset: spectra, wavenumbers and sample IDs"
df = pd.read_csv(files('soilspectfm')/'data'/'toy_noisy_mir.csv.gz')
sample_ids = df.sample_id.values
wavenumbers = df.columns[1:].to_numpy().astype(float)
spectra = df.iloc[:, 1:].to_numpy()
return spectra, wavenumbers, sample_idsload_toy_noisy_mir returns 48 noisy MIR spectra, with shape (48, 3315), their wavenumbers from 599.9 to 3998.4 cm⁻¹ (about every 1 cm⁻¹), and a sample ID for each spectrum. The scans come from a potassium (K) spiking experiment, for a publication in progress:
X, wns, smp_id = load_toy_noisy_mir()
test_eq(X.shape, (48, 3315))
smp_id[:3]<StringArray>
['TM4.1-0-2', 'SPA1-3-2', 'SPA1-2-2']
Length: 3, dtype: str