Closed Ezreal147 closed 3 weeks ago
At a glance the results seems identical. The colormap distorts your perception outside the circle, cause you have -1 with the Matlab representation and 0 with this module. Just export a .dat output and compare both by subtracting them element-wise.
I have also noticed this. The scale seems to be double of the of the matlab code. Ignore the colors, as they are close in this image, but look at the peak and valley. This python library is almost double that of matlabs.
This seems to agree: https://github.com/AlvaroMenduina/ZERN/blob/master/examples/1_tutorial.ipynb Maybe there is some normalization not happening?
Zernike polynomials can be normalised in many ways. This code uses Noll's ordering and normalisation (https://opg.optica.org/josa/abstract.cfm?uri=josa-66-3-207), which is standard in adaptive optics literature. It allows to easily compute the root-mean-square and variance of aberrations (https://opg.optica.org/ao/abstract.cfm?uri=ao-33-34-8121). Plus there is a test for the normalisation https://github.com/jacopoantonello/zernike/blob/e81e48b07d706bf924d7b5098ac190a06a3a7471/zernike/test.py#L339 which is not reporting any error. In https://en.wikipedia.org/wiki/Zernike_polynomials#Zernike_polynomials the formula for Z_2^0 should yield -sqrt(3) at the centre and +sqrt(3) at the edge of the unit circle, which seems correct looking at your first plot.
This is the fourth term with a coefficient of 1 calculated by this module:
and this is calculated by matlab function:
the matlab function can be downloaded here.
So, why the results are different? Which is correct?