def test_fsm_format(): filename = load_fsm_path() R = Request(filename) F = formats['FSM'] assert F.can_read(R) reader = F.get_reader(R) assert reader.get_length() == 7998 assert reader.get_meta_data()['signature'] == b'PEPE' spec = reader.get_data() assert spec.spectrum.shape == (7998, 1641) assert spec.wavelength.shape == (1641, ) spec = reader.get_data(0) assert spec.spectrum.shape == (1641, ) assert spec.wavelength.shape == (1641, ) assert spec.spectrum[0] == pytest.approx(38.656551)
def test_load_fsm_path(): path_data = load_fsm_path() assert 'datasets/data/spectra.fsm' in path_data
""" ============================================== Read FSM Perkin Elmer Spotlight IR binary file ============================================== This example shows how to read FSM file and plot the results. """ from __future__ import print_function import matplotlib.pyplot as plt from specio import specread from specio.datasets import load_fsm_path # Find the path to the FSM toy data fsm_filename = load_fsm_path() print(fsm_filename) # Read the data spectra = specread(fsm_filename) # Plot the first spectra plt.plot(spectra.wavelength, spectra.spectrum[0]) plt.show()
"""Test that all spectra files are retrieved.""" # Copyright (c) 2017 # Authors: Guillaume Lemaitre <*****@*****.**> # License: BSD 3 clause from os.path import join import pytest from specio.datasets import load_fsm_path from specio.datasets import load_mzml_path from specio.datasets import load_sp_path from specio.datasets import load_spc_path from specio.datasets import load_csv_path @pytest.mark.parametrize("path_data,extension", [(load_fsm_path(), 'fsm'), (load_mzml_path(), 'mzml'), (load_sp_path(), 'sp'), (load_spc_path(), 'spc'), (load_csv_path(), 'csv')]) def test_load_spectra_path(path_data, extension): assert join('datasets', 'data', 'spectra.' + extension) in path_data
if isinstance(spec.meta, tuple): for m in spec.meta: if filename_cmp: assert m['filename'] == basename(filename) else: assert m['filename'] else: if filename_cmp: assert spec.meta['filename'] == basename(filename) else: assert spec.meta['filename'] @pytest.mark.parametrize( "filename,filename_cmp,spectrum_shape,wavelength_shape", [(load_fsm_path(), True, (7998, 1641), (1641,)), (load_spc_path(), True, (1911,), (1911,)), (load_sp_path(), True, (3301,), (3301,)), pytest.param(load_mzml_path(), True, (282,), (282,), marks=skip_windows_py27()), (load_csv_path(), False, (84, 1732,), (1732,))]) def test_specread(filename, filename_cmp, spectrum_shape, wavelength_shape): spec = specread(filename) if isinstance(spec, Spectrum): _check_spectra(spec, filename, filename_cmp, spectrum_shape, wavelength_shape) elif isinstance(spec, list): assert all([isinstance(sp, Spectrum) for sp in spec]) sp = spec[0] _check_spectra(sp, filename, filename_cmp, spectrum_shape, wavelength_shape)