In [1]:
%pylab inline
import warnings
import numpy as np
import matplotlib.pyplot as plt

import rayopt as ro

# ignore matplotlib and numpy warning each other
warnings.simplefilter("ignore", FutureWarning)
# ignore floating point exceptions
np.seterr(divide="ignore", invalid="ignore")
# by default only print 4 significant digits
np.set_printoptions(precision=4)
Populating the interactive namespace from numpy and matplotlib
In [2]:
# The diameter data is courtesy Bill Claff 
# https://www.photonstophotos.net/GeneralTopics/Lenses/OpticalBench/OpticalBench.htm
description = "JP2019-152887 Example 3 (AF-S Nikkor 400mm f/2.8 E FL ED VR)"
columns = "type roc distance diameter material"
text = """
O    0            20     200.0    AIR
S    1200.3704    10     139.22   1.5168/63.88
S    1199.7897    5      139.22   AIR    
S    207.0795     1      137.22   1.43384/95.26
S    -1127.5309   17.5   137.22   AIR    
S    175.9698     44.9   115.22   1.43384/95.26
S    -397.2708    18     115.22   AIR    
S    -360.2396    3.07   110.72   1.61266/44.46
S    353.1837     6      110.72   AIR    
S    66.4844      90     69.22    1.795/45.32
S    45.9182      4      63.22    1.49782/82.54
S    1114.1067    15     63.22    AIR    
S    2992.5492    18.503 48.22    1.755/52.34
S    118.0399     2.5    46.72    AIR    
S    -241.6942    3.35   46.72    1.84668/23.83
S    -86.4136     3.5    46.72    1.53996/59.52
S    64.2643      2.4    46.72    AIR    
A    0           38.179  37.958   AIR    
S    90.0336      1.5    38.72    1.48749/70.43
S    -63.8039     7.6    38.72    AIR    
S    -65.9768     1.2    36.72    1.84668/23.83
S    -114.8763    1.9    36.72    AIR    
S    300.3587     5      36.72    1.84668/23.83
S    -128.0558    3.5    36.72    1.59319/67.94
S    53.9004      1.9    36.72    AIR    
S    -347.5421    3.1    34.72    1.755/52.33
S    94.5337      1.9    34.72    AIR    
S    118.3533     4.19    33.72   1.7725/49.68
S    -384.3825    3.5    33.72    AIR    
S    67.4622      0.1    34.22    1.64/60.14
S    -340.4206    4.5    34.22    1.84668/23.83
S    246.6417     1.9    34.22    AIR    
S    0            6.5    35.72    1.5168/63.88
S    0            1.5    35.72    AIR    
I    0            74.22  43.26    AIR    
"""
In [3]:
s = ro.system_from_text(text, columns.split(), description=description)
s.object.angle = np.deg2rad(3.14)
s.fields = 0, .7, 1.0
In [4]:
s.update()
print(s)
System: JP2019-152887 Example 3 (AF-S Nikkor 400mm f/2.8 E FL ED VR)
Scale: 1.0 mm
Wavelengths: 588, 656, 486 nm
Fields: 0, 0.7, 1
Object:
 Semi-Angle: 3.14 deg
 Pupil:
   Pupil Distance: 1035
   Refractive Index: 1.00028
   Update Radius: True
   Radius: 69.0696
Image:
 Radius: 21.6
 Update Radius: True
 Pupil:
   Pupil Distance: -116.26
   Refractive Index: 1.00028
   Update Radius: True
   Radius: 20.5506
Stop: 17
Elements:
 # T   Distance   Rad Curv   Diameter          Material       n      nd      Vd
 0 S         20        inf        200         basic/air   1.000   1.000   89.30
 1 S         10       1200     139.22                 -   1.517   1.517   63.88
 2 S          5       1200     139.22         basic/air   1.000   1.000   89.30
 3 S          1      207.1     137.22                 -   1.434   1.434   95.26
 4 S       17.5      -1128     137.22         basic/air   1.000   1.000   89.30
 5 S       44.9        176     115.22                 -   1.434   1.434   95.26
 6 S         18     -397.3     115.22         basic/air   1.000   1.000   89.30
 7 S       3.07     -360.2     110.72                 -   1.613   1.613   44.46
 8 S          6      353.2     110.72         basic/air   1.000   1.000   89.30
 9 S         90      66.48      69.22                 -   1.795   1.795   45.32
