From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

spectrum analysis

Hi,
My problem is that I am taking in a spectrum ranging from the UV to the optical parts, I need to be able to be able to choose a small part, a window of 10 to 20 nm, and get a polynomial fit and differential display for the signal in that window. I have it running that it takes in the spectrum and saves after each exposure time to an excel file. Would someone be able to help me.
0 Kudos
Message 1 of 3
(2,547 Views)
Salutations,

You'll have to excuse me, it's national bring your child to work day and I wasn't able to procreate before this instant in time, so I'm a bit slow today with all the child chaos that's taking place.

So, you want to import the data from an excel file, search through it and find a window of 10 to 20 nanometers, and then polynomial fit this, then apply a differential to it?

If that's what you so desire, you can do that without a problem. Importing an .xls file is sort of a pain (As far as i know) so i always save them as .csv files. This will eliminate multiple page files in excel, and some formating may be lost. However, it will now be a comma seperated file.

However, now we can open it in labview, go to "File I/o" --> "Read from spreadsheet file.vi" Select the file location and set a constant for the deliminator to be a "," that way it'll handle our comma seperated file. Assuming these are all numbers, if they're not, you'll have to do some other tweaking (ie, if you're trying to import dates etc... it will be a bit trickier).

Now that we've got our array, you could bin the data for the 10-20 nm range, by incrimenting through a for loop and checking those upper and lower bands... use a case structure and an "and" boolean and bin the data if they're both true, or disregard it. Now this isn't the fastest technique (depending if you data is already arranged etc...), however it will work.

Now, to polynomial fit the data do "Analyze" --> "Mathematics" --> "Curve Fitting" then choose the one you desire.
To Differentiate that you may need to rebuild the data set, depending on how you chose to curve fit, but the differntial operator is located at
"Analyze" --> "Mathematics" --> "Calculus" -->"Differential.vi".... Note: Differentiating increases the amount of noise in a signal.

Note: The curve fitting and the differential tool may not be in the base package. If they aren't, well, there are numerical techniques for both. You could write your own Vi's. Maybe not as fancy as labview's, but you'll survive i'm sure.

Hopefully this provides you solid footing for advancing.

Sincerely,
ElSmitho
Message 2 of 3
(2,545 Views)
There are some functions in LabVIEW which make your job a lot easier, but their availability depends on the version (6i, 6.1, 7) and level (base, full, pro) that you have.
  • When you say Excel file do you mean a tab-or-comma-separated-text file or a true Excel file? If the former, use the the methods mentioned earlier. Tab-separated is easier to deal with since it is the default of both Excel text export an LabVIEW spreadsheet import. If it is a true Excel file, you can either export it to text then read it or use ActiveX controls to read it directly. NI sells a report generation toolkit with this function (and a lot of others).

  • Once you have your data imported, make sure it is in two arrays, one for X and one for Y. Most of the analysis routines use this. You can use the Array Subset primitive from the array palette to get the subset you need. You will need to calculate the array indices, but this should be fairly simple if you have standard spectroscopic data with evenly spaced points.

  • To do nonlinear fitting, you need to full or pro versions of LabVIEW. As a first try, use the Levenberg Marquardt.vi. This is the standard least-squares, nonlinear fit routine. You will have to supply it with a model. If you are unfamiliar with fitting techniques, I would strongly recommend you find a copy of Numerical Recipes in C by Press, et. al. It is available in most libraries. LabVIEW includes optimized versions of most routines in the book, but LabVIEW does not give you much guidance on how to use them. Numerical Recipes does. WARNING - if you are trying to fit more than a couple of peaks to the curve, you could have severe stability problems (i.e. you get the wrong answer). The more coefficients you use, the harder it gets to fit. Numerical Recipes will point you in the right direction for solving this problem. Repost with specific problems if they do occur. Data and code samples help us help you.

  • To get the residual, subtract the best fit output of the curve fitting routine from your data. You can do this with array wires directly without using a FOR loop.
Good luck and let us know if you run into problems.
0 Kudos
Message 3 of 3
(2,519 Views)