Showing results for 
Search instead for 
Did you mean: 

Laser Beam Width using second Moment Width

Go to solution



I am Physicist. I am currently working on the project where, I have to measure laser beam width using second moment width formula (4* Sigma). I did using 86% (1/E^2) method. but it's not give a correct and accurate plot when beam is not circular. Also it's not ISO Standard method to measure laser beam width.

Here, I have uploaded my work. 

Please if anybody previously work on this kind of project, guide me through this problem. I just need little bit guidance. 


0 Kudos
Message 1 of 17

What do you think should the "accurate" plot" look like?

Do you have a link describing the formulas used?



  • "Index array" is resizeable
  • There is no need for the local variables, just use a wire
  • None of your sequence frame serve any purpose. Why are they there?
  • Your while loops should be FOR loops because the number of iterations is known before the loop starts
  • You can use autoindexing on the 2D and transposed 2D array inputs, no need to measure the size.
  • Is this really typical and good data?
  • Since x of your xy graphs is equally spaced, all you need are plain waveform graphs.
  • Why is there so much duplicate code? Can't you re-use some of it?



LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 2 of 17

Hello Altenbach,


Thank you so much for really quick reply. 


I understood all your questions regarding the old code. I will remove all the duplicating stuff and also clean up code later. 

I just attached this code to give an example what I did in past. 


Basically this code generate the output like attached file. 

Here, I also attached the link for second moment waist calculation. 


I have also one more question,

Do you have any idea about integration of waveform. how we can integrate the waveform?




Download All
0 Kudos
Message 3 of 17

I'm not sure why you're using the 1/e² method if you're supposed to use the d4 Sigma method.  If you use d4 Sigma, all you need to do is calculate the centroid first, and then the diameter is derived by summing the square of the distance from each point of the image to the centroid, multiplied by the intensity at that point. The entire summation is then divided by the total power (energy) of the beam, and the square root of that value is multiplied by 2 times sqrt(2).

 = 2 * SQRT(2 * SUM [((x - xc)² + (y - yc)²) * p(x,y)] / I)


where xc and yc are the coordinates of the image centroid, p(x,y) is the intensity at location (x,y), I is the total intensity of the image, and SUM is taken over the total image area.


Because the d4 Sigma Diameter measurement uses the square of the distance from the centroid, background noise can have a significant impact on the calculation. Therefore, it is extremely important that a background subtraction or other noise removal feature be used with the d4 Sigma Diameter measurement.

Message 4 of 17



I am totally agree with you. That's exactly what I have to do.

Only, thing is I need little bit suggestion how can i perform this task in labview. i.e. Small example, or similar calculation example. 

Can you explain me through small vi?

If it's possible.



0 Kudos
Message 5 of 17
Accepted by sspp07

Generally I find that when converting a formula to a LabVIEW expression, there are generally two ways:

1. Follow PEMDAS except instead of doing a calculation, drop a node and wire it.  Done properly this ensures you don't forget anything.

2. Use a formula node (or expression node if it's very simple) and just write it out, with slight modifications to match the allowed formatting.


So in your case, if you have a 2D array of intensities, you'd probably pass it into 2 nested FOR loops to get x and y from the iteration terminals and p(x,y) from the scalar out of the array auto-index terminal, and that gives you everything you need for the elements inside the square brackets.  Then, out of each loop, put in a "Add array elements" node to sum rows and then columns, and do the final calculations on the sum.

0 Kudos
Message 6 of 17

Thanks. I will try to follow this steps if I faced any problem will let you know.


Thank you so much for help.


0 Kudos
Message 7 of 17



Here, I have attached my VI. As per your suggestion I made it. 


Could you please check it and let me know, did I solved correctly or not?



0 Kudos
Message 8 of 17

It looks like it will work from a quick once-over. I would verify it gives the expected results before putting it to use. Are there any sections you are particularly concerned about? 



Kevin S.
Technical Support Engineering
National Instruments
0 Kudos
Message 9 of 17

@sspp07 wrote:


Could you please check it and let me know, did I solved correctly or not?


There are some serious race conditions due to blatant overuse of local variables. You are dreading from and writing to the same local variables in parallel, but the result critically depends on the order of operations. You can eliminate all of them! None of your sequence structures are needed. All your controls belong before the loops.


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 10 of 17