LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Filtering and Editing contents of a 2D array

Solved!
Go to solution

Hello I'm using Labview 2020 to collect data from an STS Ocean Insight Spectrometer and I could use some help applying some filters to the result spectra. The spectrometer outputs two arrays, one for the wavelengths detected and one for the intensity of those wavelengths, these I can then bundle and display on an XY Graph.

 

There are two things I would like to be able to do:

  • Set a minimum intensity threshold for detected wavelengths, if the intensity is below that threshold it will be set to 0, otherwise it will be displayed as is.
  • Have the option to only show a specific range of wavelengths. Eg. 300nm < X < 500nm would be displayed while all others would be set to 0.

I know how to write these parameters in C++ but I don't know how I would apply it to Labview. In C++ it would look something like this:

 

int i;
int min_wave, max_wave, min_int; //Wavelength Ranges and Intensity Threshold

double i_int[1025]; //Array with initial intensity values
double f_int[1025]; //Array with final intensity values
double wavelengths[1025]; //Array with detected wavelengths

int main
{
	for (i = 0; i < 1025; i++) //Loop through wavelength and intensity arrays, these have a max size of 1025 elements
	{
		if (i_int[i] < min_int || wavelengths[i] < min_wave || wavelengths[i] > max_wave) //If intensity is less than min. intensity or wavelength is outside the range of wavelengths chosen, intensity is set to 0
		{
			f_int[i] = 0;
		}

		else //Keep intesnity value if it passes both filters
		{
			f_int[i] = i_int[i];
		}

	}
}

 

I would like to put it into the formula node in the vi I attached but I'm not familiar enough with the syntax for it. Also if it's easier to do without a formula node I'd welcome any suggestion with regards to that too. 

Download All
0 Kudos
Message 1 of 4
(1,681 Views)
Solution
Accepted by topic author Ackalap

This is all you need:

 

FireFist-Redhawk_0-1595354700845.png

In general, it's better practice to simply not graph points you don't want to see, rather than set their y value to 0. So that's how I coded it, take the full set of data and filter out any data that is 1) outside the wavelength limits, and 2) beneath the minimum intensity threshold.

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

Message 2 of 4
(1,657 Views)

Hi,

 


@FireFist-Redhawk wrote:

In general, it's better practice to simply not graph points you don't want to see, rather than set their y value to 0.


Replace those "don't want to see" points by NaN (instead of zero)!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 4
(1,602 Views)

Hi thanks for the reply, I understand your what you're saying about not plotting the points I want ignored and normally thats what I would do. But since this is a graph of a spectrum of light I would prefer to zero the unwanted signals as opposed to not plotting them, both from a practical sense as well as an aesthetic one. I won't lie, I find the zeroed out graph much nicer to look at than the one with most of the points missing.

 

OriginalOriginalPoints not PlottedPoints not PlottedReplaced with 0Replaced with 0

0 Kudos
Message 4 of 4
(1,587 Views)