def convolve_template(): from plot_Profile_evolution import all_obs import numpy as np date_list, observations = all_obs() x = np.arange(512 - 25 - 50, 512 + 45 + 51) delay = [] for n in observations: best_mu = 0 best_corr = 0 for mu in np.linspace(512 - 25, 512 + 45, 701): template = np.exp(-(x - 512) ** 2 / (2.0 * 6.2 ** 2)) + 0.09 * np.exp(-(x - mu) ** 2 / (2.0 * 8.0 ** 2)) template /= template.max() corr = np.correlate(n, template, mode="valid").max() if corr > best_corr: best_corr = corr best_mu = mu delay.append(best_mu - 512) plt.plot(date_list, delay, "ko") plt.show()
def fit_all_good(): from plot_Profile_evolution import all_obs import fitting_position import numpy as np import matplotlib.pyplot as plt date_list, observations = all_obs() idx = np.array([3, 6, 7, 8, 9, 10, 11, 12, 14, 25, 26, 28, 84, 94, 97, 98, 99]) idx = np.hstack([idx, range(100, 155)]) date_list = date_list[idx] observations = observations[idx] observations = observations[:, 450:700] params, params_err = fitting_position.fitting(observations) delay = (params[:, 3] - params[:, 0]) / 1024.0 * 0.5384688219194 * 1000 delay_err = np.sqrt(params_err[:, 3] ** 2 + params_err[:, 0] ** 2) / 1024.0 * 0.5384688219194 * 1000 f, (ax1, ax2) = plt.subplots(2, sharex=True) ax1.errorbar(date_list, delay, yerr=delay_err, fmt="ko") ax2.errorbar(date_list, params[:, 2], yerr=params_err[:, 2], fmt="ko") f.subplots_adjust(hspace=0) plt.setp([a.get_xticklabels() for a in f.axes[:-1]], visible=False) plt.show()
def fit_all(): from plot_Profile_evolution import all_obs import fitting_position import numpy as np import matplotlib.pyplot as plt date_list, observations = all_obs() def gauss(x, *p): mu1, mu2 = p return np.exp(-(x - mu1) ** 2 / (2.0 * 6.2 ** 2)) + 0.09 * np.exp(-(x - mu2) ** 2 / (2.0 * 8.0 ** 2)) def fit(prof): x = np.arange(prof.size) coeff, var_matrix = curve_fit(gauss, x, prof, p0=p0, maxfev=10000) return coeff[1] - coeff[0] delay = [] for n in observations: d = fit(n) delay.append(d) plt.plot(date_list, n, "ko") plt.show()
import plot_Profile_evolution import DMvariation import matplotlib.pyplot as plt f, (ax1, ax2) = plt.subplots(1, 2, sharey=True) date_list, observations = plot_Profile_evolution.all_obs() plot_Profile_evolution.plot_image(date_list, observations, ax=ax1) DMvariation.DMvariation(ax=ax2, horizontal=False) plt.show()