Beispiel #1
0
if output:
  plt.subplots(num=2)
  plt.xlabel(r'$t$ / s')
  plt.ylabel(r'$U$ / V')
  plt.xlim(*t_range)
  plt.plot(t, U)

i_U_max = find_peaks_cwt(U, range(1,30), noise_perc=20)
i_U_max = i_U_max[U[i_U_max] > 0.0]
i_U_max = i_U_max[t[i_U_max] > t_range[0]]
i_U_max = i_U_max[t[i_U_max] < t_range[1]]

popt, pcov = curve_fit(gauss, t[i_U_max], U[i_U_max], p0=(2.5e-3, 0.015, 0.015))
d_popt = sqrt(np.diag(pcov))
if output:
  x_fit = dpl.x_fit_like(t[i_U_max])
  y_fit = gauss(x_fit, *popt)

  data_pts, *_ = plt.plot(t[i_U_max], U[i_U_max], marker='o', ls='None')
  plt.plot(x_fit, y_fit, color=data_pts.get_color())

if output:
  print(dpr.val(popt[2], d_popt[2], name='Δt', unit='s'))

delta_s = v_mov * popt[2]
d_delta_s = v_mov * d_popt[2]

if output:
  print(dpr.val(delta_s, d_delta_s, name='Δs', unit='m'))

L = 2 * pi * delta_s
Beispiel #2
0
  plt.subplots(num=2)
  plt.xlabel(r'$\omega_F / (1/s)$')
  plt.ylabel(r'$T_P / s$')

s, d_s = np.zeros(len(m)), np.zeros(len(m))
b, d_b = np.zeros(len(m)), np.zeros(len(m))
for i in range(len(m)):
  par = [omega_F[i], T_P[i], d_T_P[i], d_omega_F[i]]
  for j in range(len(par)):
    par[j] = np.insert(par[j], 0, 0.0)
  
  s[i], d_s[i], b[i], d_b[i] = dp.linreg(*par)

if output:
  for i in range(len(m)):
    x_fit = dp.x_fit_like(omega_F[i])
    y_fit, y_u_fit = dp.linreg_lines(x_fit, s[i], d_s[i], b[i], d_b[i])

    dataPts, *_ = plt.errorbar(omega_F[i], T_P[i], d_T_P[i], d_omega_F[i], fmt='o')
    plt.plot(x_fit, y_fit, color=dataPts.get_color(), label='Fit')
    plt.plot(x_fit, y_u_fit, color=dataPts.get_color(), label='Fit uncertainty', ls='dashed')
    # plt.legend()

if output:
  print(dpr.tbl([
    dpr.lst(s, d_s, name='s', unit='s^2', prefix=False, exp_to_fix=0)
  ]))

I_z_ = m * g * l / (2 * pi) * s
d_I_z_ = I_z_ * d_s / s
Beispiel #3
0
omega_F = 2 * pi * f_F
d_omega_F = 2 * pi * d_f_F
omega_N = 2 * pi * f_N
d_omega_N = 2 * pi * d_f_N

## Evaluation
if output:
  plt.subplots(num=5)
  plt.xlabel(r'$\omega_N$ / (1/s)')
  plt.ylabel(r'$\omega_F$ / (1/s)')

s, d_s, b, d_b = dpl.linreg(omega_N, omega_F, d_omega_F, d_omega_N)
if output:
  print(dpr.val(s, d_s, name='s'))
if output:
  x_fit = dpl.x_fit_like(omega_N)
  y_fit, y_u_fit = dpl.linreg_lines(x_fit, s, d_s, b, d_b)

  dataPts, *_ = plt.errorbar(omega_N, omega_F, d_omega_F, d_omega_F, fmt='o')
  plt.plot(x_fit, y_fit, label='Fit', color=dataPts.get_color())
  plt.plot(x_fit, y_u_fit, label='Fit uncertainty', color=dataPts.get_color(), ls='dashed')
  plt.legend()

I_x = I_z_ * s
d_I_x = I_x * sqrt((d_I_z_ / I_z_)**2 + (d_s / s)**2)

if output:
  print(dpr.val(I_x / (cs.gram * cs.centi**2), d_I_x / (cs.gram * cs.centi**2),
    name='I_x', unit='g cm^2'))

if output:
Beispiel #4
0

