SpectrumList#
- class specutils.SpectrumList(*args, **kwargs)[source]#
-
A list that is used to hold a list of
SpectrumobjectsThe primary purpose of this class is to allow loaders to return a list of spectra that have different shapes. For spectra that have the same shape but different spectral axes, see
SpectrumCollection. For a spectrum or spectra that all share the same spectral axis, useSpectrum. For more on this topic, see Overview of How Specutils Represents Spectra.Attributes Summary
Whether the SpectrumList is in lazy-loading mode
Number of spectra in the list currently loaded
Methods Summary
check_unique_labels(labels)Check that labels are unique
from_lazy(length, loader[, cache_size, labels])Construct a lazy-loading SpectrumList.
set_id_map(id_map)Set a mapping of alternate string labels to list indices.
Attributes Documentation
- is_lazy#
Whether the SpectrumList is in lazy-loading mode
- labels#
- n_loaded#
Number of spectra in the list currently loaded
Methods Documentation
- classmethod from_lazy(length: int, loader: Callable, cache_size: int | None = None, labels: list = None) SpectrumList[source]#
Construct a lazy-loading SpectrumList.
Constructs a Spectrumlist using placeholder objects and sets a loader callable used to instantiate Spectrum objects lazily on item get. Once a Spectrum is loaded, it replaces the placeholder item, and repeated access does not re-run the loader.
If cache_size is specified, then the loader is also cached with an lru_cache.
- Parameters:
- lengthint
Total number of spectra in the list.
- loaderCallable
Callable taking an int index and returns a Spectrum.
- cache_sizeint or None, optional
If provided, wraps the loader in an lru_cache of this size.
- labelslist, optional
Optional list of placeholder display labels shown by the repr before spectra are materialized.
- Returns:
- SpectrumList
A lazy-loadable SpectrumList