mirror of
https://gitlab.science.ru.nl/mthesis-edeboone/m-thesis-introduction.git
synced 2024-11-14 02:23:32 +01:00
ZH: fit gaussian to antenna clock phase figures
This commit is contained in:
parent
902362f6a9
commit
d0be6ba16f
5 changed files with 26 additions and 1 deletions
|
@ -161,7 +161,8 @@ if __name__ == "__main__":
|
||||||
actual_clock_phases,
|
actual_clock_phases,
|
||||||
plot_residuals=plot_residuals,
|
plot_residuals=plot_residuals,
|
||||||
f_beacon=f_beacon,
|
f_beacon=f_beacon,
|
||||||
figsize=figsize
|
figsize=figsize,
|
||||||
|
fit_gaussian=plot_residuals,
|
||||||
)
|
)
|
||||||
|
|
||||||
if plot_residuals:
|
if plot_residuals:
|
||||||
|
|
|
@ -125,6 +125,7 @@ if __name__ == "__main__":
|
||||||
f_beacon=f_beacon,
|
f_beacon=f_beacon,
|
||||||
figsize=figsize,
|
figsize=figsize,
|
||||||
hist_kwargs=hist_kwargs,
|
hist_kwargs=hist_kwargs,
|
||||||
|
fit_gaussian=plot_residuals,
|
||||||
)
|
)
|
||||||
|
|
||||||
axs = fig.get_axes()
|
axs = fig.get_axes()
|
||||||
|
|
|
@ -191,6 +191,7 @@ if __name__ == "__main__":
|
||||||
f_beacon=f_beacon,
|
f_beacon=f_beacon,
|
||||||
figsize=figsize,
|
figsize=figsize,
|
||||||
hist_kwargs=hist_kwargs,
|
hist_kwargs=hist_kwargs,
|
||||||
|
fit_gaussian=plot_residuals,
|
||||||
)
|
)
|
||||||
|
|
||||||
axs = fig.get_axes()
|
axs = fig.get_axes()
|
||||||
|
|
|
@ -95,6 +95,7 @@ if __name__ == "__main__":
|
||||||
figsize=figsize,
|
figsize=figsize,
|
||||||
hist_kwargs=hist_kwargs,
|
hist_kwargs=hist_kwargs,
|
||||||
secondary_axis='phase',
|
secondary_axis='phase',
|
||||||
|
fit_gaussian=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
axs = fig.get_axes()
|
axs = fig.get_axes()
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
from scipy.stats import norm
|
||||||
|
|
||||||
def phase_comparison_figure(
|
def phase_comparison_figure(
|
||||||
measured_phases,
|
measured_phases,
|
||||||
true_phases,
|
true_phases,
|
||||||
|
@ -11,6 +13,7 @@ def phase_comparison_figure(
|
||||||
colors=['blue', 'orange'],
|
colors=['blue', 'orange'],
|
||||||
legend_on_scatter=True,
|
legend_on_scatter=True,
|
||||||
secondary_axis='time',
|
secondary_axis='time',
|
||||||
|
fit_gaussian=False,
|
||||||
**fig_kwargs
|
**fig_kwargs
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
|
@ -53,6 +56,24 @@ def phase_comparison_figure(
|
||||||
if not plot_residuals: # also plot the true clock phases
|
if not plot_residuals: # also plot the true clock phases
|
||||||
axs[i].hist(true_phases, color=colors[1], label='Actual', ls='dashed', **{**hist_kwargs, **dict(bins=_bins)})
|
axs[i].hist(true_phases, color=colors[1], label='Actual', ls='dashed', **{**hist_kwargs, **dict(bins=_bins)})
|
||||||
|
|
||||||
|
if fit_gaussian:# Fit a gaussian to the histogram
|
||||||
|
gauss_kwargs = dict(color=colors[0], ls='dotted')
|
||||||
|
xs = np.linspace(min(_bins), max(_bins))
|
||||||
|
|
||||||
|
mean, std = norm.fit(measured_phases)
|
||||||
|
dx = _bins[1] - _bins[0]
|
||||||
|
scale = len(measured_phases)*dx
|
||||||
|
fit_ys = norm.pdf(xs, mean, std) * scale
|
||||||
|
|
||||||
|
axs[i].axvline(mean, ls='dotted', color='k', lw=2)
|
||||||
|
|
||||||
|
axs[i].plot( xs, fit_ys, label='fit', **gauss_kwargs)
|
||||||
|
|
||||||
|
# put mean, sigma and chisq on plot
|
||||||
|
text_str = f"$\\mu$ = {mean: .2e}\n$\\sigma$ = {std: .2e}"
|
||||||
|
text_kwargs = dict( transform=axs[i].transAxes, fontsize=14, verticalalignment='top')
|
||||||
|
axs[i].text(0.02, 0.95, text_str, **text_kwargs)
|
||||||
|
|
||||||
# Scatter plot
|
# Scatter plot
|
||||||
if do_scatter_plot:
|
if do_scatter_plot:
|
||||||
i=1
|
i=1
|
||||||
|
|
Loading…
Reference in a new issue