Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed ellipse orientation in beam_size function #19

Open
przemororo opened this issue May 12, 2024 · 0 comments
Open

fixed ellipse orientation in beam_size function #19

przemororo opened this issue May 12, 2024 · 0 comments

Comments

@przemororo
Copy link

Hello, I'm having trouble calculating the width of a laser beam in a specific rotated coordinate system. In function: laserbeamsize.analysis.beam_size(image, mask_diameters=3, corner_fraction=0.035, nT=3, max_iter=25, phi=None, iso_noise=True) there is phi argument which fix the ellipse azimuth. But looks like it doesn't work. Here is example based on beam generation using build in function laserbeamsize.image_tools.create_test_image(h, v, xc, yc, dx, dy, phi, noise=0, ntype='poisson', max_value=255)

import numpy as np
import laserbeamsize as lbs

beam = lbs.create_test_image(h = 600, v = 600, xc = 300, yc = 300, dx = 150, dy = 100, phi = np.pi/4)

xc, yc, dx, dy, phi = lbs.beam_size(beam, phi = 0)
print("Phi = 0")
print(xc, yc, dx, dy, phi/np.pi)
xc, yc, dx, dy, phi = lbs.beam_size(beam, phi = np.pi/2)
print("Phi = pi/4")
print(xc, yc, dx, dy, phi/np.pi)
xc, yc, dx, dy, phi = lbs.beam_size(beam, phi = np.pi/4)
print("Phi = pi/4")
print(xc, yc, dx, dy, phi/np.pi)

The beam is titled by -45 degrees from x axis and looks:
obraz

The output is:

Phi = 0
300.7037284975563 300.0015631385715 146.96479605836058 97.9867640173793 0.0
Phi = pi/4
300.7037284975563 300.0015631385715 146.96479605836058 97.9867640173793 0.5
Phi = pi/4
300.7037284975563 300.0015631385715 146.96479605836058 97.9867640173793 0.25

It seems that regardless of the declared value of the ellipse orientation, it always looks for the optimal one even if you want to calculate in specified axis. For example if I want calculate beam width in x and y axis (phi = 0 or pi), the width should be the same:

xc = 300
yc = 300
x = np.arange(0, 600)
X, Y = np.meshgrid(x, x)
dx = 4 * np.sqrt(np.sum((X - xc)**2 * beam) / np.sum(beam))
dy = 4 * np.sqrt(np.sum((Y - yc)**2 * beam) / np.sum(beam))
print(dx, dy)

The output is:
124.93714721914387 124.89471657232691

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant