SpectrumList

class specutils.SpectrumList(iterable=(), /)[source]

Bases: list, NDIOMixin

A list that is used to hold a list of Spectrum1D objects

The 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, use Spectrum1D. For more on this topic, see Overview of How Specutils Represents Spectra.

Attributes Summary

read

Read and parse gridded N-dimensional data and return as an NDData-derived object.

write

Write this CCDData object out in the specified format.

Methods Summary

append(object, /)

Append object to the end of the list.

clear(/)

Remove all items from list.

copy(/)

Return a shallow copy of the list.

count(value, /)

Return number of occurrences of value.

extend(iterable, /)

Extend list by appending elements from the iterable.

index(value[, start, stop])

Return first index of value.

insert(index, object, /)

Insert object before index.

pop([index])

Remove and return item at index (default last).

remove(value, /)

Remove first occurrence of value.

reverse(/)

Reverse IN PLACE.

sort(*[, key, reverse])

Sort the list in ascending order and return None.

Attributes Documentation

read

Read and parse gridded N-dimensional data and return as an NDData-derived object.

This function provides the NDDataBase interface to the astropy unified I/O layer. This allows easily reading a file in the supported data formats, for example:

>>> from astropy.nddata import CCDData
>>> dat = CCDData.read('image.fits')

Get help on the available readers for CCDData using the``help()`` method:

>>> CCDData.read.help()  # Get help reading CCDData and list supported formats
>>> CCDData.read.help('fits')  # Get detailed help on CCDData FITS reader
>>> CCDData.read.list_formats()  # Print list of available formats

For more information see:

Parameters:
*argstuple, optional

Positional arguments passed through to data reader. If supplied the first argument is the input filename.

formatstr, optional

File format specifier.

cachebool, optional

Caching behavior if file is a URL.

**kwargsdict, optional

Keyword arguments passed through to data reader.

Returns:
outNDData subclass

NDData-basd object corresponding to file contents

write

Write this CCDData object out in the specified format.

This function provides the NDData interface to the astropy unified I/O layer. This allows easily writing a file in many supported data formats using syntax such as:

>>> from astropy.nddata import CCDData
>>> dat = CCDData(np.zeros((12, 12)), unit='adu')  # 12x12 image of zeros
>>> dat.write('zeros.fits')

Get help on the available writers for CCDData using the``help()`` method:

>>> CCDData.write.help()  # Get help writing CCDData and list supported formats
>>> CCDData.write.help('fits')  # Get detailed help on CCDData FITS writer
>>> CCDData.write.list_formats()  # Print list of available formats

For more information see:

Parameters:
*argstuple, optional

Positional arguments passed through to data writer. If supplied the first argument is the output filename.

formatstr, optional

File format specifier.

**kwargsdict, optional

Keyword arguments passed through to data writer.

Methods Documentation

append(object, /)

Append object to the end of the list.

clear(/)

Remove all items from list.

copy(/)

Return a shallow copy of the list.

count(value, /)

Return number of occurrences of value.

extend(iterable, /)

Extend list by appending elements from the iterable.

index(value, start=0, stop=sys.maxsize, /)

Return first index of value.

Raises ValueError if the value is not present.

insert(index, object, /)

Insert object before index.

pop(index=-1, /)

Remove and return item at index (default last).

Raises IndexError if list is empty or index is out of range.

remove(value, /)

Remove first occurrence of value.

Raises ValueError if the value is not present.

reverse(/)

Reverse IN PLACE.

sort(*, key=None, reverse=False)

Sort the list in ascending order and return None.

The sort is in-place (i.e. the list itself is modified) and stable (i.e. the order of two equal elements is maintained).

If a key function is given, apply it once to each list item and sort them, ascending or descending, according to their function values.

The reverse flag can be set to sort in descending order.