In [1]:
import batoid
from batoid.utils import normalized
import os
import yaml
import numpy as np
from ipywidgets import interact
import ipywidgets as widgets
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
%matplotlib inline

In [2]:
fiducial_telescope = batoid.Optic.fromYaml("DECam.yaml")


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-cdf1e7022cd9> in <module>
----> 1 fiducial_telescope = batoid.Optic.fromYaml("DECam.yaml")

~/src/batoid/batoid/optic.py in fromYaml(cls, filename)
     91                 raise FileNotFoundError(filename)
     92         from .parse import parse_optic
---> 93         return parse_optic(config['opticalSystem'])
     94 
     95 

~/src/batoid/batoid/parse.py in parse_optic(config, coordSys, inMedium, outMedium)
     76         coordSys = parse_coordSys(config.pop('coordSys'), coordSys)
     77     inMedium = parse_medium(config.pop('inMedium', inMedium))
---> 78     outMedium = parse_medium(config.pop('outMedium', outMedium))
     79     if outMedium is None:
     80         outMedium = inMedium

~/src/batoid/batoid/parse.py in parse_medium(config)
    142 
    143 def parse_medium(config):
--> 144     typ = config.pop('type')
    145     evalstr = "batoid.{}(**config)".format(typ)
    146     return eval(evalstr)

AttributeError: 'NoneType' object has no attribute 'pop'

In [ ]:
%debug


> /Users/josh/src/batoid/batoid/parse.py(144)parse_medium()
    142 
    143 def parse_medium(config):
--> 144     typ = config.pop('type')
    145     evalstr = "batoid.{}(**config)".format(typ)
    146     return eval(evalstr)

ipdb> print(config)
None
ipdb> up
> /Users/josh/src/batoid/batoid/parse.py(78)parse_optic()
     76         coordSys = parse_coordSys(config.pop('coordSys'), coordSys)
     77     inMedium = parse_medium(config.pop('inMedium', inMedium))
---> 78     outMedium = parse_medium(config.pop('outMedium', outMedium))
     79     if outMedium is None:
     80         outMedium = inMedium

ipdb> print(config)
{'type': 'CompoundOptic', 'medium': {}, 'backDist': 12.0, 'sphereRadius': 10.0, 'pupilSize': 3.81, 'pupilObscuration': 0.1, 'stopSurface': {'type': 'Interface', 'name': 'entrancePupil', 'surface': {'type': 'Plane'}, 'coordSys': {'z': 0.08512541896228668}}, 'items': [{'type': 'Mirror', 'name': 'PM', 'surface': {'type': 'Quadric', 'R': 21.3116, 'conic': -1.0976}, 'obscuration': {'type': 'ClearAnnulus', 'outer': 1.905, 'inner': 0.762}}, {'type': 'CompoundOptic', 'name': 'DECam', 'coordSys': {'z': 8.875037}, 'items': [{'type': 'Lens', 'name': 'C1', 'medium': {'type': 'SellmeierMedium', 'B1': 0.6961663, 'B2': 0.4079426, 'B3': 0.8974794, 'C1': 0.00467914825849, 'C2': 0.013512063073959999, 'C3': 97.93400253792099}, 'items': [{'type': 'RefractiveInterface', 'name': 'C1_entrance', 'surface': {'type': 'Sphere', 'R': 0.68598}, 'obscuration': {'type': 'ClearCircle', 'radius': 0.49}}, {'type': 'RefractiveInterface', 'name': 'C1_exit', 'surface': {'type': 'Sphere', 'R': 0.71187}, 'obscuration': {'type': 'ClearCircle', 'radius': 0.46}, 'coordSys': {'z': 0.11054}}]}, {'type': 'Lens', 'name': 'C2', 'medium': {'type': 'SellmeierMedium', 'B1': 0.6961663, 'B2': 0.4079426, 'B3': 0.8974794, 'C1': 0.00467914825849, 'C2': 0.013512063073959999, 'C3': 97.93400253792099}, 'coordSys': {'z': 0.768634}, 'items': [{'type': 'RefractiveInterface', 'name': 'C2_entrance', 'surface': {'type': 'Sphere', 'R': 3.3856}, 'obscuration': {'type': 'ClearCircle', 'radius': 0.345}}, {'type': 'RefractiveInterface', 'name': 'C2_exit', 'coordSys': {'z': 0.051136}, 'surface': {'type': 'Asphere', 'R': 0.506944, 'conic': 0.0, 'coefs': [-0.15789999999999998, -0.10429999999999999, 0.1351]}, 'obscuration': {'type': 'ClearCircle', 'radius': 0.32}}]}, {'type': 'Lens', 'name': 'C3', 'medium': {'type': 'SellmeierMedium', 'B1': 0.6961663, 'B2': 0.4079426, 'B3': 0.8974794, 'C1': 0.00467914825849, 'C2': 0.013512063073959999, 'C3': 97.93400253792099}, 'coordSys': {'z': 0.914377}, 'items': [{'type': 'RefractiveInterface', 'name': 'C3_entrance', 'surface': {'type': 'Sphere', 'R': 0.9436}, 'obscuration': {'type': 'ClearCircle', 'radius': 0.326}}, {'type': 'RefractiveInterface', 'name': 'C3_exit', 'coordSys': {'z': 0.07559}, 'surface': {'type': 'Sphere', 'R': 2.41685}, 'obscuration': {'type': 'ClearCircle', 'radius': 0.313}}]}, {'type': 'Lens', 'name': 'Filter', 'medium': {'type': 'SellmeierMedium', 'B1': 0.6961663, 'B2': 0.4079426, 'B3': 0.8974794, 'C1': 0.00467914825849, 'C2': 0.013512063073959999, 'C3': 97.93400253792099}, 'coordSys': {'z': 1.315074}, 'items': [{'type': 'RefractiveInterface', 'name': 'Filter_entrance', 'surface': {'type': 'Plane'}, 'obscuration': {'type': 'ClearCircle', 'radius': 0.307}}, {'type': 'RefractiveInterface', 'name': 'Filter_exit', 'coordSys': {'z': 0.013}, 'surface': {'type': 'Plane'}, 'obscuration': {'type': 'ClearCircle', 'radius': 0.307}}]}, {'type': 'Lens', 'name': 'C4', 'medium': {'type': 'SellmeierMedium', 'B1': 0.6961663, 'B2': 0.4079426, 'B3': 0.8974794, 'C1': 0.00467914825849, 'C2': 0.013512063073959999, 'C3': 97.93400253792099}, 'coordSys': {'z': 1.519564}, 'items': [{'type': 'RefractiveInterface', 'name': 'C4_entrance', 'surface': {'type': 'Asphere', 'R': 0.66243, 'conic': 0.0, 'coefs': [0.1798, 1.126, 7.907]}, 'obscuration': {'type': 'ClearCircle', 'radius': 0.302}}, {'type': 'RefractiveInterface', 'name': 'C4_exit', 'coordSys': {'z': 0.101461}, 'surface': {'type': 'Sphere', 'R': 1.79728}, 'obscuration': {'type': 'ClearCircle', 'radius': 0.292}}]}, {'type': 'Lens', 'name': 'C5', 'medium': {'type': 'SellmeierMedium', 'B1': 0.6961663, 'B2': 0.4079426, 'B3': 0.8974794, 'C1': 0.00467914825849, 'C2': 0.013512063073959999, 'C3': 97.93400253792099}, 'coordSys': {'z': 1.82315}, 'items': [{'type': 'RefractiveInterface', 'name': 'C5_entrance', 'surface': {'type': 'Sphere', 'R': -0.899815}, 'obscuration': {'type': 'ClearCircle', 'radius': 0.256}}, {'type': 'RefractiveInterface', 'name': 'C5_exit', 'coordSys': {'z': 0.053105}, 'surface': {'type': 'Sphere', 'R': -0.68501}, 'obscuration': {'type': 'ClearCircle', 'radius': 0.271}}]}, {'type': 'Detector', 'name': 'D', 'coordSys': {'z': 1.906155}, 'surface': {'type': 'Plane'}, 'obscuration': {'type': 'ClearCircle', 'radius': 0.23}}]}]}