10 S          4      45.92      63.22                 -   1.498   1.498   82.54
11 S         15       1114      63.22         basic/air   1.000   1.000   89.30
12 S     18.503       2993      48.22                 -   1.755   1.755   52.34
13 S        2.5        118      46.72         basic/air   1.000   1.000   89.30
14 S       3.35     -241.7      46.72                 -   1.847   1.847   23.83
15 S        3.5     -86.41      46.72                 -   1.540   1.540   59.52
16 S        2.4      64.26      46.72         basic/air   1.000   1.000   89.30
17 S     38.179        inf     37.958         basic/air   1.000   1.000   89.30
18 S        1.5      90.03      38.72                 -   1.487   1.487   70.43
19 S        7.6      -63.8      38.72         basic/air   1.000   1.000   89.30
20 S        1.2     -65.98      36.72                 -   1.847   1.847   23.83
21 S        1.9     -114.9      36.72         basic/air   1.000   1.000   89.30
22 S          5      300.4      36.72                 -   1.847   1.847   23.83
23 S        3.5     -128.1      36.72                 -   1.593   1.593   67.94
24 S        1.9       53.9      36.72         basic/air   1.000   1.000   89.30
25 S        3.1     -347.5      34.72                 -   1.755   1.755   52.33
26 S        1.9      94.53      34.72         basic/air   1.000   1.000   89.30
27 S       4.19      118.4      33.72                 -   1.772   1.772   49.68
28 S        3.5     -384.4      33.72         basic/air   1.000   1.000   89.30
29 S        0.1      67.46      34.22                 -   1.640   1.640   60.14
30 S        4.5     -340.4      34.22                 -   1.847   1.847   23.83
31 S        1.9      246.6      34.22         basic/air   1.000   1.000   89.30
32 S        6.5        inf      35.72                 -   1.517   1.517   63.88
33 S        1.5        inf      35.72         basic/air   1.000   1.000   89.30
34 S      74.22        inf      43.26         basic/air   1.000   1.000   89.30

In [5]:
ro.Analysis(s)
System: JP2019-152887 Example 3 (AF-S Nikkor 400mm f/2.8 E FL ED VR)
Scale: 1.0 mm
Wavelengths: 588, 656, 486 nm
Fields: 0, 0.7, 1
Object:
 Semi-Angle: 3.14 deg
 Pupil:
   Pupil Distance: 1035
   Refractive Index: 1.00028
   Update Radius: True
   Radius: 69.0696
Image:
 Radius: 21.6
 Update Radius: True
 Pupil:
   Pupil Distance: -116.26
   Refractive Index: 1.00028
   Update Radius: True
   Radius: 20.5506
Stop: 17
Elements:
 # T   Distance   Rad Curv   Diameter          Material       n      nd      Vd
 0 S         20        inf        200         basic/air   1.000   1.000   89.30
 1 S         10       1200     139.22                 -   1.517   1.517   63.88
 2 S          5       1200     139.22         basic/air   1.000   1.000   89.30
 3 S          1      207.1     137.22                 -   1.434   1.434   95.26
 4 S       17.5      -1128     137.22         basic/air   1.000   1.000   89.30
 5 S       44.9        176     115.22                 -   1.434   1.434   95.26
 6 S         18     -397.3     115.22         basic/air   1.000   1.000   89.30
 7 S       3.07     -360.2     110.72                 -   1.613   1.613   44.46
 8 S          6      353.2     110.72         basic/air   1.000   1.000   89.30
 9 S         90      66.48      69.22                 -   1.795   1.795   45.32
