LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Data Sort

Hello,

 

In the attached VI, dynamic plot3, I am attempting to sort the data from the attached txt file and then plot the data corresponding to the selection in the cluster.  I was given a great starting point from you guys before but now I need to add one more dimension of data sorting.

 

Currently the program works for the selection of Temp, LO Freq and Headings.  I am trying to add another dimension the Desc.  Can you point me in the direction to add this extra sort dimension?

 

Thanks,

hiNi.

Download All
0 Kudos
Message 1 of 22
(4,126 Views)

Where is the sorting?

 

In "Get Desc. Info" you seem to be removing duplicates in an extremely convoluted way. What is the purpose of the outer for loop? Nothing changes if you remove it.... same for the next few states.

 

What's happening in the Plot graph state? Seems to be hammering the CPU as fast as the computer allows, recalculating and graphing the same thing over and over, millions of times per second.

 

We probably need more info....

0 Kudos
Message 2 of 22
(4,097 Views)

Hello,

In the program's current state, the 'Desc' selections have no effect on the plot graph block.  That is what I am trying to fix.  I have just been able to sort the data.

 

If you select different LO Freqs, you will get plots based on your selections.  You can select any amounts of LO Freqs from the cluster, and they will be plotted.  I wanted to have the same effect also if I select any "Desc" selections.  So for example, if I select 'RM' from Temp, 'Original' and 'Tune1' from Desc, '168' and '484' from LO Freq and 'Deviation Hz' from Headings, I should end up with 4 plots...LO Freq 168 showing 'Original' and 'Tune1' plots, then LO Freq 484 showing 'Original' and 'Tune1' with Deviation Hz on the y-axis vs freq on the x-axis.

 

If you need further clarification, please let me know.

 

Thanks,

hiNi

0 Kudos
Message 3 of 22
(3,993 Views)

@hiNI wrote:

If you need further clarification, please let me know.


As I said, the for loops just repeat the same operation N times without changing the result. Simply a waste of CPU and time! If you are lucky, the compiler recognizes it as loop invariant code and will optimize the loop away behind the scenes, but why not program it correctly? Less diagram clutter!

 

I still don't know what you mean by "sorting".

 

You still have way too many dimensions due to incorrect coding. The 3D array should be 2D and the 4D array should be 3D.

As I said, your inner graphing while loop spins as fast as the CPU allows, heating up your room and possibly draining your labtop battery and making your AC work overtime. A small wait would be unnoticeable to the operator but would reduce the CPU use to negigible levels.

 

Somehow I still think your code is way too convoluted and much simpler code is possible once we now what it actually needs to do.

0 Kudos
Message 4 of 22
(3,943 Views)

There is one and only one built-in SORT function, which will sort a 1-D array of ANYTHING.

 

So, use that.

 

What I do is build things into clusters - the most important key item 0th (in cluster order), the 2nd most important key item 1st (in cluster order), and so on.

 

Then sort the array of clusters.

 

For example: if you sold 42 widgets in January, 29 in February, and 63 in March, and you want to sort by sales, then combine your data into clusters like this:

 

[ {42, January}, {29, February}, {63, March} ]     (sales number bundled FIRST )

 

Then sort the array, and it turns into:

[{29, February}, {42, January}, {63, March} ]     (sales number in ascending order )

 

 

It always sorts on the first item (in cluster order) first, and the second item second...

 

If you also sold 29 in April, it will always put {29, April} before {29,February}, because "A" comes before "F".

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 5 of 22
(3,934 Views)

In addition to what was said (which is all good information) you may want to check out the OpenG array functions.  They have lots of array tools for things like sorting and reordering based on pointers, removing duplicates from arrays, and filtering items out of an array.

0 Kudos
Message 6 of 22
(3,908 Views)

OK, let me see if this will hopefully clarify my objective:

At Room temperature (Temp: RM), and Test Condition (Original), I collect data from my instrument and sweep the LO Freqs over different Audio Freq points (data for which the deviation reading is plotted against).  Hence, if you view the text file, you will see the first block of data has Desc, Temp, LO Freq, pVCO Freq, pVCO the same.  As I sweep the Audio Freq, I measure the corresponding deviation reading from my instrument.  Hence, the Audio Freq, Audio Freq Meas and Deviation are varying.  All plots are plotted against the Audio Freq (the 7th column in the data file)

I then test another LO Freq at the same Test Condition (Original) Temp (RM), and sweep the Audio Freq and measure the resulting Audio Freq and deviation from the equipment.  Hence the second block of data has a different LO Freq, but varying Audio Freq and Deviation.  I repeat these conditions for all the different 8 LO Freqs (the # of LO Freqs can change but that is left for a later modification).

After the 8 LO Freqs are completed, I then switch the test condition to “Tune1” and repeat the process above.

After all the data is collected, I am attempting to sort the data for:

  1. Different Temps (RM)
  2. LO Freq (168.036, 463,…,460.899)
  3. Test Condition (Original, Tune1, TUNE2)
  4. Deviation (Deviation Hz, Deviation dB)

I wanted to compare the data in the graph as follows:

If I select:

  1. Any Temp selection (in this case there is currently only “RM” temp data so that has to be selected)
  2. Desc (currently does not work)
  3. Any of the LO Freq (for this example I will use the 168.036 LO Freq)
  4. Deviation Hz

I should end up with a plot that looks like:

168.PNG

 

If I now select all LO Freqs, I should end up with a plot that looks like:

 

all.PNG

I put the for loop in there because I wanted to dynamically change the different selections and compare the data.  For example, after viewing all LO Freqs, then just view (for example) 1 LO Freq (say select 168.036), 3 test conditions (select Original, Tune1 and TUNE2), and Deviation Hz.

 

Does this explanation help any?

 

Thanks,

hiNi.

0 Kudos
Message 7 of 22
(3,900 Views)

So... I don't understand what your trouble is.

 

If you arrange keys in a cluster, in whatever cluster order you want to sort on, then the SORT 1D ARRAY function will do the work for you.

 

Suppose you have 48 data sets.  4 different RM, 4 different LO Frequencies, 3 different TEST CONDITIONS (TC)

 

For one case, Build a cluster with {RM , LO, TC, DataSet # } for each data set.

Sort that array.  That gives you the DataSet numbers arranged by RM (and then by LO in case of identical RMs...)

 

For another case, Build a cluster with {LO, RM, TC, DataSet #} for each data set.

Sort that array.  That gives you the DataSet numbers arranged by LO (and then by RM in case of identical LOs...)

 

For another case, Build a cluster with {TC, RM, LO, DataSet #} for each data set.

Sort that array.  That gives you the DataSet numbers arranged by TC (and then by RM in case of identical TCs...)

 

 

Choose one of the sorted arrays (by RM, or by LO, or by TC).

For each element in that sorted array, pull out the DataSet #, and use the corresponding Data Set.

 

 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 8 of 22
(3,861 Views)

 Hello Steve,

 

I like your idea, but not sure how to execute your suggestion.  I humble request a start showing the code for your elegant solution.

 

Sincerely,

hiNi

0 Kudos
Message 9 of 22
(3,811 Views)

Well, since you asked so humbly.... 😉

 

Here it is in LV2013 format.

 

The first part just generates some data.

 

Then you can change the SORT BY selector and it shows the data sorted by what you want.

 

 

The Sequence Nazis may be here soon, telling you how what I did is evil.

 

It's not.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 10 of 22
(3,783 Views)