Commit 2fdd462f authored by Marcelo Luda's avatar Marcelo Luda

pulí un poco el lolo-superajuste

parent 6e4b9258
......@@ -405,7 +405,7 @@ for Detunings_3_SA_short,CountsDR,Detunings_3_SA_long,FittedEITpi_3_SA_long,sele
ax.grid(True, ls=":")
print(f'listo med {selectedcurve}')
print(popt_3_SA)
# print(popt_3_SA)
for ax in axx[:,0]:
......@@ -452,58 +452,86 @@ ax.set_xticks(num_med)
ax.set_xlabel('Num. de medición')
#%%
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#%% Endcap hiperbola (con residuos)
"""
Grafico distintas variables que salieron del SUper ajuste
Veamos cómo varía el Beta con el voltaje del endcap
"""
import seaborn as sns
paleta = sns.color_palette("rocket")
voltages_dcA = Voltages[0][1:10]
I = slice(None,9)
voltages_dcA = Voltages[0][SelectedCurveVec]
def lineal(x,a,b):
return a*x+b
def hiperbola(x,a,b,c,x0):
return a*np.sqrt(((x-x0)**2+c**2))+b
def hiperbola(x,a,y0,b,x0):
"""
Hiperbola de ecuación:
1 =(y-y0)²/a² - (x-x0)²/b²
"""
return a*np.sqrt(((x-x0)**2+b**2))+y0
hiperbola_or_linear = True
es_hiperbola = False
if hiperbola_or_linear:
popthip,pcovhip = curve_fit(hiperbola,voltages_dcA,Betas_vec,p0=(100,0.1,1,-0.15))
# par_inicial = (100,0.1,1,-0.15)
# a y0 b x0
par_inicial = (12,0.1,1,-0.13)
xhip = np.linspace(-0.23,0.005,200)
plt.figure()
plt.errorbar(voltages_dcA,Betas_vec,yerr=ErrorBetas_vec,fmt='o',capsize=5,markersize=5,color=paleta[1])
plt.plot(xhip,hiperbola(xhip,*popthip))
plt.xlabel('Endcap voltage (V)')
plt.ylabel('Modulation factor')
plt.grid()
popthip,pcovhip = curve_fit(hiperbola,voltages_dcA[I],Betas_vec[I],p0=par_inicial)
xhip = np.linspace(-0.23,0.005,200)
else:
poptini,pcovini = curve_fit(lineal,voltages_dcA[0:3],Betas_vec[0:3])
poptfin,pcovfin = curve_fit(lineal,voltages_dcA[4:],Betas_vec[4:])
# plt.figure()
# plt.errorbar(voltages_dcA[I],Betas_vec[I],yerr=ErrorBetas_vec[I],fmt='o',capsize=5,markersize=5,color=paleta[1])
# plt.plot(xhip,hiperbola(xhip,*popthip))
# # plt.plot(xhip,hiperbola(xhip,*par_inicial),'--',color='red')
# plt.xlabel('Endcap voltage (V)')
# plt.ylabel('Modulation factor')
# plt.grid()
minimum_voltage = -(poptini[1]-poptfin[1])/(poptini[0]-poptfin[0]) #voltaje donde se intersectan las rectas, es decir, donde deberia estar el minimo de micromocion
minimum_modulationfactor = lineal(minimum_voltage,*poptini) #es lo mismo si pongo *poptfin
xini = np.linspace(-0.23,-0.13,100)
xfin = np.linspace(-0.15,0.005,100)
plt.figure()
plt.errorbar(voltages_dcA,Betas_vec,yerr=ErrorBetas_vec,fmt='o',capsize=5,markersize=5,color=paleta[1])
plt.plot(xini,lineal(xini,*poptini))
plt.plot(xfin,lineal(xfin,*poptfin))
plt.axvline(minimum_voltage,linestyle='dashed',color='grey')
plt.xlabel('Endcap voltage (V)')
plt.ylabel('Modulation factor')
plt.grid()
fig, axx = plt.subplots( 2, figsize=(10,7) ,
constrained_layout=True, sharex=True,
gridspec_kw=dict(height_ratios=[10,2]))
fig.set_constrained_layout_pads(w_pad=2/72, h_pad=2/72, hspace=0, wspace=0)
ax = axx[0]
ax.errorbar(voltages_dcA[I],Betas_vec[I],yerr=ErrorBetas_vec[I],fmt='o',capsize=5,markersize=5,color=paleta[1])
ax.plot(xhip,hiperbola(xhip,*popthip))
# plt.plot(xhip,hiperbola(xhip,*par_inicial),'--',color='red')
ax.set_ylabel('Modulation factor')
ax = axx[1]
ax.errorbar(voltages_dcA[I],Betas_vec[I]-hiperbola(voltages_dcA[I],*popthip),
yerr=ErrorBetas_vec[I],fmt='o',capsize=5,markersize=5,color=paleta[1])
ax.set_ylabel('Res.')
ax.set_xlabel('Endcap voltage (V)')
for ax in axx:
ax.grid(True, ls=":", color='lightgray')
print([t*1e3 for t in Temp_vec])
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#%% Este hay que armarlo aún
plt.figure()
plt.errorbar(voltages_dcA,[t*1e3 for t in Temp_vec],yerr=[t*1e3 for t in ErrorTemp_vec],fmt='o',capsize=5,markersize=5,color=paleta[3])
# plt.axvline(minimum_voltage,linestyle='dashed',color='grey')
......@@ -514,30 +542,11 @@ plt.ylabel('Temperature (mK)')
plt.grid()
#plt.ylim(0,2)
#%%
"""
Ahora hago un ajuste con una hiperbola porque tiene mas sentido, por el hecho
de que en el punto optimo el ion no esta en el centro de la trampa
sino que esta a una distancia d
"""
def hiperbola(x,a,b,c,x0):
return a*np.sqrt(((x-x0)**2+c**2))+b
popthip,pcovhip = curve_fit(hiperbola,voltages_dcA,Betas_vec,p0=(100,0.1,1,-0.15))
xhip = np.linspace(-0.23,0.005,200)
plt.figure()
plt.errorbar(voltages_dcA,Betas_vec,yerr=ErrorBetas_vec,fmt='o',capsize=5,markersize=5,color=paleta[1])
plt.plot(xhip,hiperbola(xhip,*popthip))
plt.xlabel('Endcap voltage (V)')
plt.ylabel('Modulation factor')
plt.grid()
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#%% Ajuste de los betas y la temperatura
#%%
from scipy.special import jv
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment