import numpy as np
from numpy import exp,pi,sqrt
from scipy.optimize import curve_fit
import matplotlib.pyplot as plt
import random
import csv
from lmfit import Model
from lmfit.models import VoigtModel
#inputting the raw data as a CSV file
with open(input("Please enter the name of your CSV file "), 'r') as f:
reader = csv.reader(f, delimiter=',')
headers = next(reader)
data = [row for row in reader]
x_given = np.array([float(row[0]) for row in data])
y_given = np.array([float(row[1]) for row in data])
#accounting for the data being in Julian Days
x_p = np.linspace(2458238,2458300,1054)
#this is the gaussian from the lmfit website I was trying but was unsuccessful with
#def gaussian(x,amplitude,center,width):
#return (amplitude / (sqrt(2*pi) * width)) * exp(-(x-center)**2 / (width**2))
gmodel = VoigtModel()
pars = gmodel.guess(y_given,x=x_given)
result = gmodel.fit(y_given,pars,x=x_given)
print(result.fit_report())
plt.title('Nova Persei 2018')
plt.xlabel(headers[0])
plt.ylabel(headers[1])
plt.plot(x_given,y_given, 'D', markersize=1.8, color='green')
plt.plot(x_p,result.best_fit,'r-', markersize=100)
plt.legend(['Data','fit'], loc='best')
plt.ylim(5,13)
plt.xlim(2458238,2458307)
plt.gca().invert_yaxis()
So you can see here I'm trying to use the Voigt model. I've tried most of the built in models that are listed on the lmfit website/ "Working" in the context that I'm looking for would be like the example pictures I've attached here that are outputs from the lmfit website. The first example would be what I'm looking to do with the nova persei data and then the 2nd is what I'm looking for with the exoplanet stuff. Sorry for the confusion and being vague. Please forgive my ignorance as this is a new world for me.
Many thanks,
-Brennan