Working with Spectral data

Recommended Posts


I am struggling with the sprectral capabilities at the moment. I have a spectra with each wavelength read in as a seperate channel (OPC). I have loaded this into a variable array in a sequence. E.g.

var.FBRM[0] = Measured2000_in[0]

var.FBRM[1] = Measured2001_in[0]

var.FBRM[2] = Measured2002_in[0] etc etc

This allows me to view the spectra with a 2d graph.

What I would like to do is load the individual data into a spectrum and then trend it with a 3-d graph. Can a spectrum be created to do this or are spectrums limited to device channels?



Link to comment
Share on other sites

The problem is you are putting the data in the wrong dimension. The first dimension (rows) of arrays is always with time, so all data with the same time (i.e. a spectra or image) should have the same row. You can't add columns one at a time to a, so you have two choices, create a temporary variable to create the spectra then add the variable to the, or just use a variable for it all. I'd probably do the first. I'd also consider using a regular Test Spectrum channel with Timing = 0 instead and using AddValue() on it. Anyhow, it would look something like this:

private temp

temp[0][0] = Measured2000_in[0]

temp[0][1] = Measured2001_in[0]


temp.time[0] = systime()

v.fbrm = temp

or if using a channel:


BTW: you can do this even easier using a for loop and evaluate if your channels are actually numbered in order:

private temp
for (private x = 0, x < 20, x++)  
   // I'm assuming you have 20 values in your spectra
   temp[0][x] = evaluate("Measured" + doubletostr(2000+x) + "_in[0]")

Finally, you can then use the image component to get an indian blanket style visualization, or use the 3d graph to get a waterfall. If you use a 2D graph, you'll want to graph "myspec[0]" vs "X", or just leave X expression blank. You'll need to change the x axis scaling to Lin and change the scale from scale to. As a side point, you can do some cool stuff with histories of spectra. For example, you could plot the 3rd wavelength by doing myspec[][2] vs Time. You can also use the mean() and other stat functions to get the means of each wavelength, or do meancols() and other xxxCols() functions to get the mean across the spectra. This is a powerful, but unfortunately not often used feature of DAQFactory.

Link to comment
Share on other sites

  • 1 year later...

I'm trying to learn all I can about spectral channel commands and syntax. If I wanted to to put the current value of Value 2 of a spectral channel into say, a variable value component for display, would I address that as:

myspec[][2] ???


Link to comment
Share on other sites

The most current value would be:


assuming you wanted the 3rd value. Doing:

myspec[][2] would give you the entire 3rd column, returning an array with 1 column and a bunch of rows, assuming of course that myspec had a bunch of rows of spectra.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.