Skip to content

Spectroscopy Sketches

Michael Mommert edited this page Jun 12, 2017 · 12 revisions

Spectral model

Create a model for a molecular gas coma and fit observed line emission.

Example for radio observations

This example shows reading of an spectrum and fitting of an spectral model for a line emission.

import astropy.units as u
from sbpy.spectroscopy import read, Spectrum, SpectralModel
from sbpy.ephemeris import Ephemeris

spec = spectroscopy.read(file_name, format='fits')

A 1D spectrum could be defined using numpy arrays as well.

spec = spectroscopy.Spectrum(flux=data, dispersion=xaxis,
				unit=u.erg/u.s/u.cm**2/u.AA)

Spectrum methods and attributes

Return the y-axis converted to a new unit.

spec.convert_units(flux_unit=u.K)
spec.convert_units(dispersion_unit=u.km/u.s)
# write to FITS file
spec.write(file_name)

Model fit

Part of the line fitting can be done interactively as in IRAF.

# fit the continuum baseline
spec.baseline(subtract=True)

spec.fit(model='gaussian')

The fit type could be provided by a Haser coma model.

spec_model = SpectralModel(type='Haser', molecule='H2O')

spec.fit(model=spec_model)

print(spec.fit_info)
# plot spectral fit
spec.plot(show_fit=True)

print(spec.fit.equivalent_width)

A similar method could be used for data cubes as generated by interforemetric observations with a Spectrum3D class, where two of the axis are spatial and one is the dispersion axis.

Suggestions for treatment of Asteroids (MM)

# fitting asteroid spectrum
spec.fit(model='demeo')

# reproducing ('modeling') asteroid spectrum (from library data, DeMeo et al. 2009) 
spec_model = SpectralModel(type='demeo', type='Cgh')

# measure band depth and area
depth, area = spec.analyze_band(center=1.0) # provide rough band center wavelength