Commit 3c28582b authored by Peter Jansweijer's avatar Peter Jansweijer

added dashed linear fit line to plots

parent 976125fe
......@@ -421,6 +421,7 @@ if __name__ == "__main__":
# again define the best fit line, now based on clean arrays:
ly_clean=[]
ly_lin_clean=[]
alpha_clean=[]
alpha_lin_clean=[]
......@@ -437,21 +438,17 @@ if __name__ == "__main__":
# in [Km].
for i in x_clean: # scan through all wavelengths in [nm]!
#clean_y = line(i,popt_clean[0],popt_clean[1])
lin_clean_y = line(i,popt_clean[0],popt_clean[1])
clean_y = (group_delay(i,popt[0],popt[1],popt[2],popt[3],popt[4]))
dispersion = dispersion_coefficient(i,popt[1],popt[2],popt[3],popt[4])
ly_clean.append(clean_y)
ly_lin_clean.append(lin_clean_y) # linear
ly_clean.append(clean_y) # 5-t Sellmeier
alpha_lin_clean.append(calc_alpha(i/1e9, clean_y, tangent*1e9, fixed_lambda))
alpha_clean.append(calc_alpha(i/1e9, clean_y, dispersion, fixed_lambda))
fig = plt.figure("CRTT versus ITU Channel number")
ax = fig.add_subplot(111)
ax.set_ylabel('CRTT [ps]')
ax.text(0.01, 0.95, str(insitu_file), transform=ax.transAxes)
ax.text(0.01, 0.90, "tolerance: " + str(tolerance) + "; outliers: " + str(outlier_cnt), transform=ax.transAxes)
#ax.text(0.01, 0.85, "fit y = a * x + b", transform=ax.transAxes)
#ax.text(0.01, 0.80, "a:" + str(popt_clean[0]), transform=ax.transAxes)
#ax.text(0.01, 0.75, "b:" + str(popt_clean[1]), transform=ax.transAxes)
if use_itu_channels:
ax.set_title("CRTT versus ITU Channel number")
......@@ -462,15 +459,21 @@ if __name__ == "__main__":
ax.set_xlabel('Wavelenth [nm]')
ax.text(0.01, 0.85, "1st order linear tangent: " + str(tangent) + " [ps/nm]", transform=ax.transAxes)
with_tolerances = True
with_tolerances = False
ax.text(0.01, 0.95, str(insitu_file), transform=ax.transAxes)
ax.plot(x, y, color = 'blue', label='data') # Original datapoints
if with_tolerances:
ax.text(0.01, 0.90, "tolerance: " + str(tolerance) + "; outliers: " + str(outlier_cnt), transform=ax.transAxes)
#ax.text(0.01, 0.85, "fit y = a * x + b", transform=ax.transAxes)
#ax.text(0.01, 0.80, "a:" + str(popt_clean[0]), transform=ax.transAxes)
#ax.text(0.01, 0.75, "b:" + str(popt_clean[1]), transform=ax.transAxes)
ax.plot(x, ly, ".", color='gray', label='best fit 5-term Sellmeier') # 5-term Sellmeier best fit
ax.plot(x, ly + tol, ".", color='#c0c0c0', label='tolerances') # 5-term Sellmeier best fit with + tolerances
ax.plot(x, ly - tol, ".", color='#c0c0c0') # 5-term Sellmeier best fit with - tolerances
ax.plot(x_clean, y_clean, color = 'red', label='data, outliers removed') # cleaned array in [nm]
ax.plot(x_clean, ly_clean, color = 'green', label='5-term Sellmeier fit') # final clean 5th order sellmeier fit in [nm]
ax.plot(x_clean, ly_lin_clean, "-", color = 'blue', dashes=[5,5,5,5], label='linear fit') # final clean linear fit in [nm]
ax.legend(loc='lower right', fontsize='medium')
fig.savefig(insitu_file+".png")
......@@ -490,7 +493,7 @@ if __name__ == "__main__":
ax.axhline(0, color='gray')
ax.axvline(fixed_lambda*1e9, color='red')
ax.plot(x_clean, alpha_clean, color='green', label='5-term Sellmeier')
ax.plot(x_clean, alpha_lin_clean, color='blue' , label='linear')
ax.plot(x_clean, alpha_lin_clean, color='blue', dashes=[5,5,5,5], label='linear')
ax.legend(loc='lower right', fontsize='medium')
alpha_file = open(name+".out","w")
......@@ -506,9 +509,10 @@ if __name__ == "__main__":
alpha_file.close()
#pdb.set_trace()
#plt.subplot_tool()
plt.subplots_adjust(left=0.17)
fig_alpha.savefig(insitu_file+"_alpha.png")
plt.draw()
plt.show()
......
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