A new function for the Optics package

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

A new function for the Optics package

Jose Ramom Flores das Seixas

Hi:

I have written a function that could be incorporated to the optics package. This new function calculates the Zernike polynomials and their partial derivatives in Cartesian coordinates, using a recursive algorithm described in reference [1].

I'm sending an attachment with three files:

  • zernikes_and_derivatives_cartesian_OSA.m, it is the main function
  • zernike_osa_ansi_to_mn.m, it's a small function needed by the main function. It is similar to zernike_noll_to_mn.m, part of package optics, but for "OSA/ANSI standard indices" instead of "Noll's sequential indices".
  • Zernikes_cartesian_OSA.pdf, where the recurrence relations are explained, as well as the modifications to these relations that I have made to accommodate the standard OSA. I wrote this file for those who want to understand the algorithm used.

It's the first time I've sent anything, so it's possible there was some loose end left.

The main function has been checked by comparing it with the explicit expressions of the Zernike polynomials, and their partial derivatives, and the results obtained are coherent. I.e. the differences are either zero or very small, in the order of 1e-14.

I also compared my function with zernike_cartesian.m, a function of the optics package written by Andreas Weber. The differences are either zero or very small. To my disappointment, the average execution times are similar. So the main improvement that introduces my function is the calculation of partial derivatives.

[1] Andersen T.B., Efficient and robust recurrence relations for the Zernike circle polynomials and their
derivatives in Cartesian coordinates. Optic Express 26 (15), 18878-18896 (2018).


Surely yours

José Ramom




Zernikes_and_derivatives_Cartesian_OSA.zip (187K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: A new function for the Optics package

Andreas Weber-6
Hi Jose,
thank you for your contribution.

Am 21.07.19 um 17:38 schrieb Jose Ramom Flores das Seixas:
> I have written a function that could be incorporated to the optics
> package. This new function calculates the Zernike polynomials and their
> partial derivatives in Cartesian coordinates, using a recursive
> algorithm described in reference [1].
>
> I'm sending an attachment with three files:
>   * zernikes_and_derivatives_cartesian_OSA.m, it is the main function

Is this really needed? I only had a quick look but for me it looks like
a lookup table with coefficients, which can be calculated. (and btw, a
licence header is missing)

Can you also add some tests (if they make sense) and some demos?
The demos often serve as exmaples to show how a function can be used.

>   * Zernikes_cartesian_OSA.pdf, where the recurrence relations are
>     explained, as well as the modifications to these relations that I
>     have made to accommodate the standard OSA. I wrote this file for
>     those who want to understand the algorithm used.

I think this can go inside a ./doc directory. Can you also provide the
tex source which generated the pdf? I think we should include this and
generate the pdf in the Makefile.

> It's the first time I've sent anything, so it's possible there was some
> loose end left.

I'm very busy so it would be good if you can create a hg changeset which
I can apply. And perhaps you can have a look how other forge packages
include documentation and how it can be found by the user.

> I also compared my function with zernike_cartesian.m, a function of the
> optics package written by Andreas Weber. The differences are either zero
> or very small. To my disappointment, the average execution times are
> similar.

I've implemented them for adaptive optics using EASLMs and generate
holograms so speed was always important ;-)

-- Andy

PS: If I don't respond within a week please feel free to trigger me
again and again. I'm very busy and things might get lost