Add arctan fit function to pre-edge background

This commit is contained in:
rasmusthog 2022-10-10 17:42:39 +02:00
parent fd662e3cbd
commit f30426e95d

View file

@ -1125,6 +1125,19 @@ def fit_pre_edge_feautre(data: dict, options={}) -> pd.DataFrame:
]
elif options['background_model'] == 'arctan':
popt, pcov = curve_fit(arctan, peak_background['ZapEnergy']-data['e0_diff'][filename], peak_background[filename])
background = arctan(background_df['ZapEnergy']-data['e0_diff'][filename], *popt)
background_df.insert(1, filename, background)
removed_background_df.insert(1, filename, partial_data[filename]-background_df[filename])
removed_background_df = removed_background_df.loc[(removed_background_df['ZapEnergy'] > options['background_limits'][0][1]) &
(removed_background_df['ZapEnergy'] < options['background_limits'][1][0])
]
# Fit Gaussian
@ -1208,6 +1221,10 @@ def gauss(x, A, mu, sigma):
return (A/(sigma*np.sqrt(np.pi)))*np.exp(-(x-mu)**2/(2*sigma**2))
def arctan(x,a,b,c,d):
return a*np.arctan(x*b+c) + d
def save_data(data, options={}):