All Projects → scottprahl → laserbeamsize

scottprahl / laserbeamsize

Licence: MIT license
Extract the ISO 11146 beam size from an image file

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to laserbeamsize

Laser
Python modules for laser simulation
Stars: ✭ 20 (-16.67%)
Mutual labels:  laser
Laserweb4
Collaborative effort on the next version of LaserWeb / CNCWeb
Stars: ✭ 456 (+1800%)
Mutual labels:  laser
Midi To Laser Cutter
Stars: ✭ 122 (+408.33%)
Mutual labels:  laser
mightyscape-1.X
A maintained extension collection for Inkscape 1.0+, working on Windows and Linux
Stars: ✭ 23 (-4.17%)
Mutual labels:  laser
Boxes
Boxes.py - laser cutting boxes and more
Stars: ✭ 429 (+1687.5%)
Mutual labels:  laser
Laser writing machine
激光雕刻写字机器人、laser、sculpture、writing、C#、STC12c5a60s2、G-Code
Stars: ✭ 27 (+12.5%)
Mutual labels:  laser
Laser-XY-Scanner
Low Cost DIY Laser XY Scanner, Cutter, or Engraver
Stars: ✭ 27 (+12.5%)
Mutual labels:  laser
Opensimplelidar
Open Source scanning laser rangefinder
Stars: ✭ 2,206 (+9091.67%)
Mutual labels:  laser
Picongpu
Particle-in-Cell Simulations for the Exascale Era ✨
Stars: ✭ 452 (+1783.33%)
Mutual labels:  laser
Fbpic
Spectral, quasi-3D Particle-In-Cell code, for CPU and GPU
Stars: ✭ 111 (+362.5%)
Mutual labels:  laser
Camlasercalibratool
Extrinsic Calibration of a Camera and 2d Laser
Stars: ✭ 277 (+1054.17%)
Mutual labels:  laser
Godot Visual Effects
Open-source visual effects designed in Godot, from our VFX Secrets course.
Stars: ✭ 288 (+1100%)
Mutual labels:  laser
Maker.js
📐⚙ 2D vector line drawing and shape modeling for CNC and laser cutters.
Stars: ✭ 1,185 (+4837.5%)
Mutual labels:  laser
camera lidar calibration
A tool used for calibrate the extrinsic between 2D laser range finder (LRF) and camera. ROS Version: https://github.com/TurtleZhong/camera_lidar_calibration_v2
Stars: ✭ 48 (+100%)
Mutual labels:  laser
Openlidar
Open Hardware scanning triangulation laser rangefinder
Stars: ✭ 166 (+591.67%)
Mutual labels:  laser
three-laser-pointer
Interactive laser object for VR-like scenes
Stars: ✭ 26 (+8.33%)
Mutual labels:  laser
Lasergrbl
Laser optimized GUI for GRBL
Stars: ✭ 609 (+2437.5%)
Mutual labels:  laser
Rf2o laser odometry
Estimation of 2D odometry based on planar laser scans. Useful for mobile robots with innacurate base odometry. For full description of the algorithm, please refer to: Planar Odometry from a Radial Laser Scanner. A Range Flow-based Approach. ICRA 2016 Available at: http://mapir.isa.uma.es/mapirwebsite/index.php/mapir-downloads/papers/217
Stars: ✭ 191 (+695.83%)
Mutual labels:  laser
Musicbeam
MusicBeam is a multi plattform software to use a projector as a rgb laser.
Stars: ✭ 186 (+675%)
Mutual labels:  laser
Jsprintmanager
Advanced Client-side Printing & Scanning Solution for Javascript
Stars: ✭ 74 (+208.33%)
Mutual labels:  laser

laserbeamsize

by Scott Prahl


Simple and fast calculation of beam sizes from a single monochrome image based on the ISO 11146 method of variances. Some effort has been made to make the algorithm less sensitive to background offset and noise.

This module also supports M² calculations based on a series of images collected at various distances from the focused beam.

Extensive documentation can be found at <https://laserbeamsize.readthedocs.io>

