Skip to main content

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?

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


 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