scottprahl / laserbeamsize Goto Github PK
View Code? Open in Web Editor NEWpython module for ISO 11146 analysis of laser beam images
License: MIT License
python module for ISO 11146 analysis of laser beam images
License: MIT License
When I use your code:
import imageio.v3 as iio
import laserbeamsize as lbs
file = "https://github.com/scottprahl/laserbeamsize/raw/master/docs/t-hene.pgm"
image = iio.imread(file)
x, y, dx, dy, phi = lbs.beam_size(image)
print("The center of the beam ellipse is at (%.0f, %.0f)" % (x, y))
print("The ellipse diameter (closest to horizontal) is %.0f pixels" % dx)
print("The ellipse diameter (closest to vertical) is %.0f pixels" % dy)
print("The ellipse is rotated %.0f° ccw from the horizontal" % (phi * 180/3.1416))
I can get the expected results.
But then I follow your instructions from the screenshot1.png:
"A visual report can be done with one function call:
lbs.beam_size_plot(beam)
plt.show() "
The code would return error: AttributeError: module 'laserbeamsize' has no attribute 'beam_size_plot',pls see the screenshot2.png.
I wonder whether there is some trouble with my understanding on your code? And I also search the "beam_size_plot" in all the API from your link "https://laserbeamsize.readthedocs.io/en/latest/index.html",
and cannot find the "beam_size_plot" attribute.
A colleague of mine brought up that the clipping to zero done in these functions is not mentioned in the iso standard. Therefore this wouldn't be completely iso conform. Instead, negative numbers should be used for the next steps. Would you be interested in changing this?
I noticed that you have a focused_diameter
function for the diffraction limited spot size. In the function, the size is not proportional to the
This is different to what I would expect and other treatments of this. Nevertheless, I was able to dig up the equation in the referenced text and it is indeed
Just wondering if the equation is right or I have some confusion here.
Thank you for contributing this library and the documentation, I have found it very useful and works great so far. I shall now be able to retire my personal, much less complete beam profiling code.
When we can expect ISO 11146-2 implementation in this project ? :)
Dear Scott,
Thank you for this amazingly useful library.
I have just discovered that Gaussian fit seems to be invalid for heavily astigmatic beams, and therefore, the function returns the incorrect beam diameters. Please refer to the image below.
Is there any parameter to overcome the problem?
UPD
It seems (from the values) that dx and dy are just mixed up here
Regards
Hello!
I'm getting wrong beam diameter estimation. Here is the result of lbs.beam_size_plot(beam, pixel_size=5.2, units='µm')
:
Original image: image.zip
Hi Scott Prahl,
Thanks for code. I've just used your code in data processing.
But i find data printed differs from data in plot with my experiment data.
And i cannot find what happened to this. Please help~
Data Printed
laserbeamsize
M2x 1.29 ± 0.03
M2y 1.07 ± 0.11
d0x 152 ± 3 µm
d0y 135 ± 14 µm
Thetax 5.28 ± 0 mrad
Thetay 4.95 ± 0 mrad
z0x -276 ± 1 mm
z0y -277 ± 3 mm
zRx 29 ± 1 mm
zRy 27 ± 6 mm
Experiment data
lambda4 = 488e-9
d_scan_head = 0
f = 150
z = np.array([210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320,
760, 770, 780, 790, 800, 810, 820, 830, 840, 850]) * 1e-3
dx = np.array([397.4, 330.2, 284.4, 242.8, 192.6, 167.1, 142.1, 148.5, 180.7, 206.1, 242.3,
287.5, 2570.9, 2622.5, 2675.6, 2726.5, 2780.2, 2832.2, 2886.8, 2939.3, 2992.1, 3024.3]) * 1e-6
dy = np.array([382.3, 329.4, 277.9, 226.1, 182.1, 149.1, 128.5, 126.3, 145.8, 178.2, 220.7,
263.7, 2465.3, 2503.9, 2540.6, 2574.7, 2608.4, 2641.9, 2677.1, 2712.5, 2739.9, 2768.1]) * 1e-6
When specifying the phi
argument of lbs.beam_size
, a zero value (0.0) is not accepted.
It is, however, useful to do so, e.g., for measuring the m2 of an astigmatic beam.
Looking into the code, I'm pretty sure the reason is in line 205 of laserbeamsize/analysis.py
:
phi_ = phi or phi_
There is a workaround I used, that is specifying phi as a really small but nonzero value or 180degrees, however I don't think this is elegant and yields unexpected results.
I think a robust fix would be a change to
phi_ = phi if phi is not None else phi_
in lines 205 and 223 of laserbeamsize/analysis.py
.
This would require no further changes.
Would you be interested in considering this?
Thanks for this great module, I use it all the time!
>>> phi = 0.0
>>> phi_ = 1.0
>>> phi or phi_ # Gives phi_, even though phi is defined
1.0
>>> phi if phi is not None else phi_ # Works as expected
0.0
I like this module, as is makes analysis very easy. However, I wonder about the fitting for M2. Especially I refer to
def _beam_fit_fn_(z, d0, z0, Theta): """Fitting function for d0, z0, and Theta.""" return d0**2 + (Theta*(z-z0))**2
I understand the idea of fitting d(z)^2 = ... wwithout the sqrt. But if I change the input from d**2 to d and also the function from d0**2 + (Theta*(z-z0))**2
to np.sqrt(d0**2 + (Theta*(z-z0))**2)
, I get different results.
Has anyone an idea, where this change comes from and how to get the proper output? Which of the two versions is right?
Hello!
I have a highly astigmatic laser diode. At some point after a lens I getting this with lbs.beam_size_montage()
:
No problems with estimating the center of the beam, but axes are rotated by 45 degrees. Laser modes are aligned along x and y axes, no need to rotate them (almost).
Is there any type of workaround for this problem?
Here is the original image from Thorlabs DCC1545M: astigmatic_beam.zip
P.S. Thanks a lot for this project !!!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.