%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
# It appears that rayopt requires distance rather than
# thickness quoted in patent literature
# So we have to move the thickness value one row down
#
# The first surface represents the Object (O)
# The last surface represents the Image (I)
description = "Nikkor-Z-35mmf1.8-JP2019090947A"
columns = "type distance roc diameter material"
# Following is original data
# from patent with one correction of distance
# The data is scaled because the focal length as per the
# patent is only 1.57 mm.
text = """
O 20 0 3.0 AIR
S 0.5 4.6232 1.664 1.51680/64.13
S 0.102 0.8784 1.346 AIR
S 0.354 4.0730 1.314 1.95375/32.33
S 0.258 -2.0290 1.28 1.60342/38.03
S 0.083 3.2358 1.138 AIR
S 0.2595 -1.2945 1.096 1.68893/31.16
S 0.172 1.7517 1.262 1.85150/40.78
S 0.329 -1.7517 1.29 AIR
S 0.018 1.1917 1.306 1.49700/81.61
S 0.368 -3.5528 1.262 AIR
S 0.009 4.1556 1.174 1.83441/37.28
S 0.057 1.9836 1.114 AIR
A 0.187 0 1.066 AIR
S 0.514 -0.9917 0.956 1.61293/36.94
S 0.062 -5.7790 0.99 AIR
S 0.012 2.1244 1.088 1.59282/68.62
S 0.282 -1.3918 1.124 AIR
S 0.209 -8.4171 1.198 1.69350/53.20
S 0.098 -2.8176 1.228 AIR
S 0.229 -1.8973 1.29 1.58313/59.46
S 0.083 -6.9348 1.408 AIR
S 0.751 0 2.4 1.51680/64.13
S 0.074 0 2.4 AIR
I 0.0425 0 2.0 AIR
"""
# Following data is scaled by a factor of 21.6
# to get to an image radius of 43.2
text = """
O 432 0 64.8 AIR
S 10.8 99.86112 35.9424 1.51680/64.13
S 2.2032 18.97344 29.0736 AIR
S 7.6464 87.9768 28.3824 1.95375/32.33
S 5.5728 -43.8264 27.648 1.60342/38.03
S 1.7928 69.89328 24.5808 AIR
S 5.6052 -27.9612 23.6736 1.68893/31.16
S 3.7152 37.83672 27.2592 1.85150/40.78
S 7.1064 -37.83672 27.864 AIR
S 0.3888 25.74072 28.2096 1.49700/81.61
S 7.9488 -76.74048 27.2592 AIR
S 0.1944 89.76096 25.3584 1.83441/37.28
S 1.2312 42.84576 24.0624 AIR
A 4.0392 0 23.0256 AIR
S 11.1024 -21.42072 20.6496 1.61293/36.94
S 1.3392 -124.8264 21.384 AIR
S 0.2592 45.88704 23.5008 1.59282/68.62
S 6.0912 -30.06288 24.2784 AIR
S 4.5144 -181.80936 25.8768 1.69350/53.20
S 2.1168 -60.86016 26.5248 AIR
S 4.9464 -40.98168 27.864 1.58313/59.46
S 1.7928 -149.79168 30.4128 AIR
S 16.2216 0 51.84 1.51680/64.13
S 1.5984 0 51.84 AIR
I 0.918 0 43.2 AIR
"""
s = ro.system_from_text(text, columns.split(),
description=description)
s.object.angle = np.deg2rad(32.5)
s.fields = 0, .7, 1.
#s.wavelengths = [587.5618e-9]
# following are the original aspheric coeffcients
s[11].conic = -4.9288
s[11].aspherics = [0, -9.582E-02, 5.043E-01, -4.618E-01]
s[12].conic = -0.4693
s[12].aspherics = [0, -8.355E-02, 5.689E-01, -2.913E-01]
s[18].conic = 15.3255
s[18].aspherics = [0, -2.063E-01, 6.890E-02]
s[19].conic = -0.9347
s[19].aspherics = [0, -2.416E-03, 1.158E-01, 1.983E-01, -1.130E-01]
s[20].conic = -0.1889
s[20].aspherics = [0, -1.143E-01, -1.549E-01]
s[21].conic = 0
s[21].aspherics = [0, -9.359E-02, -1.873E-01, 1.909E-01, -1.298E-01]
# Following is scaling done by hand in the same way that
# rayopt does it
scale = 21.6
s[11].aspherics = [ai/(scale**(2*i + 1)) for i, ai in enumerate(s[11].aspherics)]
s[12].aspherics = [ai/(scale**(2*i + 1)) for i, ai in enumerate(s[12].aspherics)]
s[18].aspherics = [ai/(scale**(2*i + 1)) for i, ai in enumerate(s[18].aspherics)]
s[19].aspherics = [ai/(scale**(2*i + 1)) for i, ai in enumerate(s[19].aspherics)]
s[20].aspherics = [ai/(scale**(2*i + 1)) for i, ai in enumerate(s[20].aspherics)]
s[21].aspherics = [ai/(scale**(2*i + 1)) for i, ai in enumerate(s[21].aspherics)]
print(s[11].aspherics)
print(s[12].aspherics)
print(s[18].aspherics)
print(s[19].aspherics)
print(s[20].aspherics)
print(s[21].aspherics)
[0.0, -9.508125666819081e-06, 1.07255658207538e-07, -2.105123941656667e-10] [0.0, -8.290585467154395e-06, 1.2099493149765686e-07, -1.327896501092653e-10] [0.0, -2.0470948915307623e-05, 1.4653806961132993e-08] [0.0, -2.3973733678809123e-07, 2.4628604442658933e-08, 9.039542607850089e-11, -1.1040651032393528e-13] [0.0, -1.1341878143575673e-05, -3.2944480381415106e-08] [0.0, -9.286844929634708e-06, -3.983538525138185e-08, 8.702212223089167e-11, -1.2682092955793626e-13]
s.update()
print(s)
System: Nikkor-Z-35mmf1.8-JP2019090947A Scale: 1.0 mm Wavelengths: 588, 656, 486 nm Fields: 0, 0.7, 1 Object: Semi-Angle: 32.5 deg Pupil: Pupil Distance: 34.9212 Refractive Index: 1.00028 Update Radius: True Radius: 9.60801 Image: Radius: 21.6 Update Radius: True Pupil: Pupil Distance: -48.0172 Refractive Index: 1.00028 Update Radius: True Radius: 13.583 Stop: 13 Elements: # T Distance Rad Curv Diameter Material n nd Vd 0 S 432 inf 64.8 basic/air 1.000 1.000 89.30 1 S 10.8 99.86 35.942 - 1.517 1.517 64.13 2 S 2.2032 18.97 29.074 basic/air 1.000 1.000 89.30 3 S 7.6464 87.98 28.382 - 1.954 1.954 32.33 4 S 5.5728 -43.83 27.648 - 1.603 1.603 38.03 5 S 1.7928 69.89 24.581 basic/air 1.000 1.000 89.30 6 S 5.6052 -27.96 23.674 - 1.689 1.689 31.16 7 S 3.7152 37.84 27.259 - 1.851 1.851 40.78 8 S 7.1064 -37.84 27.864 basic/air 1.000 1.000 89.30 9 S 0.3888 25.74 28.21 - 1.497 1.497 81.61 10 S 7.9488 -76.74 27.259 basic/air 1.000 1.000 89.30 11 S 0.1944 89.76 25.358 - 1.834 1.834 37.28 12 S 1.2312 42.85 24.062 basic/air 1.000 1.000 89.30 13 S 4.0392 inf 23.026 basic/air 1.000 1.000 89.30 14 S 11.102 -21.42 20.65 - 1.613 1.613 36.94 15 S 1.3392 -124.8 21.384 basic/air 1.000 1.000 89.30 16 S 0.2592 45.89 23.501 - 1.593 1.593 68.62 17 S 6.0912 -30.06 24.278 basic/air 1.000 1.000 89.30 18 S 4.5144 -181.8 25.877 - 1.694 1.694 53.20 19 S 2.1168 -60.86 26.525 basic/air 1.000 1.000 89.30 20 S 4.9464 -40.98 27.864 - 1.583 1.583 59.46 21 S 1.7928 -149.8 30.413 basic/air 1.000 1.000 89.30 22 S 16.222 inf 51.84 - 1.517 1.517 64.13 23 S 1.5984 inf 51.84 basic/air 1.000 1.000 89.30 24 S 0.918 inf 43.2 basic/air 1.000 1.000 89.30
ro.Analysis(s)
System: Nikkor-Z-35mmf1.8-JP2019090947A Scale: 1.0 mm Wavelengths: 588, 656, 486 nm Fields: 0, 0.7, 1 Object: Semi-Angle: 32.5 deg Pupil: Pupil Distance: 34.9212 Refractive Index: 1.00028 Update Radius: True Radius: 9.60801 Image: Radius: 21.6 Update Radius: True Pupil: Pupil Distance: -48.0172 Refractive Index: 1.00028 Update Radius: True Radius: 13.583 Stop: 13 Elements: # T Distance Rad Curv Diameter Material n nd Vd 0 S 432 inf 64.8 basic/air 1.000 1.000 89.30 1 S 10.8 99.86 35.942 - 1.517 1.517 64.13 2 S 2.2032 18.97 29.074 basic/air 1.000 1.000 89.30 3 S 7.6464 87.98 28.382 - 1.954 1.954 32.33 4 S 5.5728 -43.83 27.648 - 1.603 1.603 38.03 5 S 1.7928 69.89 24.581 basic/air 1.000 1.000 89.30 6 S 5.6052 -27.96 23.674 - 1.689 1.689 31.16 7 S 3.7152 37.84 27.259 - 1.851 1.851 40.78 8 S 7.1064 -37.84 27.864 basic/air 1.000 1.000 89.30 9 S 0.3888 25.74 28.21 - 1.497 1.497 81.61 10 S 7.9488 -76.74 27.259 basic/air 1.000 1.000 89.30 11 S 0.1944 89.76 25.358 - 1.834 1.834 37.28 12 S 1.2312 42.85 24.062 basic/air 1.000 1.000 89.30 13 S 4.0392 inf 23.026 basic/air 1.000 1.000 89.30 14 S 11.102 -21.42 20.65 - 1.613 1.613 36.94 15 S 1.3392 -124.8 21.384 basic/air 1.000 1.000 89.30 16 S 0.2592 45.89 23.501 - 1.593 1.593 68.62 17 S 6.0912 -30.06 24.278 basic/air 1.000 1.000 89.30 18 S 4.5144 -181.8 25.877 - 1.694 1.694 53.20 19 S 2.1168 -60.86 26.525 basic/air 1.000 1.000 89.30 20 S 4.9464 -40.98 27.864 - 1.583 1.583 59.46 21 S 1.7928 -149.8 30.413 basic/air 1.000 1.000 89.30 22 S 16.222 inf 51.84 - 1.517 1.517 64.13 23 S 1.5984 inf 51.84 basic/air 1.000 1.000 89.30 24 S 0.99902 inf 43.2 basic/air 1.000 1.000 89.30 lagrange: -6.6194 track length: 97.427 object, image height: [24.0523 23.3938] front, back focal length (from PP): [-34.0061 34.0061] entry, exit pupil height: [ 9.608 13.583] entry, exit pupil distance: [ 24.1212 -47.0992] front, back focal distance: [0.0669 0.9756] front, back principal distance: [ 34.073 -33.0305] front, back nodal distance: [ 34.073 -33.0305] front, back numerical aperture: [0. 0.272] front, back f number: [1.7697 1.2518] front, back working f number: [ inf 1.839] front, back airy radius: [ inf 0.0013] transverse, angular magnification: [-0. 0.7074] # T path n axial y axial nu chief y chief nu 0 S 432 1 9.608 0 -24.05 0.6889 1 S 442.8 1.517 9.608 -0.0497 -16.61 0.7749 2 S 445 1 9.536 0.2099 -15.49 0.3532 3 S 452.6 1.954 11.14 0.08916 -12.79 0.4918 4 S 458.2 1.603 11.39 -0.00192 -11.38 0.5828 5 S 460 1 11.39 0.09639 -10.73 0.4902 6 S 465.6 1.689 11.93 0.3903 -7.986 0.2935 7 S 469.3 1.851 12.79 0.3353 -7.341 0.3251 8 S 476.4 1 14.08 0.0186 -6.093 0.4621 9 S 476.8 1.497 14.09 -0.2532 -5.913 0.5762 10 S 484.8 1 12.74 -0.3357 -2.854 0.5947 11 S 485 1.834 12.68 -0.4535 -2.738 0.6202 12 S 486.2 1 12.37 -0.2126 -2.322 0.575 13 S 490.2 1 11.51 -0.2126-2.308e-15 0.575 14 S 501.3 1.613 9.153 0.04916 6.382 0.7575 15 S 502.7 1 9.194 0.004034 7.011 0.7231 16 S 502.9 1.593 9.195 -0.1147 7.198 0.6301 17 S 509 1 8.756 -0.2873 9.608 0.4408 18 S 513.6 1.694 7.46 -0.2588 11.6 0.485 19 S 515.7 1 7.136 -0.3401 12.2 0.346 20 S 520.6 1.583 5.454 -0.2626 13.91 0.5439 21 S 522.4 1 5.157 -0.2826 14.53 0.4873 22 S 538.6 1.517 0.5735 -0.2826 22.43 0.4873 23 S 540.2 1 0.2757 -0.2826 22.95 0.4873 24 S 541.1 1 0.01635 -0.2826 23.39 0.4873 # T SA3 CMA3 AST3 PTZ3 DIS3 TACHC TCHC 0 S 0 0 0 0 0 0 0 1 S -0.003397 -0.01844 -0.1001 -0.264 -1.977 -0.01736 -0.09427 2 S 1.98 -1.287 0.8369 1.389 -1.447 0.1275 -0.0829 3 S -0.4157 -0.2567 -0.1585 -0.4294 -0.3631 -0.2 -0.1235 4 S -0.08513 0.2031 -0.4848 -0.1976 1.628 -0.08776 0.2094 5 S 0.1315 0.1707 0.2214 0.4166 0.8278 0.1033 0.1341 6 S 0.09323 -0.2189 0.5139 1.129 -3.857 0.1824 -0.4282 7 S -0.8146 0.02893 -0.001028 -0.1064 0.003815 0.07879 -0.002799 8 S -0.2464 0.4343 -0.7655 -0.9405 3.007 -0.1983 0.3496 9 S -1.049 -0.4307 -0.1768 -0.9978 -0.4822 -0.1145 -0.04702 10 S -1.261 1.588 -2 -0.3347 2.941 -0.09184 0.1157 11 S 3.324 -1.174 1.578 -0.3921 -3.047 0.1062 -0.3083 12 S -2.506 0.401 -0.5488 0.8215 2.481 0.04064 0.2777 13 S 0 0 0 0 0 -0 0 14 S 1.533 -0.6634 0.2871 1.373 -0.7182 0.2129 -0.09213 15 S -0.001171 0.01121 -0.1074 -0.2355 3.284 -0.02327 0.2228 16 S -0.03345 -0.1439 -0.6195 -0.6275 -5.367 -0.03602 -0.155 17 S -1.253 0.2622 -0.05488 -0.9578 0.2119 -0.09706 0.02031 18 S 0.9105 0.6595 1.893 0.1743 1.747 0.0666 -0.07646 19 S -0.6516 0.2215 -0.04587 -0.5206 0.2221 -0.08876 0.02822 20 S 0.5878 0.1977 0.522 0.6954 1.322 0.05648-0.0007599 21 S -0.2169 0.04792 -0.6763 -0.1903 -0.6725 -0.03578 0.04404 22 S 0.01292 -0.02228 0.03842 -0 -0.06625 0.003042 -0.005245 23 S -0.006211 0.01071 -0.01847 0 0.03185 -0.001462 0.002521 24 S 0 -0 0 0 0 -0 0 0.02914 0.02122 0.1332 -0.1959 -0.2901 -0.01424 -0.01227
<rayopt.analysis.Analysis at 0x1ec55e18e10>