# Continuum Fitting with Python using specutils

it's my first time processing spectra from a black body radiation experiment, I'm using Python and having some troubles... I have this spectra with 2 peaks and uneven background noise which I want to normalize, I tried using specutils 1.1 "continuum-fitting" (documentation here: https://specutils.readthedocs.io/en/stable/fitting.html#continuum-fitting )

My implementation is this:

import matplotlib.pyplot as plt import numpy as np
from astropy.modeling import models
from astropy import units as u
from specutils.spectra import Spectrum1D, SpectralRegion
from specutils.fitting import fit_generic_continuum

...

x = data[:, 0]
y = data[:, 1]
plt.plot(x, y, label = 'My Data', c='C0')

spectrum = Spectrum1D(flux=y*u.Jy, spectral_axis=x*u.um)
g1_fit = fit_generic_continuum(spectrum)
y_fit = g1_fit(x*u.um)

plt.plot(x, y_fit, label = ' Specutils Continuum Fit', c='C1')

plt.legend()


But the result is somewhat disappointing

Am I doing something wrong? Do you have any other way to normalize the background noise in python? any suggestion at all?

• What is your purpose? Removing the peaks only? – Laurent Duval Nov 22 '20 at 11:35
• Yes, at the end I used a median filtering technique – Alessandro Romancino Nov 23 '20 at 12:03

...