Giter VIP home page Giter VIP logo

Comments (1)

ldoyle avatar ldoyle commented on June 14, 2024

Thanks, this is an interesting observation, I gave it a try and found the following:
The code evidently distinguishes between 0 and -0, resulting in a different complex phase angle.
Even though the code is Cpp based, you can recreate the same behaviour with numpy:

import numpy as np
a = np.zeros((5,),dtype=complex)
a *= np.exp(1j*np.pi/2*np.array([0,1,2,3,4])) #pi/2 * N = phase angle rotation in 90° steps
phi = np.angle(a)
print(f'a = {a}') #f-strings work in python >= 3.6, else use '{}'.format(a)
print(f'phi = {phi}')
#output:
# a = [ 0.+0.j  0.+0.j -0.+0.j  0.-0.j  0.+0.j]
# phi = [ 0.          0.          3.14159265 -0.          0.        ]

As you can see, the resulting a "rotates" from (0+j0) via (-0+j0), (0-j0) back to (0,0) just as it would for (1+j0), (0+j1), (-1+j0), (0-j1), (1+j0) with magnitude 1 instead of 0.
Indeed for some operations like 1/np.inf and 1/-np.inf it may be important to keep the sign, but of course here it is a side-effect.

Nevertheless, the code works fine, since at 0 intensity the phase is meaningless (and in this case just jumps between 0, -0 and 2pi, which are really the same). I checked and the intensity will definitely be 0.0 after RectAperture(), no matter the order of functions.
In fact, also in your hologram examples in the other issue posted, a lot of data points will have seemingly random phases, but at sufficiently low intensity this is meaningless and for plotting often phase-blanking is convenient (i.e. setting phase=0 or NaN when Intensity<threshold).

from lightpipes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.