In [3]:
fig1 = plt.figure(figsize=(12, 11))
ax1 = fig1.add_subplot(111)
fiducial_telescope.draw2d(ax1, c='k')

fig2 = plt.figure(figsize=(12, 11))
ax2 = fig2.add_subplot(111, projection='3d')
fiducial_telescope.draw3d(ax2, c='k')

p0_left = np.array([-1.8, 0, 0])
p0_right = np.array([1.8, 0, 0])
p0_lmid = np.array([-0.9, 0, 0])
p0_rmid = np.array([0.9, 0, 0])
v_left = normalized(np.array([-1*np.pi/180, 0, -1]))/1.000277
v_mid = normalized(np.array([0, 0, -1]))/1.000277
v_right = normalized(np.array([1*np.pi/180, 0, -1]))/1.000277

for v, c in zip([v_left, v_mid, v_right], ['#377eb8', '#ff7f00', '#4daf4a']):
    rays = []
    for p0 in [p0_left, p0_lmid, p0_rmid, p0_right]:
        ray = batoid.Ray(p0, v, t=0, wavelength=500e-9)
        p0 = ray.positionAtTime(-10)        
        rays.append(batoid.Ray(p0, v, t=0, wavelength=500e-9))
    traceFull = fiducial_telescope.traceFull(batoid.RayVector(rays))
    batoid.drawTrace2d(ax1, traceFull, c=c)
    batoid.drawTrace3d(ax2, traceFull, c=c)



In [4]:
fig1 = plt.figure(figsize=(12, 11))
ax1 = fig1.add_subplot(111)
fiducial_telescope['BlancoDECam.DECam'].draw2d(ax1, c='k')
ax1.set_xlim(ax1.get_xlim())
ax1.set_ylim(ax1.get_ylim())

fig2 = plt.figure(figsize=(12, 11))
ax2 = fig2.add_subplot(111, projection='3d')
fiducial_telescope['BlancoDECam.DECam'].draw3d(ax2, c='k')
ax2.set_xlim(ax2.get_xlim())
ax2.set_ylim(ax2.get_ylim())
ax2.set_zlim(ax2.get_zlim())

p0_left = np.array([-1.8, 0, 0])
p0_right = np.array([1.8, 0, 0])
p0_lmid = np.array([-0.9, 0, 0])
p0_rmid = np.array([0.9, 0, 0])
v_left = normalized(np.array([-1*np.pi/180, 0, -1]))/1.000277
v_mid = normalized(np.array([0, 0, -1]))/1.000277
v_right = normalized(np.array([1*np.pi/180, 0, -1]))/1.000277

for v, c in zip([v_left, v_mid, v_right], ['#377eb8', '#ff7f00', '#4daf4a']):
    rays = []
    for p0 in [p0_left, p0_lmid, p0_rmid, p0_right]:
        ray = batoid.Ray(p0, v, t=0, wavelength=500e-9)
        p0 = ray.positionAtTime(-10)        
        rays.append(batoid.Ray(p0, v, t=0, wavelength=500e-9))
    traceFull = fiducial_telescope.traceFull(batoid.RayVector(rays))
    batoid.drawTrace2d(ax1, traceFull, c=c)
    batoid.drawTrace3d(ax2, traceFull, c=c)



In [ ]: