fibre_walk_project_code/scripts/transients_without_amplification.py

37 lines
1 KiB
Python
Raw Normal View History

import sys
from ringfit import data
import matplotlib.pyplot as plt
from ringfit.data import *
from ringfit.plotting import *
from ringfit.fit import *
2024-05-21 15:18:18 -04:00
path = "/home/hiro/Documents/org/roam/code/fitting_ringdown/data/08_05_24/characterization_first"
scan = ScanData.from_dir(path)
2024-05-17 20:14:25 -04:00
# %% interactive
2024-05-21 15:18:18 -04:00
STEPS = [25, 27, 28]
2024-05-17 20:14:25 -04:00
fig = plt.figure("interactive")
2024-05-21 15:18:18 -04:00
fig.clf()
ax, *axs = fig.subplots(1, len(STEPS) + 1)
plot_scan(
scan, smoothe_output=10 ** (-6), normalize=True, laser=True, steps=True, ax=ax
)
2024-05-21 15:18:18 -04:00
# %% plot steps
2024-05-17 20:14:25 -04:00
for ax, STEP in zip(axs, STEPS):
2024-05-21 15:18:18 -04:00
data = scan.for_step(step=STEP).smoothed(10**-6)
t, o, params, cov, scaled = fit_transient(data.time, data.output)
2024-05-21 15:18:18 -04:00
ax.cla()
2024-05-17 20:14:25 -04:00
ax.plot(t, o)
ax.plot(t, transient_model(t, *params))
ax.set_title(
2024-05-21 15:18:18 -04:00
f"Transient {STEP}, γ={1/scaled[1] * 10**6:.2f}μs ({cov[1]/scaled[1]**2 * 10**6:.2f}μs)\n ω/2π={scaled[0] / (2*np.pi * 10**3):.5f}kHz\n step={STEP}"
)
freq_unit = params[1] / scaled[1]
2024-05-17 20:14:25 -04:00
ax.plot(t, np.sin(2 * np.pi * 4 * 10**4 * t * freq_unit), alpha=0.1)