Skip to main content
Solved

Fit freeform surface to grid sag


I have a grid sag surface that was generated using sag values at a bunch of x, y points. I want to fit a more parameterized freeform surface (e.g. biconic zernike, Chebyshev polynomial, or polynomial) to this grid sag surface. I’ve tried to create a dummy surface after the grid sag surface and set parameters of the dummy surface to be variable. Then I used merit functions such as NORD or PLEN to try and minimize the distance or path length between the two surfaces. This sort of works, but the results of the fit aren’t very good and there’s usually some residual tilt that it seems like Zemax can’t find the right parameters for.

I have tried this process with spherical or biconic surfaces, and it works very well for those. It seems like anything that is off-axis or tilted really throws off the optimization. Any tips or other approaches that I should consider?

Best answer by David.Nguyen

Hi itsjdl,

 

I’m not convinced OpticStudio is the right tool to do that. Your approach sounds reasonable and I can’t comment further on why it isn’t working, but you might be better off using something like Python (or MATLAB if you have it) to perform the fit. In Python, SciPy has some handy features to do just that. Have a look at this thread. You mainly need to modify the fit function (called function in the answer) to match whatever freeform surface you want (the equations can be found in the Help File typically).

Once the fit is done, you can input the parameters in OpticStudio. You could even automate the work with the ZOS-API.

Hope this helps.

Take care,

 

David

View original
Did this topic help you find an answer to your question?

2 replies

David.Nguyen
Luminary
Forum|alt.badge.img+2
  • Luminary
  • 1085 replies
  • Answer
  • May 27, 2022

Hi itsjdl,

 

I’m not convinced OpticStudio is the right tool to do that. Your approach sounds reasonable and I can’t comment further on why it isn’t working, but you might be better off using something like Python (or MATLAB if you have it) to perform the fit. In Python, SciPy has some handy features to do just that. Have a look at this thread. You mainly need to modify the fit function (called function in the answer) to match whatever freeform surface you want (the equations can be found in the Help File typically).

Once the fit is done, you can input the parameters in OpticStudio. You could even automate the work with the ZOS-API.

Hope this helps.

Take care,

 

David


  • Single Emitter
  • 3 replies
  • October 25, 2022
 segdata = ZRDResult.ReadNextSegmentFull(1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
                11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
                21, 22, 23, 24, 25, 26, 27, 28, 29)

 

Python.Runtime.PythonException: since Python.NET 3.0 int can not be converted to Enum implicitly. Use Enum(int_value)

The above exception was the direct cause of the following exception:

System.ArgumentException: since Python.NET 3.0 int can not be converted to Enum implicitly. Use Enum(int_value) in method Boolean ReadNextSegmentFull(Int32 ByRef, Int32 ByRef, Int32 ByRef, Int32 ByRef, Int32 ByRef, ZOSAPI.Tools.RayTrace.RayStatus ByRef, Double ByRef, Double ByRef, Double ByRef, Double ByRef, Double ByRef, Double ByRef, Double ByRef, Double ByRef, Double ByRef, Double ByRef, Double ByRef, Double ByRef, Double ByRef, Double ByRef, Int32 ByRef, Int32 ByRef, Double ByRef, Double ByRef, Double ByRef, Double ByRef, Double ByRef, Double ByRef, Double ByRef) ---> Python.Runtime.PythonException: since Python.NET 3.0 int can not be converted to Enum implicitly. Use Enum(int_value)

 

Hi itsjdl

 

When I run it at line 195 it seems that the interface is not compatible.

 

Environment:

zemax: 20.2.1

python: 3.10.0

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings