Spectrum

class sbpy.spectroscopy.Spectrum(flux, dispersionaxis, unit)[source]

Bases: object

Methods Summary

baseline(self[, subtract])

fit baseline to Spectrum instance

convert_units(self, \*\*kwargs)

Convert Spectrum units as provided by user

fit(self, spec)

Fit SpectralModel to different model types

integrated_flux(self, frequency[, interval])

Calculate integrated flux of emission line.

plot(self)

Plot spectrum

read(filename[, columns])

Read spectrum from file

slope(self[, subtract])

fit slope to Spectrum instance

write(self, filename[, columns])

Write spectrum to file

Methods Documentation

baseline(self, subtract=False)[source]

fit baseline to Spectrum instance

Parameters
subtractbool, optional, default=False

if True, subtract the baseline

Returns
float

Examples

>>> baseline = spec.baseline() # doctest: +SKIP
>>> spec.baseline(subtract=True) # doctest: +SKIP

not yet implemented

convert_units(self, **kwargs)[source]

Convert Spectrum units as provided by user

Examples

>>> spec.convert_units(flux_unit=u.K) # doctest: +SKIP
>>> spec.convert_units(dispersion_unit=u.km/u.s) # doctest: +SKIP

not yet implemented

fit(self, spec)[source]

Fit SpectralModel to different model types

Parameters
specstr, mandatory

SpectralModel instance to fit

Examples

>>> spec_model = SpectralModel(type='Haser', molecule='H2O')        # doctest: +SKIP
>>> spec.fit(spec_model) # doctest: +SKIP
>>> print(spec.fit_info) # doctest: +SKIP

not yet implemented

integrated_flux(self, frequency, interval=<Quantity 1. km / s>)[source]

Calculate integrated flux of emission line.

Parameters
frequencyQuantity

Transition frequency

intervalQuantity

line width

Examples

>>> flux = spec.integrated_flux(frequency=556.9*u.GHz, # doctest: +SKIP
>>>                             interval=1.7*u.km/u.s) # doctest: +SKIP

not yet implemented

plot(self)[source]

Plot spectrum

Returns
matplotlib.pyplot instance
not yet implemented
classmethod read(filename, columns='auto')[source]

Read spectrum from file

Parameters
filenamestr, mandatory

data file name

columnsstr or list-like, optional, default: ‘auto’

file format, auto will try to recognize the format automatically

Returns
Spectrum instance

Examples

>>> spec = Spectrum.read('2012_XY.dat') # doctest: +SKIP

not yet implemented

slope(self, subtract=False)[source]

fit slope to Spectrum instance

Parameters
subtractbool, optional, default=False

if True, subtract the slope

Returns
float

Examples

>>> slope = spec.slope() # doctest: +SKIP
>>> spec.slope(subtract=True) # doctest: +SKIP

not yet implemented

write(self, filename, columns='all')[source]

Write spectrum to file

Parameters
filenamestr, mandatory

data file name

columnsstr or list-like, optional: default: ‘all’

file format; all will write all fields to the file

Examples

>>> spec = Spectrum.read('2012_XY.dat') # doctest: +SKIP
>>> spec.write('2012_XY.dat.bak') # doctest: +SKIP

not yet implemented