## Evaluation
def omega_fit(t, delta, omega_0):
    return omega_0 * exp(-delta * t)


popt, pcov = curve_fit(omega_fit, t, omega, p0=(1 / 1000, 80), sigma=d_omega)
if output:
    plt.subplots(num=1)
    plt.xlabel(r'$t$ / s')
    plt.ylabel(r'$\omega$ / (1/s)')
    plt.yscale('log')
    lines, *_ = plt.errorbar(t, omega, d_omega, fmt='o')

    x_fit = dp.x_fit_like(t)
    y_fit = omega_fit(x_fit, *popt)
    plt.plot(x_fit, y_fit, color=lines.get_color())

delta, *_ = popt
d_delta = sqrt(pcov[0, 0])

t_h = log(2) / delta
d_t_h = t_h * d_delta / delta

if output:
    print(
        dpr.val(delta * cs.day,
                d_delta * cs.day,
                name='δ',
                unit='1/d',
Beispiel #5
0
T = 25.0
d_T = 0.05

## Data processing
h_mean = 0.5 * (hI + hF)
d_h_mean = 0.5 * (hI - hF)

## Evaluation
slope1, d_slope1, itc1, d_itc1 = dp.linreg(V, t, d_t)
if output:
  plt.subplots(num=3)
  plt.xlabel(r'V / cm$^3$')
  plt.ylabel(r't / s')
  lines, *_ = plt.errorbar(*dp.to_units(V, t, d_t, x_unit=cs.centi**3), fmt='o')

  x_line = dp.x_fit_like(V)
  y_line, y_uline = dp.linreg_lines(x_line, slope1, d_slope1, itc1, d_itc1)
  plt.plot(*dp.to_units(x_line, y_line, x_unit=cs.centi**3), label='Fit', color=lines.get_color())
  plt.plot(*dp.to_units(x_line, y_uline, x_unit=cs.centi**3), label='Fit uncertainty', color=lines.get_color(), ls='dashed')

if output:
  print(dpr.val(slope1 * cs.centi**3, d_slope1 * cs.centi**3, name='slope1', unit='s / cm^3'))

J = 1 / slope1
d_J = J * d_slope1 / slope1

if output:
  print(dpr.val(J / cs.milli**3, d_J / cs.milli**3, name='J', unit='mm^3 / s'))

p_tube = h_mean * rho_peg * g
d_p_tube = p_tube * sqrt((d_h_mean / h_mean)**2 + (d_rho_peg / rho_peg)**2 + (d_g / g)**2)
Beispiel #6
0
omega_F = 2 * pi * f
d_omega_F = omega_F * d_f / f
Omega = 2 * pi / t
d_Omega = Omega * d_t / t

## Evaluation
if output:
    plt.subplots(num=4)
    plt.xlabel(r'$\Omega$ / (1/s)')
    plt.ylabel(r'$\omega_F$ / (1/s)')

s, d_s, b, d_b = dpl.linreg(Omega, omega_F, d_omega_F, d_Omega)
if output:
    print(dpr.val(s, d_s, name='s'))
if output:
    x_fit = dpl.x_fit_like(Omega)
    y_fit, y_u_fit = dpl.linreg_lines(x_fit, s, d_s, b, d_b)

    dataPts, *_ = plt.errorbar(Omega, omega_F, d_omega_F, d_Omega, fmt='o')
    plt.plot(x_fit, y_fit, color=dataPts.get_color(), label='Fit')
    plt.plot(x_fit,
             y_u_fit,
             color=dataPts.get_color(),
             label='Fit uncertainty',
             ls='dashed')
    plt.legend()

delta_I = I_z_ / (s - 1)
d_delta_I = delta_I * sqrt((d_I_z_ / I_z_)**2 + (d_s / (s - 1))**2)

if output:
Beispiel #7
0
            ]
        ]))

popts = np.zeros((len(p), 2))
d_popts = np.zeros((len(p), 2))
for i in range(len(p)):
    popt = dpl.linreg(m, p[i], d_p[i])
    popts[i] = popt[0], popt[2]
    d_popts[i] = popt[1], popt[3]

