brandondube / prysm

physical optics: integrated modeling, phase retrieval, segmented systems, polynomials and fitting, sequential raytracing...
https://prysm.readthedocs.io/en/stable/
MIT License
269 stars 46 forks source link

Wrong sign in odd angular part #33

Closed lepus2589 closed 3 years ago

lepus2589 commented 3 years ago

When using the Zernike module, I noticed an error in the implemented algorithm. In the angular part of odd zernike terms (sine function), the sign of the argument is wrong. The argument of both sine and cosine depends only on abs(m). sign(m) is only used to determine, if you should use the sine or cosine (see https://en.wikipedia.org/wiki/Zernike_polynomials#Zernike_polynomials, compare pairs of +m and -m).

https://github.com/brandondube/prysm/blob/56ce1be8cc7e4261a27f4cb4d96af74f7a468494/prysm/zernike.py#L447 https://github.com/brandondube/prysm/blob/56ce1be8cc7e4261a27f4cb4d96af74f7a468494/prysm/zernike.py#L511

brandondube commented 3 years ago

Thanks for the bug report!

This is fixed on the dev branch. v0.20 is a long time (~3-6mo) from release. If you'd like to introduce the fix for a v0.19.2, please make a PR

If you are only interested in polynomials and not the other features, the polynomials submodule of v0.20 is mostly complete. It's considerably faster than before, with more polynomials and more flexible functions.

brandondube commented 3 years ago

Closed as stale and resolved for the next major version.