<jupyter_start><jupyter_text>Peakfit class exampleFitting is based on the LMfit library: https://lmfit.github.io/lmfit-py/index.html<jupyter_code>from nasagamma import spectrum as sp
import numpy as np
import pandas as pd
from nasagamma import peaksearch as ps
from nasagamma import peakfit as pf


# dataset 1
file = "data/SSR-mcnp.hdf"
df = pd.read_hdf(file, key='data')
df = df.iloc[1:,:]


cts_np = df.cts.to_numpy() * 1e8
erg = np.array(df.index)

# Required input parameters (in channels)
fwhm_at_0 = 1.0
ref_fwhm = 31
ref_x = 1220
min_snr = 1
# instantiate a Spectrum and a peaearch object
spect = sp.Spectrum(counts=cts_np, energies=erg)
search = ps.PeakSearch(spect, ref_x, ref_fwhm, fwhm_at_0, min_snr=min_snr)<jupyter_output><empty_output><jupyter_text>We can now define a background type: linear, quadratic, exponential, or any other n-degree polynomial.We also define a range of x-values to perform the fit<jupyter_code># peakfit class
bkg0 = 'poly2'
xrange = [2.6, 4]
fit = pf.PeakFit(search, xrange, bkg=bkg0)
fit.plot(plot_type="full", legend='on')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10877513711151737, 'fraction_numerical': 0.019195612431444242, 'mean_word_length': 5.676829268292683, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '489433', 'license': 'MIT', 'n_tokens_mistral': 446, 'n_tokens_neox': 424, 'n_words': 115, 'path': 'examples/3.peakfitting_example.ipynb', 'repo_name': 'mauricioAyllon/NASA-gamma', 'size': '1094'}