if output:
    fig, axes = plt.subplots(num=1, nrows=2, ncols=2)
    plt.subplots_adjust(hspace=0.25, wspace=0.25)
    axes[-1][-1].axis('off')
    for i in range(len(popts)):
        x_fit = dpl.x_fit_like(m)
        y_fit, y_u_fit = dpl.linreg_lines(x_fit, popts[i][0], d_popts[i][0],
                                          popts[i][1], d_popts[i][1])

        ax = axes[i // 2][i % 2]
        ax.set_xlabel(r'$m$')
        ax.set_ylabel(r'$p$ / kPa')
        dataPts, *_ = ax.errorbar(m, p[i] / cs.kilo, d_p[i] / cs.kilo, fmt='o')
        ax.plot(x_fit, y_fit / cs.kilo, color=dataPts.get_color())
        ax.plot(x_fit,
                y_u_fit / cs.kilo,
                color=dataPts.get_color(),
                ls='dashed')

if output:
    print(
Beispiel #8
0
if output:
  plt.subplots(num=1)
  plt.xlabel(r'$r^2$ / mm$^2$')
  plt.ylabel(r'$\frac{v}{\varrho_K - \varrho_\textnormal{PEG}} / \frac{\textnormal{cm}^4}{\textnormal{g} \, \textnormal{s}}$')
  plt.errorbar(*dp.to_units(r2, v_rho_ratio, d_v_rho_ratio, d_r2, x_unit=cs.milli**2, y_unit=(cs.centi**4 / cs.gram)), fmt='o')

v[:7] = v_c[:7]
d_v[:7] = d_v_c[:7]
v_rho_ratio = v / (rho_K - rho_peg)
d_v_rho_ratio = v_rho_ratio * sqrt((d_v / v)**2 + (d_rho_K**2 + d_rho_peg**2) / (rho_K - rho_peg)**2)
slope1, d_slope1, itc1, d_itc1 = dp.linreg(r2, v_rho_ratio, d_v_rho_ratio, d_r2)

if output:
  lines, *_ = plt.errorbar(*dp.to_units(r2, v_rho_ratio, d_v_rho_ratio, d_r2, x_unit=cs.milli**2, y_unit=(cs.centi**4 / cs.gram)), fmt='o')

  x_line = dp.x_fit_like(r2)
  y_line, y_uline = dp.linreg_lines(x_line, slope1, d_slope1, itc1, d_itc1)
  plt.plot(*dp.to_units(x_line, y_line, x_unit=(cs.milli**2), y_unit=(cs.centi**4 / cs.gram)),
    label='Fit', color=lines.get_color())
  plt.plot(*dp.to_units(x_line, y_uline, x_unit=(cs.milli**2), y_unit=(cs.centi**4 / cs.gram)),
    label='Fit uncertainty', color=lines.get_color(), ls='dashed')
  plt.legend()

if output:
  print(dpr.val(slope1 / (cs.centi**2 / cs.gram), d_slope1 / (cs.centi**2 / cs.gram),
    name='slope1', unit='cm^2 / g', prefix=False))
  print()

eta = 2 / 9 * g / slope1
d_eta = eta * sqrt((d_g / g)**2 + (d_slope1 / slope1)**2)
Beispiel #9
0
import datproc.plot as dpl
import datproc.print as dpr

import stokes as st
from stokes import a, d_a, T, d_T, eta, d_eta, t, r2_

## General
output = __name__ == '__main__'

## Evaluation
r2_cum = np.cumsum(r2_)
t_ = np.append(t[:67], t[68:-1] - (t[67] - t[66]))
popt, pcov = curve_fit(lambda x, s, b: s * x + b, t_, r2_cum)
d_popt = sqrt(np.diag(pcov))
if output:
  x_fit = dpl.x_fit_like(t_)
  y_fit, y_u_fit = dpl.linreg_lines(x_fit, popt[0], d_popt[0], popt[1], d_popt[1])

  plt.subplots(num=3)
  plt.xlabel(r'$t$ / s')
  plt.ylabel(r'$r^2$ / $\mu$m$^2$')
  plt.plot(t_, r2_cum / cs.micro**2, marker='o', ls='None')
  plt.plot(x_fit, y_fit / cs.micro**2)

if output:
  print(dpr.val(popt[0] / cs.micro**2, d_popt[0] / cs.micro**2, name='slope', unit='μm² / s'))
  print()

D = popt[0] / 4
d_D = d_popt[0] / 4