

%pylab inline
#imshow(C.get_optical_path_map())
#colorbar()

#poly,error=C.get_optical_path_map_lsq(order=2)

#print(error)
#print(poly)

"""
Explanation: TODO: When generating the documentation automatically, the methods related to get_optical_path_map... are not working. If the example is run in a normal notebook tthey work. I dont understand what is the problem. Needs to be fixed.
End of explanation
"""


def opsystem(lp):
    L=library.Edmund.get("32494")
    C=CCD()

    S=System(complist=[(L,(0,0,lp),(0,-pi,0)),(C,(0,0,570),(0,0,0))],n=1.)
    R=point_source_c(span=(0.06,0.06),wavelength=.65)


    S.ray_add(R)
    S.propagate()
    X,Y,Z=C.get_optical_path_data()
    return array(Z).std()

#opsystem(158)

"""
Explanation: Ejercicio:
Encontrar la configuración del motaje óptico mostrado, de tal manera que el haz salga colimado
Creando una función para calcular parámetros del sistema
End of explanation
"""


#from scipy.optimize import fmin
#fmin(opsystem,158)

"""
Explanation: Utilizando otras librerias de python para optimizar el sistema
End of explanation
"""


