Closed Jonas231 closed 1 year ago
Hello Jonas, When I tried to reproduce your problem, I got an error on the first line you included. The line should be:
root_pth = Path(rayoptics.__file__).resolve().parent
with double underscores around file
. When I do this, the file reads correctly for me.
Let me know if you have further problems. Sincerely,
Mike Hayford
Hello Mike, thank you for your answer. I think the error is somewhere else:
I used this code in a jupyter notebook:
%matplotlib inline
from rayoptics.environment import *
root_pth = Path(rayoptics.file).resolve().parent opm, info = open_model(root_pth/"zemax/tests/354710-C-Zemax(ZMX).zmx", info=True)
info is then listed correctly.
Then come the commands:
sm = opm['seq_model'] osp = opm['optical_spec'] pm = opm['parax_model'] em = opm['ele_model'] pt = opm['part_tree'] ar = opm['analysis_results']
Here the error occurs:
TypeError Traceback (most recent call last) Input In [11], in <cell line: 1>() ----> 1 sm = opm['seq_model'] 2 osp = opm['optical_spec'] 3 pm = opm['parax_model']
TypeError: 'OpticalModel' object is not subscriptable
Could you please help me remove this error message?
Regards, Jonas
The __ of file are remove due to copy and paste. I used: root_pth = Path(rayoptics.file).resolve().parent
file
What version of rayoptics is installed? Either use pip:
pip show rayoptics
or use the pkg_resources
module:
import pkg_resources
print(pkg_resources.get_distribution('rayoptics').version)
The current version of rayoptics is 0.8.1.
Hello Mike, it seems both "pip install rayoptics" and "conda install rayoptics --channel conda-forge" installed this older version: pip show rayoptics: Name: rayoptics Version: 0.6.2 Summary: Tools for image forming optical design and analysis Home-page: https://github.com/mjhoptics/ray-optics Author: Michael J Hayford Author-email: mjhoptics@gmail.com License: BSD 3 Clause Location: c:\users\herbst\anaconda3\envs\mypython38\lib\site-packages Requires: ipython, qdarkstyle, json-tricks, matplotlib, qtconsole, attrs, transforms3d, traitlets, opticalglass, numpy, scipy, pandas, requests, ipywidgets, pyqt5 Required-by:
How do I update to 0.8.1? Best regards, Jonas
That’s odd. You should be able to force it to install a particular version, e.g.
Conda update ray optics==0.8.1.
Hope this helps.
Mike
On Jun 1, 2022, at 11:41 PM, Jonas231 @.***> wrote:
Hello Mike, it seems both "pip install rayoptics" and "conda install rayoptics --channel conda-forge" installed this older version: pip show rayoptics: Name: rayoptics Version: 0.6.2 Summary: Tools for image forming optical design and analysis Home-page: https://github.com/mjhoptics/ray-optics Author: Michael J Hayford Author-email: @.*** License: BSD 3 Clause Location: c:\users\herbst\anaconda3\envs\mypython38\lib\site-packages Requires: ipython, qdarkstyle, json-tricks, matplotlib, qtconsole, attrs, transforms3d, traitlets, opticalglass, numpy, scipy, pandas, requests, ipywidgets, pyqt5 Required-by:
How do I update to 0.8.1? Best regards, Jonas
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.
Okay. Thank you for the idea. I get this:
(mypython38) C:\Users\herbst>Conda update ray optics==0.8.1.
CondaValueError: invalid package specification: optics==0.8.1.
I used: conda install -c conda-forge rayoptics==0.8.1 Now the example works.
Great! I think I have my default channel set to conda-forge so I forgot it include it explicitly in my reply. Best regards, Mike
On Jun 10, 2022, at 11:54 AM, Jonas231 @.***> wrote:
I used: conda install -c conda-forge rayoptics==0.8.1 Now the example works.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.
Hello,
I tried to do your example:
root_pth = Path(rayoptics.file).resolve().parent opm, info = open_model(root_pth/"zemax/tests/354710-C-Zemax(ZMX).zmx", info=True)
osp = opm.optical_spec
sm = opm['seq_model']
osp = opm['optical_spec']
pm = opm['parax_model']
em = opm['ele_model']
pt = opm['part_tree']
ar = opm['analysis_results']
And get this error:
TypeError Traceback (most recent call last) Input In [36], in <cell line: 3>() 1 osp = opm.optical_spec ----> 3 sm = opm['seq_model']
TypeError: 'OpticalModel' object is not subscriptable
Best regards, Jonas