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 if output:
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)
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: fig_folder_path = 'figures/spinning_top'
])) 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( dpr.tbl([dpr.lst(popts[:, 0], d_popts[:, 0], name='slope', unit='Pa')]))