LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Txt to XL to 2D array

HI

 

How can I convert the attach txt file to XL to 2D array. This is laser beam profile data from a CCD camera. Array size 640x480.

 

I want to read the third colum (value) only and conver into 2D array to display beam profile

 

Thanks

0 Kudos
Message 1 of 15
(3,928 Views)
First, it appears that the file is delimited, either tab or whatever (I opened it in Excel, although it apparently is too big to load all of at 10 Mb in size). Since it is delimited the "Read from Spreadsheet file.vi" should be able to read the data in as a 2D array, then you can split off the 3rd columns data. I'm not sure how you will then configure the resulting 1D array into a 2D, not sure what criteria you want to use, other than possibly taking every 640 elements and making them the next row of your new array, which can be done in a FOR loop.
Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 2 of 15
(3,919 Views)

Try this!

 

Regards

Visuman

0 Kudos
Message 3 of 15
(3,910 Views)

Hi,

 

I have created this VI to read the data out the file a line at a time and poke the amplitude data into an array. The data is then plotted on an intensity graph.

 

 

Some of the data looks right, some of it doesn't but I will let you be the judge of that.

 

Does this help?

 

cheers

 

David

Message Edited by David Crawford on 10-30-2009 09:01 AM
Message Edited by David Crawford on 10-30-2009 09:02 AM
Message 4 of 15
(3,896 Views)
0 Kudos
Message 5 of 15
(3,891 Views)

Regarding the solutions:

visuman solution

visuman, you posted your solution already, so you don't need to post it again. As far as the solution itself is concerned all of those array manipulations can be replaced with a single Array Subset. The one problem I see with this solution is that it's a heavy memory impact solution since it reads the whole file into memory. Tip: You can wire the file path directly to the Read From Text File function, allowing you to eliminate the Open File and Close File functions. Those operations will be automatically performed when wiring a path to the Read From Text File function.

 

David's solution

I like the top-half of this solution, but not the bottom-half. The top half employs the pre-allocate the memory and then just replace array elements technique. The bottom-half has the fundamental problem of performing an I/O operation for each line. For the file provided that's 307,203 file I/O reads. This will take forever. Literally. In this case I prefer the high memory impact solution. A better solution is to read the file in large chunks and process the chunks.

 

I think we need to step back and address the original question. Why does the poster want to convert it to Excel? Is it because the poster believes the Read From Spreadsheet File works with Excel workbooks? This is not correct, but an understandable assumption, given the lousy name of the function. Is the user trying to work with this data in Excel and manipulate the workbook in LabVIEW as a bigger project? 

 

I think we need to get some more answers here.

Message 6 of 15
(3,868 Views)

Hello

David , visuman, thanks alot for the VI's

 

David's vi's works fine but I need to transpose the intensity array to display intensity profile correctly.

 

 

This data is a laser intensity profile from a CCD camera....

 

This camera doesn't have any option to see the 2D profile in a particular line or 3D intensity display.

 

 

 

Can anyone help to plot this intensity profile into a 3D plot

 

the array size is 640X480

and the size of each pixel in 8.3 micron in both direction.

 

 

thanks again

 

 

 

 

0 Kudos
Message 7 of 15
(3,859 Views)

Hi,

 

I work for a laser company myself and have done something simliar to what you are trying. I have added in some more functionality to the first VI I posted. I wanted to show you the steps that I have gone through to get it into a 3D graph and get the line profile at the peak. I might be mixing my columns and rows up but I am sure you can debug all that.

 

All that its left is for you to go away and work out your FWHM, 1/e or 1/e^2 spot size converting pixels to microns.

 

 

@smercurio_fc (Saverio, right?): I was concerned that the multiple space delimiter (8 space representation of a tab is my guess) wasn't constant because of field padding. So thats while I choose the read a line at time method. This was instead of reading in a 10meg file and manipulating it in a loop or using the spreadsheet to array functionality. At the same time I thought I would demonstrate to Kamalm2 that you can use file functions to get your data from the file while keeping the memory consumption down. Of course, you are absolutely right, it is slower. Visumans clocked in a ~3secs and my version was ~7 secs. To me thats not a big deal. I would not have posted the VI if the OP had to run my file and go a away and make a wee cup of tea and come back to it while it was loading.

 

Right, its Saturday afternoon and I am off to play Sins of a Solar Empire which I highly recommend.

 

Hope this helps you out

 

cheers

 

David

Message Edited by David Crawford on 10-31-2009 12:56 PM
Message 8 of 15
(3,831 Views)

David Crawford wrote:

 

Visumans clocked in a ~3secs and my version was ~7 secs. To me thats not a big deal. I would not have posted the VI if the OP had to run my file and go a away and make a wee cup of tea and come back to it while it was loading.


When I tried it on my computer it was still going after one minute, and wasn't anywhere close to getting nearly done. While I do not have an old TI-99 computer, I also don't have a Cray supercomputer sitting on my desk. This has to be taken into account when designing a VI. And creating a VI that performs over 300,000 file I/O accesses is simply silly.

Message 9 of 15
(3,827 Views)

Hi David

 

Thank you very much for your time. Its really great, at this stage it works fine.

 

I want to do more modification, I want to connect this program with a CCD beam profiler.

 

I have  Mellers Griot SpotOn CCD USB2 beam profiler

 

They have a LabVIEW interface (see the attach VI) but its call only their interface (see the SpotOn CCD.png)  and give the cetroid. It doesn't give any intensity profile in LabVIEW interface. SpotOn CCD manual also attach

 

I want to operate the CCD with LabVIEW interface and intensity profile on LabVIEW interface.

 

 

Please help me

 

 

thanks

 

 

 

 

 

 

 

0 Kudos
Message 10 of 15
(3,804 Views)