jkrogager / VoigtFit

Python code to fit absorption lines semi-interactively
http://voigtfit.readthedocs.io/
MIT License
28 stars 12 forks source link

Chebyshev polynomial and incorrect final normalization? #39

Closed dciampa closed 3 years ago

dciampa commented 3 years ago

Up until now I have primarily used spline continuum fitting and have had no issues with the normalization. Recently, I tried to use Chebyshev polynomials for the continuum, but am noticing some irregular results. When I first fit the continuum the immediate normalization looks fine and is very well horizontally aligned. However, the final plot_fit pdf has the continuum no long normalized well. I'm including an example of this. On the left, during the masking phase you see the continuum normalized yet the final fit shows the continuum residing below the expected horizontal dashed line at 1. I'll also include some of my code that I am running:

dataset.cheb_order = 1
dataset.prepare_dataset(norm=True, mask=True)

popt, chi2 = dataset.fit()

dataset.plot_fit(filename=dataset.name+".pdf")

dataset.save()
dataset.save_parameters(dataset.name+".fit")
dataset.save_cont_parameters_to_file(dataset.name+".cont")
dataset.save_fit_regions(dataset.name+".reg")
VoigtFit.output.save_individual_components(dataset=dataset,filename=dataset.name+".ind")

Screen Shot 2021-06-01 at 12 05 09 PM

dciampa commented 3 years ago

Also, just for example. When using spline fitting the result is as such: Screen Shot 2021-06-01 at 12 15 44 PM

jkrogager commented 3 years ago

In order to constrain the Chebyshev polynomial you also have to include the continuum region in the fit. Right now you are masking out all the continuum region and therefore the code cannot properly constrain the polynomium.