Using laserbeamsize

  1. Install with pip:

    pip install --user laserbeamsize
    
  2. or run this code in the cloud using Google Collaboratory by selecting the Jupyter notebook that interests you.

  3. use binder which will create a new environment that allows you to run Jupyter notebooks. This takes a bit longer to start, but it automatically installs laserbeamsize.

  4. clone the laserbeamsize github repository and then add the repository to your PYTHONPATH environment variable

Determining the beam size in an image

Finding the center and dimensions of a good beam image:

import imageio
import numpy as np
import matplotlib.pyplot as plt
import laserbeamsize as lbs

beam = imageio.imread("t-hene.pgm")
x, y, dx, dy, phi = lbs.beam_size(beam)

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 horizontal" % (phi*180/3.1416))

to produce:

The center of the beam ellipse is at (651, 491)
The ellipse diameter (closest to horizontal) is 334 pixels
The ellipse diameter (closest to   vertical) is 327 pixels
The ellipse is rotated 29° ccw from the horizontal

A visual report can be done with one function call:

lbs.beam_size_plot(beam)
plt.show()

produces something like

hene-report.png

or:

lbs.beam_size_plot(beam, r"Original Image $\lambda$=4µm beam", pixel_size = 12, units='µm')
plt.show()

produces something like

astigmatic-report.png

Non-gaussian beams work too:

# 12-bit pixel image stored as high-order bits in 16-bit values
tem02 = imageio.imread("TEM02_100mm.pgm") >> 4
lbs.beam_size_plot(tem02, title = r"TEM$_{02}$ at z=100mm", pixel_size=3.75)
plt.show()

produces

tem02.png

Determining M²

Determining M² for a laser beam is also straightforward. Just collect beam diameters from five beam locations within one Rayleigh distance of the focus and from five locations more than two Rayleigh distances:

lambda1=308e-9 # meters
z1_all=np.array([-200,-180,-160,-140,-120,-100,-80,-60,-40,-20,0,20,40,60,80,99,120,140,160,180,200])*1e-3
d1_all=2*np.array([416,384,366,311,279,245,216,176,151,120,101,93,102,120,147,177,217,256,291,316,348])*1e-6
lbs.M2_radius_plot(z1_all, d1_all, lambda1, strict=True)
plt.show()

produces

m2fit.png

Here is an analysis of a set of images that do not meet the ISO 11146 requirements for determining M² (because the image locations are not taken in right locations relative to the focus). These beam images are from a HeNe laser with slightly misaligned mirrors to primarily lase in a TEM₀₁ transverse mode. The laser resonator had a fixed rotation of 38.7° from the plane of the optical table.:

lambda0 = 632.8e-9 # meters
z10 = np.array([247,251,259,266,281,292])*1e-3 # meters
filenames = ["sb_%.0fmm_10.pgm" % (number*1e3) for number in z10]

# the 12-bit pixel images are stored in high-order bits in 16-bit values
tem10 = [imageio.imread(name)>>4 for name in filenames]

# remove top to eliminate artifact
for i in range(len(z10)):
    tem10[i] = tem10[i][200:,:]

# find beam rotated by 38.7° in all images
fixed_rotation = np.radians(38.7)
options = {'pixel_size': 3.75, 'units': "µm", 'crop': [1400,1400], 'z':z10, 'phi':fixed_rotation}
dy, dx= lbs.beam_size_montage(tem10, **options)  # dy and dx in microns
plt.show()

produces

sbmontage.png

Here is one way to plot the fit using the above diameters:

lbs.M2_diameter_plot(z10, dx*1e-6, lambda0, dy=dy*1e-6)
plt.show()

In the graph on the below right, the dashed line shows the expected divergence of a pure gaussian beam. Since real beams should diverge faster than this (not slower) there is some problem with the measurements (too few!). On the other hand, the M² value the semi-major axis 2.6±0.7 is consistent with the expected value of 3 for the TEM₁₀ mode.

sbfit.png

License

laserbeamsize is licensed under the terms of the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].