model = QENSmodels.sqwDeltaLorentz(x, q, scale, center, A0, hwhm)
    return np.convolve(model, resolution / resolution.sum(), mode='same')


# Fit
M = []

# First dataset: wavelength=5 Angstrom
for i in range(len(q)):

    # Bumps fitting model
    Mq = bmp.Curve(model_convol,
                   hw,
                   sqw[:, i],
                   err[:, i],
                   q=q[i],
                   scale=1000,
                   center=0.0,
                   A0=0.5,
                   hwhm=0.01,
                   resolution=res[:, i])
    Mq.scale.range(0, 1e5)
    Mq.center.range(-0.1, 0.1)
    Mq.A0.range(0, 1)
    Mq.hwhm.range(0, 2)

    # Q-independent parameters
    if i == 0:
        QA0 = Mq.A0
    else:
        Mq.A0 = QA0
    M.append(Mq)
示例#2
0
    x = x[valid[1]]
    if len(valid[1]) != len(x):
        print(i, "truncate to make vectors symmetric with respect to max")

    data = data[valid]
    error = error[valid]
    resol = resol[valid]

    # Teixeira model
    Mq = bmp.Curve(model_convol,
                   x,
                   data,
                   error,
                   q=q_5A[i],
                   scale=20,
                   center=0.0,
                   A0=0.0,
                   A1=0.9,
                   hwhm1=0.05,
                   hwhm2=0.3,
                   resolution=resol)

    # Fitted parameters
    Mq.scale.range(1.e-12, 20)
    Mq.center.range(-0.1, 0.1)
    Mq.A0.range(0, 0.05)
    Mq.A1.range(0, 1)
    Mq.hwhm1.range(0, 0.5)
    Mq.hwhm2.range(0, 3)

    # Q-independent parameters
示例#3
0
    resol = res_5A[idx_5A, i]

    # Select only valid data (error = -1 for Q, w points not accessible)
    valid = np.where(error > 0.0)
    x = x[valid[1]]
    data = data[valid]
    error = error[valid]
    resol = resol[valid]

    # model
    Mq = bmp.Curve(model_convol,
                   x,
                   data,
                   error,
                   q=q_5A[i],
                   scale=15,
                   center=0.0,
                   hwhm=0.1,
                   radius=1.1,
                   DR=1.,
                   resolution=resol)

    # Fitted parameters
    Mq.scale.range(0, 1e2)
    Mq.center.range(-0.1, 0.1)
    Mq.hwhm.range(0., 1)
    Mq.radius.range(0.9, 1.1)
    Mq.DR.range(0.01, 5)

    # Q-independent parameters
    if i == 0:
    resol = res_5A[idx_5A, i]

    # Select only valid data (error = -1 for Q, w points not accessible)
    valid = np.where(error > 0.0)
    x = x[valid[1]]
    data = data[valid]
    error = error[valid]
    resol = resol[valid]

    # Teixeira model
    Mq = bmp.Curve(model_convol,
                   x,
                   data,
                   error,
                   q=q_5A[i],
                   scale=10,
                   center=0.0,
                   D=0.13,
                   resTime=0.1,
                   radius=1.0,
                   DR=0.3,
                   resolution=resol)

    # Fitted parameters
    Mq.scale.range(0, 1e2)
    Mq.center.range(-0.1, 0.1)
    Mq.D.range(0.05, 0.25)
    Mq.resTime.range(0, 1)
    Mq.radius.range(0.9, 1.1)
    Mq.DR.range(0, 1)

    # Q-independent parameters
dict_physical_units = {
    'omega': "1/ps",
    'q': "1/Angstrom",
    'D': "ps.Angstrom^2",
    'L': "Angstrom",
    'scale': "unit_of_signal/ps",
    'center': "1/ps"
}

M = []
for i in range(len(q)):
    # Bumps fitting model
    Mq = bmp.Curve(QENSmodels.sqwChudleyElliotDiffusion,
                   xx,
                   chudley_elliot_noisy[i],
                   q[i],
                   scale=1,
                   center=0,
                   D=0.2,
                   L=0.7)

    Mq.scale.range(0.1, 1e5)
    Mq.center.range(-0.1, 0.1)
    Mq.D.range(0.1, 1)
    Mq.L.range(0.1, 3)

    # Q-independent parameters
    if i == 0:
        QD = Mq.D
        QL = Mq.L
    else:
        Mq.D = QD
    model = QENSmodels.sqwJumpTranslationalDiffusion(x, q, scale, center, D,
                                                     resTime)
    return np.convolve(model, resolution / resolution.sum(), mode='same')


# Fit
M = []

for i in range(len(q)):

    # Bumps fitting model
    Mq = bmp.Curve(model_convol,
                   hw,
                   sqw[:, i],
                   err[:, i],
                   q=q[i],
                   scale=1000,
                   center=0.0,
                   D=0.1,
                   resTime=0.5,
                   resolution=res[:, i])
    Mq.scale.range(0, 1e5)
    Mq.center.range(-0.1, 0.1)
    Mq.D.range(0, 1)
    Mq.resTime.range(0, 5)

    # Q-independent parameters
    if i == 0:
        QD = Mq.D
        QT = Mq.resTime
    else:
        Mq.D = QD
print(f"""The names and units of `w` (`x`axis) and `q` are: 
{str(unit_w[0], 'utf-8')} and {str(unit_q[0], 'utf-8')}, respectively.""")

# Fit
M = []

# First dataset: wavelength=5 Angstrom
for i in range(len(q)):

    # Bumps fitting model
    Mq = bmp.Curve(model_convol,
                   hw,
                   sqw[:, i],
                   err[:, i],
                   q=q[i],
                   scale=1000,
                   center=0.0,
                   radius=1.0,
                   DR=0.1,
                   resolution=res[:, i])
    Mq.scale.range(0, 1e5)
    Mq.center.range(-0.1, 0.1)
    Mq.radius.range(0, 3)
    Mq.DR.range(0, 2)

    # Q-independent parameters
    if i == 0:
        QR = Mq.radius
        QDR = Mq.DR
    else:
        Mq.radius = QR