Pulse shape fitting

Neutron pulse


In [1]:
import os
import sys
root_folder = os.path.dirname(os.getcwd())
sys.path.append(root_folder)
from ResoFit._pulse_shape import NeutronPulse
from ResoFit._pulse_shape import ProtonPulse
from lmfit import Parameters
import numpy as np
import matplotlib.pyplot as plt
from lmfit import Model
import pprint
from lmfit.models import LinearModel

In [2]:
%matplotlib notebook

In [3]:
# path1 = '/Users/Shawn/Dropbox (ORNL)/Postdoc_Research/neutron_beam_shape/SNS/neutron_pulse/source_section_1.dat'
# path2 = '/Users/Shawn/Dropbox (ORNL)/Postdoc_Research/neutron_beam_shape/SNS/neutron_pulse/source_section_2.dat'
path1 = '/Users/y9z/Dropbox (ORNL)/Postdoc_Research/neutron_beam_shape/SNS/neutron_pulse/source_section_1.dat'
path2 = '/Users/y9z/Dropbox (ORNL)/Postdoc_Research/neutron_beam_shape/SNS/neutron_pulse/source_section_2.dat'

Model index:

  • 1: 'ikeda_carpenter',
  • 2: 'cole_windsor',
  • 3: 'pseudo_voigt',
  • 4: 'ikeda_carpenter_jparc',
  • 5: 'cole_windsor_jparc'

In [4]:
neutron_pulse = NeutronPulse(path1, model_index=1)
neutron_pulse.load_shape_each(path2)


/Users/y9z/anaconda3/envs/py36/lib/python3.6/site-packages/lmfit/models.py:30: FutureWarning:

'argmin' is deprecated. Use 'idxmin' instead. The behavior of 'argmin' will be corrected to return the positional minimum in the future. Use 'series.values.argmin' to get the position of the minimum now.

Fitted params for raw proton pulse shape:
Name          Value      Min      Max   Stderr     Vary     Expr Brute_Step
amplitude  1.984e+04     -inf      inf    36.58     True     None     None
center         1909     -inf      inf   0.3126     True     None     None
fwhm          345.7     -inf      inf   0.7362    False 2.3548200*sigma     None
height         53.9     -inf      inf  0.09941    False 0.3989423*amplitude/max(1.e-15, sigma)     None
sigma         146.8        0      inf   0.3126     True     None     None

In [5]:
neutron_pulse.plot_shape_total(x)



In [5]:
neutron_pulse.fit_shape(e_min=1, e_max=500,
                        drop=False, norm=True, check_each=True,
                        save_fig=False, overwrite_csv=True)


'/Users/y9z/Documents/GitHub/ResoFit/ResoFit/result/neutron_pulse/ikeda_carpenter/Neutron_fitted_params_1eV_500eV_ikeda_carpenter.csv' exists...
File overwriting...
New fitting starts...
Fitting [1.0 eV] ...
Fitting [1.122 eV] ...
Fitting [1.2589 eV] ...
Fitting [1.4125 eV] ...
Fitting [1.5849 eV] ...
Fitting [1.7783 eV] ...
Fitting [1.9953 eV] ...
Fitting [2.2387 eV] ...
Fitting [2.5119 eV] ...