Jump to content

2D contour plots...


PA-Paul

Recommended Posts

Hi All,

We're using labview to control a measurement system which comprises several moving axes, a source and a detector. We have a whole suite of software written now in labview for control and acquisition with the system and (separately) for post processing acquired data. One of the functions of the measurement system is to acquire 2D data "maps" and then process the data and display it to the user. For the type of measurement we're doing a dB contour plot of the data is extremely useful. At the moment, we have manage to achieve this using the 3D plots in labview (8.6). But we want to be able to make cursor measurements on the plots as well, which is where things get tricky - although we can make the 3D plot simulate a flat, 2D contour plot, the cursors within the 3D plot are always in 3D... so it's not at all obvious where on the flat projection of the contour plot the cursor is actually placed.

The ideal solution would be to have a genuine 2D plot with the contour lines on it (as opposed to using the 3D activex graphy thing), but I can't see anywhere within labview how to do this... I can get nice looking intensity plots of the data, but I want contour lines (with user selectable dB interval). Is there any easy (i.e. pre-existing) labview code that will let me do this? I can't imagine that I'm the only one who's interested in doing this with data acquired in labview....

Running inside the labview IDE I can use the MatScript node and the matlab "contour" function, but this app requires building into an exe and running under the labview runtime engine (which apparently you can't do with matscript functions...)

Anyone know any good solutions for doing this? Any suggestions welcome (I'd probably even pay for an add on if one existed... well, maybe...)

Cheers

Paul

Edited by Ic3Knight
Link to comment

Hi All,

We're using labview to control a measurement system which comprises several moving axes, a source and a detector. We have a whole suite of software written now in labview for control and acquisition with the system and (separately) for post processing acquired data. One of the functions of the measurement system is to acquire 2D data "maps" and then process the data and display it to the user. For the type of measurement we're doing a dB contour plot of the data is extremely useful. At the moment, we have manage to achieve this using the 3D plots in labview (8.6). But we want to be able to make cursor measurements on the plots as well, which is where things get tricky - although we can make the 3D plot simulate a flat, 2D contour plot, the cursors within the 3D plot are always in 3D... so it's not at all obvious where on the flat projection of the contour plot the cursor is actually placed.

The ideal solution would be to have a genuine 2D plot with the contour lines on it (as opposed to using the 3D activex graphy thing), but I can't see anywhere within labview how to do this... I can get nice looking intensity plots of the data, but I want contour lines (with user selectable dB interval). Is there any easy (i.e. pre-existing) labview code that will let me do this? I can't imagine that I'm the only one who's interested in doing this with data acquired in labview....

Running inside the labview IDE I can use the MatScript node and the matlab "contour" function, but this app requires building into an exe and running under the labview runtime engine (which apparently you can't do with matscript functions...)

Anyone know any good solutions for doing this? Any suggestions welcome (I'd probably even pay for an add on if one existed... well, maybe...)

Cheers

Paul

You can configure the 3d graph to show you the project onto any of the planes you wish.

Ben

Link to comment

Ben - You're absolutely right, but the cursors always appear in "3D" and "latch on" to the positions the points would be in in 3D if it weren't for the fact that only the projection is showing. Also, it's much harder to customise the 3D graph - I find the axis labels look clunky, and I cant seem to get a decent "tight fit" for the projection on the map... a 2D graph (like the matlab "contour" plot would be the ideal solution for what we're trying to achieve...

Is there any (built in) way to calculate the points of the contour lines and then plot them in an XY graph? i.e. each contour line would be an individual plot within the XY graph? so I feed my 2D data array into a magic function which calculates the path of each desired contour (i.e.-3dB, -6dB etc) and then I plug those into an XY graph...

Any more thoughts gratefully recieved!

Thanks

Paul

Link to comment

I wrote my own, based on this paper: http://www.springerl...750730487puqm0/ - it works but would need some tidying before I shared it!

But a better option is perhaps to directly call the VIs that end up being called by the Mathscript contour function, namely vi.lib\imath\engines\lvmath2\RunTimeEngine\BuiltInFunctions\contour\NIMS_contour.vi (I presume this is legit - at least on the dark side :ph34r:). Not this routine itself, which has a RUN_TIME_ENGINE check, but the routines called from here:

post-3889-058898900 1283464576_thumb.png

This begs a related idea I've had - there are a few very useful routines in the Mathscript library that are not "available" in G. That would include these Contour routines, the Delaunay Triangulation, and some other geometric functions like Convex Hull and Polygon Area. Why shouldn't these have menu entries in the main menus, maybe under Mathematics. The low-level routines are pretty much independent of any Mathscript-related variables. It seems detrimental to LabVIEW overall to restrict these to using Mathscript.

Edited by GregSands
Link to comment

I think this is also important to consider: As I understand it, you can now deploy MathScript code to real-time targets. On the other hand, NI took all the MathScript functionality out of LabVIEW/Developer Suite and put it in the MathScript RT Module. So be wary that if you are developing MathScript scripts in earlier versions of LabVIEW you will need to purchase a toolkit to use them in later versions. Or am I missing something?

Link to comment

I think this is also important to consider: As I understand it, you can now deploy MathScript code to real-time targets. On the other hand, NI took all the MathScript functionality out of LabVIEW/Developer Suite and put it in the MathScript RT Module. So be wary that if you are developing MathScript scripts in earlier versions of LabVIEW you will need to purchase a toolkit to use them in later versions. Or am I missing something?

Yes, I should have also mentioned that you would need the MathScript RT module in order to use this routine. However the contour routines can be called directly rather than through the MathScript node.

Link to comment

Paul,

Would the MathScript contours function (legacy name contourc) meet your needs? It returns the same data that contour uses but without popping up a plot window, so it is supported in the Runtime Engine.

Greg,

You'll be happy to hear that we are working to bring many MathScript algorithms into the LabVIEW palettes. All of the ones you mentioned are currently on our road map. If you have any other requests, please let us know!

And just a general comment about using the MathScript internal VIs on your diagrams. I can't think of any major harm in doing this, besides the risk that the API will change between versions. For example between LabVIEW 8.6 and 2009 all of the built-in function internal VIs were refactored and renamed. If you do ever use these VIs in your application, I'd recommend making a copy of the entire hierarchy to avoid being bitten by changes like this.

JesseA

LabVIEW MathScript R&D

  • Like 2
Link to comment

Jesse -

That's sounds great! Makes a lot of sense to have the core functionality easily available.

The most useful function for me that I didn't mention above would be intrp2d_uneven for 2D interpolation of scattered data. Hope you can also add the use of parallel for loops where applicable.

Link to comment

Greg,

It looks like interp2d_uneven is also planned as part of the effort to bring more MathScript algorithms into LabVIEW. It seems you have a similar wish list to our internal developers!

Adding more parallelism to the analysis functions is an area of active research. Automatically parallelizing MathScript for loops is also tantalizing, but we'd have to figure out a way to make it configurable in case the parallel loop doesn't perform as well as the serial one.

Thanks for your feedback!

JesseA

LabVIEW MathScript R&D

Link to comment

JesseA,

Thanks for the response, that does sound like it may be useful (the contours thing - and having this functionality direct in palettes!).

One quick question, just to be sure, I just need to create my own subvi with a mathscript node in it with the necessary mathscript functions and then when I build an exe,it'll all work by magic? Do I need to include any additional installers for distributing the code if I've used mathscript nodes?

Thanks again for your help.

Paul

Link to comment

Hi Paul,

You are correct that it should just work when you built a MathScript node into an application. The MathScript node just calls some subVIs in vi.lib and they are pulled in to the application the same way any other subVIs are.

If the MathScript Node does not appear on the structures palette and the MathScript Window entry doesn't appear under the "Tools" menu, it usually means that you don't have the correct license for MathScript. Try opening up NI License Manager and checking your licenses for LabVIEW 8.6.1. You need to have one of the licenses with "MathScript" in its name.

Jesse

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.