10 S          4      45.92      63.22                 -   1.498   1.498   82.54
11 S         15       1114      63.22         basic/air   1.000   1.000   89.30
12 S     18.503       2993      48.22                 -   1.755   1.755   52.34
13 S        2.5        118      46.72         basic/air   1.000   1.000   89.30
14 S       3.35     -241.7      46.72                 -   1.847   1.847   23.83
15 S        3.5     -86.41      46.72                 -   1.540   1.540   59.52
16 S        2.4      64.26      46.72         basic/air   1.000   1.000   89.30
17 S     38.179        inf     37.958         basic/air   1.000   1.000   89.30
18 S        1.5      90.03      38.72                 -   1.487   1.487   70.43
19 S        7.6      -63.8      38.72         basic/air   1.000   1.000   89.30
20 S        1.2     -65.98      36.72                 -   1.847   1.847   23.83
21 S        1.9     -114.9      36.72         basic/air   1.000   1.000   89.30
22 S          5      300.4      36.72                 -   1.847   1.847   23.83
23 S        3.5     -128.1      36.72                 -   1.593   1.593   67.94
24 S        1.9       53.9      36.72         basic/air   1.000   1.000   89.30
25 S        3.1     -347.5      34.72                 -   1.755   1.755   52.33
26 S        1.9      94.53      34.72         basic/air   1.000   1.000   89.30
27 S       4.19      118.4      33.72                 -   1.772   1.772   49.68
28 S        3.5     -384.4      33.72         basic/air   1.000   1.000   89.30
29 S        0.1      67.46      34.22                 -   1.640   1.640   60.14
30 S        4.5     -340.4      34.22                 -   1.847   1.847   23.83
31 S        1.9      246.6      34.22         basic/air   1.000   1.000   89.30
32 S        6.5        inf      35.72                 -   1.517   1.517   63.88
33 S        1.5        inf      35.72         basic/air   1.000   1.000   89.30
34 S     74.785        inf      43.26         basic/air   1.000   1.000   89.30

lagrange: -3.792
track length: 322.69
object, image height: [56.807  21.4464]
front, back focal length (from PP): [-392.5702  392.5702]
entry, exit pupil height: [69.0696 20.5506]
entry, exit pupil distance: [1025.0027  -42.0399]
front, back focal distance: [-294.3282   74.7423]
front, back principal distance: [  98.2419 -317.8278]
front, back nodal distance: [  98.2419 -317.8278]
front, back numerical aperture: [0.     0.1733]
front, back f number: [2.8418 9.5513]
front, back working f number: [   inf 2.8855]
front, back airy radius: [   inf 0.0021]
transverse, angular magnification: [-0.     3.361]

 # T      path         n   axial y  axial nu   chief y  chief nu
 0 S        20         1     69.07         0    -56.81    0.0549
 1 S        30     1.517     69.07  -0.02972    -56.26   0.07911
 2 S        35         1     68.97-2.779e-05       -56     0.055
 3 S        36     1.434     68.97   -0.1444    -55.94    0.1721
 4 S      53.5         1     67.21   -0.1703    -53.84    0.1928
 5 S      98.4     1.434     59.57    -0.317    -45.19    0.3042
 6 S     116.4         1     55.59   -0.3777    -41.37    0.3493
 7 S     119.5     1.613     54.43   -0.2852     -40.3    0.2808
 8 S     125.5         1     53.37   -0.1927    -39.25    0.2128
 9 S     215.5     1.795     36.03   -0.6234    -20.11    0.4531
