visualdatatools.com Forum Index visualdatatools.com
Discussion for DataTank and DataGraph
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Starting with 2D structured meshes

 
Post new topic   Reply to topic    visualdatatools.com Forum Index -> Getting Started
View previous topic :: View next topic  
Author Message
CharlieH



Joined: 12 Feb 2011
Posts: 3

PostPosted: Sat Feb 12, 2011 6:02 pm    Post subject: Starting with 2D structured meshes Reply with quote

I am very new to this. I have a file with three columns, X, Y, Var (although not in that order). I would like to create a plot of the Var values interpolated onto an Isoplane and display that as a function of the X and Y values. I can generate a 3D type plot with and the individual values, but I would like to make this a smoother surface where one color is the "high value" and another is the low value and all the data points fall in between.
Now after reading the manual, i think my problem is that my X and Y variables are not uniformly spaced. So I think my mission is to first map this onto a grid, and then create a 2D structured mesh which uses that grid and the Var column, but while I do not get any red error circles, I also do not get a plot. I am trying to map each column of my data into separate variable names to make sure that is really working. Am I on the right path here?
Back to top
View user's profile Send private message
David
Site Admin


Joined: 25 Nov 2006
Posts: 1961
Location: Chapel Hill, NC

PostPosted: Sat Feb 12, 2011 8:11 pm    Post subject: Reply with quote

If what you want is to create an "envelope" for the x,y,value point cloud, one idea is to create your own External program that computes it.

How is your C++ ?

If the answer is decent or better, do the following steps.

Assume PV is the point values, set up as a "2D Point Value Collection" variable. That is the most natural variable type and encapsulates the data. You can easily create that from a 3xN array using the context menu.

Create two external programs, one for the "upper" and one for the "lower". There is also a way to create both at the same time using a Group variable, but let's start simple.

To prepare the input, create a "2D Mesh Grid" to lay out a grid. There are a few modules that make the most sense, "Specify" and "Specify Inside Box". Draw the grid on top of the point cloud to make sure that it covers what you want.

To create the external program, do the following, and here I'm going to assume pv = point values, grid = Grid
Create a "2D Mesh" variable, and select "External Program"
Drag pv, grid onto this. This adds it as input
Go into the support menu and create the XCode project (bottom entry, inside the attachments folder). This creates an XCode project inside the DataTank script.
Create the code (see below)
Compile
Select the executable in the Support menu

Now when you change the input, the executable is triggered and you get the output.

I wrote a very simple code and added it to the sample scripts:
http://www.visualdatatools.com/SampleScripts/SimpleEnvelope.zip
You need to go into Support->Open Project and compile the program. Then just add points. You can click on the image in "2D Mesh Grid" to add points and tweak them. The "2D Point Collection::Interactive" will record the clicks and the external program is automatically triggered when the data changes.

Note that both "upper" and "lower" use the same external program so you don't have to compile both. They use a different input, since the type flag is different (0 or 1).


Hopefully this gets you started. The XCode mechanism and the DTSource code library are a very good way to add functionality to DataTank.

David
Back to top
View user's profile Send private message Send e-mail
David
Site Admin


Joined: 25 Nov 2006
Posts: 1961
Location: Chapel Hill, NC

PostPosted: Sat Feb 12, 2011 8:14 pm    Post subject: Reply with quote

And make sure that you click on the "Reset" button after you have compiled the code or changed the external program (and recompiled). This is because DataTank caches results quite aggressively, so if you change the external program you need either change the input or tell DT that it needs to recompute everything.

David
Back to top
View user's profile Send private message Send e-mail
CharlieH



Joined: 12 Feb 2011
Posts: 3

PostPosted: Sat Feb 12, 2011 9:03 pm    Post subject: 2D structured mesh issues Reply with quote

Actually, I think this is overkill for what I am trying to do. I think you have a system that produces a binary action (either high or low), what I want is a continuous change ( I am sure that was not very clear before). I have been working the system for awhile now and I am still not getting any plots when I think I should be. That makes me think that not everything is being defined. Is there a way to check what the missing values are for a plot? Also, I am finding myself really not thinking along the right lines. I think I could use a reference to some of the ideas in how the "tasks" are defined. Is there a good reference for this material? For example it would be great to see some examples of the differences between 2D structured grids and 2D grids. I think I understand it, but when I do not get a plot, I am confused
Back to top
View user's profile Send private message
CharlieH



Joined: 12 Feb 2011
Posts: 3

PostPosted: Sun Feb 13, 2011 10:51 am    Post subject: Follow-on Reply with quote

I have looked at the script, but I think I am missing a key point in my understanding. what I have is a three step process. I realize that the data can probably handled different ways, but in this manner I could make sure everything was where I wanted it
Step 1: Reading in the data- I read in the data from a file into a three column array an then I split out in sub steps using the same commands 3 individual arrays (X, Y, Var). these al have the same length
Step 2: I created a structures grid -> from Array or lists where the "X array" was my X, and the "Y array" was my Y value.
Step 3: I created a 2D structured Mesh -> From array and grid, where the array was my Var value and the grid was from step 2

Then I would do a 2D plot and nothing would come up. I think that is because something is not being defined, I am wodering if there is a step that needs to take each Var valu and assign t to a point on the new structured grid? I was thinking the i'th value in Var array would correspond to the i'th value in the x and the i'th value in the y, but I suspect there is more to it.
Back to top
View user's profile Send private message
David
Site Admin


Joined: 25 Nov 2006
Posts: 1961
Location: Chapel Hill, NC

PostPosted: Sun Feb 13, 2011 2:18 pm    Post subject: Reply with quote

There are three types of 2D grids.

2D Mesh = uniform discretization. Origin + step size or Origin+(dx,dy).
2D Structured Mesh = Logically rectangular grid. Sometimes referred to as body fitted. Similar to 2D Mesh except the vertexes don't have to be uniformly spaced or even along straight lines.
2D Triangular Mesh = Sometimes called unstructured. The most flexibility and maybe what you want in this case. If you only have a point cloud, you can triangulate it (context menu for either a 2D point collection or 2D Point value collection). Now you can draw the values as a mesh and the drawing routine will interpolate between the values.

I e-mailed you a sample based on your data set.

You can also use 2DMesh->Weighted Point Values. See the help document for that module (small ? button in the lower right corner) for more info.

David
Back to top
View user's profile Send private message Send e-mail
Adam



Joined: 01 Dec 2006
Posts: 61
Location: Sequim, WA

PostPosted: Mon Feb 14, 2011 2:06 pm    Post subject: Reply with quote

I'd guess that the "logically rectangular grid" requirement of the 2D Structured Mesh is the problem here. For scattered 2D data, I've tried both approaches that David suggests here. It's important to note that if your data has holes, Weighted Point Values (which can be converted to a 2D Triangular mesh) may handle them in a more straightforward manner. I run into this frequently with e.g., bathymetric datasets, whereas Triangulate on 2D Point Values can require you to mess around with the Remove Bad Triangles module.

Shameless plug: I recently added 2D Structured Mesh/Grid support to my Python code, so that may be easier than C++ for some people. 2D Point Value Collections are also supported (support meaning you can easily write them to a .dtbin file): http://code.google.com/p/mactlmgr/source/browse/#svn%2Fdatatank_py
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    visualdatatools.com Forum Index -> Getting Started All times are GMT - 3 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group