Coder Social home page Coder Social logo

zGetPSF about pyzdde HOT 3 CLOSED

B2015 avatar B2015 commented on September 15, 2024
zGetPSF

from pyzdde.

Comments (3)

indranilsinharoy avatar indranilsinharoy commented on September 15, 2024

Hi Ben,

Thanks very much for spreading the word.

I have seen these type of problems a few times before (that's the reason why I decided to put the "assert ret == 0" in order to localize the error. Although I don't have an exact solution, but I have noted a few things that could potentially result in this type of problem:

  1. The first thing to check would be that the text encoding between PyZDDE and Zemax is the same. To see the text encoding set in PyZDDE use pyz.getTextEncoding(), assuming you have done import pyzdde.zdde as pyz at the beginning. To set the text encoding, use pyz.setTextEncoding().
  2. If the filename(s) of the text or (especially) the .cfg file is very long (I don't have an estimate of how long). I have seen this problem when I tried to do "image simulation", and I have documented it (under the "NOTE" section at the beginning of this IPython notebook. Using a shorter name for the .cfg file generally works OK. In order to debug, I would copy the .cfg file to some temporary directory (e.g. C:\tmp), and provide a very short names (e.g. c:\tmp\tmp.txt, and c:\tmp\<lens_filename.cfg>) to ensure that the function works. Also, I would set keepFile=True to see what file has been dumped.
  3. If step 2 works, fine then the problem could be due to long file name or due to access permission to a particular directory in Windows.
  4. If step 2 didn't work, then there could be a problem with the settings file (I understand that the likelihood of this is very small. Generally, if the .cfg file is not valid, Zemax is supposed to use the default .cfg file .... however, I have seen a problem like this when I tried to do "Image simulation". In that case, the error is generally sometime like IOError: [Errno 2] No such file or directory: ...
  5. See if it related to #55 ().

I wish Zemax would have returned a more useful error code.

I hope that helps.

Best regards,
Indranil.

from pyzdde.

B2015 avatar B2015 commented on September 15, 2024

Hello Indranil,

Thanks much for the help! We already checked your first point and made sure the text encoding is correct. I think that you second point may be spot on because the path he's using is quite long, I'll suggest him to put the Zemax files somewhere else and see if it works well.

By the way, I tested a script using zGetPSF on yet another colleague's computer (did I tell you about spreading the word ;-) ), and found a small issue while trying to read the 2D psf_data. Indeed, the zdde regex is looking for number where the exponent contains 3 digits while for some reasons, the text file returned by zemax/OS on my other colleague's computer has only two digits. To prevent this I would suggest transforming the current pattern:

pat = (r'(-?\d.\d{4,6}[Ee][-+]\d{3}\s*)' + r'{{{num}}}'
.format(num=img_grid_x))

into:

pat = (r'(-?\d.\d{4,6}[Ee][-+]\d{2,3}\s*)' + r'{{{num}}}'
.format(num=img_grid_x))

Cheers,

Ben

from pyzdde.

indranilsinharoy avatar indranilsinharoy commented on September 15, 2024

Hi Ben,

Thanks very much for the suggestion on the regex pattern. I will update the code based on your suggestion. Till then I will keep this issue open.

Best regards,
Indranil.

from pyzdde.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.