10 S     219.5     1.498     34.64   -0.3992     -19.1    0.3295
11 S     234.5         1     30.65   -0.3855     -15.8    0.3225
12 S       253     1.755     23.51   -0.3914    -9.834    0.3249
13 S     255.5         1     22.96   -0.2446    -9.371     0.265
14 S     258.8     1.847     22.14   -0.1671    -8.483    0.2353
15 S     262.3      1.54     21.82   -0.2445    -8.037    0.2638
16 S     264.7         1     21.44  -0.06449    -7.626    0.1998
17 S     302.9         1     18.98  -0.06449 1.838e-14    0.1998
18 S     304.4     1.487     18.88   -0.1667    0.2996    0.1982
19 S       312         1     18.03   -0.3044     1.312    0.1882
20 S     313.2     1.847     17.67  -0.07772     1.538    0.2079
21 S     315.1         1     17.59   -0.2073     1.752     0.195
22 S     320.1     1.847     16.55   -0.2539     2.726    0.1873
23 S     323.6     1.593     16.07   -0.2857     3.081    0.1812
24 S     325.5         1     15.73   -0.1127     3.297    0.2175
25 S     328.6     1.755     15.38  -0.07934     3.971    0.2261
26 S     330.5         1     15.29   0.04275     4.216    0.2598
27 S     334.7     1.772     15.47  -0.05819     5.304    0.2251
28 S     338.2         1     15.36  -0.08905     5.749    0.2136
29 S     338.3      1.64     15.35   -0.2346      5.77    0.1589
30 S     342.8     1.847      14.7   -0.2257     6.206    0.1626
31 S     344.7         1     14.47    -0.176     6.374    0.1845
32 S     351.2     1.517     13.33    -0.176     7.573    0.1845
33 S     352.7         1     13.15    -0.176     7.755    0.1845
34 S     426.9         1   0.09555    -0.176     21.45    0.1845

 # T       SA3      CMA3      AST3      PTZ3      DIS3     TACHC      TCHC
 0 S         0         0         0         0         0         0         0
 1 S -0.008359 -0.001165-0.0001623  -0.01153  -0.00163   -0.1199  -0.01671
 2 S  0.008305  0.001202 0.0001739   0.01154  0.001695    0.1195   0.01729
 3 S     -1.52     0.982   -0.6345  -0.05936    0.4482   -0.4124    0.2664
 4 S    -1.004     1.051    -1.099   -0.0109     1.162   -0.2773    0.2902
 5 S   0.07623  -0.02899   0.01103  -0.06985   0.02237   -0.1799   0.06844
 6 S    -9.405     8.239    -7.217  -0.03094     6.349   -0.5164    0.4524
 7 S     11.53    -10.05     8.768   0.04285    -7.684      1.39    -1.213
 8 S  -0.02155   0.05275   -0.1291   0.04371     0.209    -0.107    0.2619
 9 S  -0.01148   0.00295-0.0007579   -0.2707   0.06974   -0.6957    0.1787
10 S    0.8137   -0.3267    0.1312   0.09788  -0.09198    0.8228   -0.3304
11 S    -2.302     1.983    -1.707   0.01212      1.46   -0.2496     0.215
12 S     2.448    -2.069     1.749 -0.005842    -1.473    0.4126   -0.3488
13 S  -0.01911   0.07083   -0.2626    0.1481    0.4244  -0.05341     0.198
14 S     1.383    -1.235     1.102   0.07709    -1.053    0.8098   -0.7229
15 S     -1.34    0.8611   -0.5534  -0.05075    0.3883    -1.044    0.6706
16 S    0.1699   0.05119   0.01542    0.2217   0.07142    0.1922    0.0579
17 S         0        -0         0         0         0        -0         0
18 S  -0.01226  -0.01714  -0.02396   -0.1479   -0.2402  -0.07215   -0.1009
19 S    -4.021     1.148   -0.3277   -0.2087    0.1531   -0.2784   0.07947
20 S     4.602    -1.326     0.382    0.2824   -0.1914       1.1   -0.3168
21 S    -1.191     0.594   -0.2962   -0.1622    0.2286   -0.6896    0.3439
22 S    0.1438   -0.1929    0.2586  -0.06203   -0.2636     0.274   -0.3674
23 S   -0.4084    0.1201  -0.03534  -0.02736   0.01844   -0.6073    0.1786
24 S-0.0001382 -0.000215-0.0003345    0.2807    0.4361   0.08727    0.1358
25 S   0.09315   -0.1223    0.1604    0.0503   -0.2766    0.1122   -0.1473
26 S    0.1239    0.1844    0.2744    0.1849    0.6834    0.1454    0.2163
27 S  -0.08067   -0.1416   -0.2486   -0.1496   -0.6991   -0.1331   -0.2337
28 S  -0.05093   0.07842   -0.1208  -0.04607    0.2569  -0.09826    0.1513
29 S  0.001481  0.003198  0.006907    -0.235   -0.4927  -0.07798   -0.1684
30 S   0.08164  -0.03448   0.01456  0.008152 -0.009591    0.3239   -0.1368
31 S  -0.06178    0.1108   -0.1987   0.07554    0.2209   -0.1847    0.3312
32 S     0.116   -0.1217    0.1276        -0   -0.1337   0.07072  -0.07414
33 S   -0.1145    0.1201   -0.1259         0     0.132  -0.06979   0.07318
34 S         0        -0         0         0         0        -0         0
       0.01742  -0.01784   0.01959  -0.01184    0.1249 -0.005824  0.009818

Out[5]:
<rayopt.analysis.Analysis at 0x1b971229f28>
In [ ]: