[AstroPy] Gaussian with constant background

Erik Tollerud erik.tollerud@gmail....
Mon Jul 2 19:06:39 CDT 2012

Depending on how you think, you might also find pymodelfit
(http://packages.python.org/PyModelFit/ - for full disclosure, I'm the
author) useful - it has gaussian models for both 1D and 2D datasets
that you can just fit like:

gmod = pymodelfit.GaussianModel()
gmod.fitData(x, y)

And if you want a constant background as you're saying here, you could
just add in an offset:

gmod2 = pymodelfit.offset_model(pymodelfit.GaussianModel, 'bkgd')
gmod2.bkgd = whatever your constant background should be
gmod2.fitData(x, y, fixedpars='bkgd')

This is all scipy.optimize functions under the hood, so it should
perform pretty much the same - just rather easier to use.

On Wed, Jun 27, 2012 at 1:10 PM, Vivienne Baldassare
<vivienne.baldassare@gmail.com> wrote:
> Hello,
> I've been trying to figure out how to fit a gaussian with a constant
> (non-zero) background.  Aside from just subtracting off the background, I
> haven't been able to do it, and googling around was not particularly
> helpful.  I'd appreciate any tips!
> Best,
> Vivienne Baldassare
> _______________________________________________
> AstroPy mailing list
> AstroPy@scipy.org
> http://mail.scipy.org/mailman/listinfo/astropy

Erik Tollerud

More information about the AstroPy mailing list