Hi,
Either I miss something or I encountered strange behavior of Map module
:-(.
The problem is as follows:
We have scalar function of two variables f = f(x,y);
Let assume that
f(x,y)= x^2 + y^2 and x in [-0.5,1.0], y in [-0.5, 1.5]
Draw the profile of function 'f' along a line parallel to 'y'-axis
passing through specified point [x0, y0].
The function is given by the set of points on regular rectangular grid.
I solved the problem in the following steps:
1) read in the data
2) create line grid passing through [x0, y0] and perpendicular to y
3) Map the read data on the line grid
4) Create 2D plot of data on line
Below I included the script implementing the steps.
It works fine except for cases when the grid line passes exactly
through one of the rectangular grid lines (in other words when
point [x0, y0] is one of the grid points on which function f has
been specified)!!!! This is exactly opposite I would expect.
What's more if I only slightly move my [x0, y0] point it produces
again correct results.
Any ideas what is wrong ?
(I'm running Data Explorer version 4.0.1 on Linux box).
To make it possible to reproduce the behavior I included three short
files:
1) dx script
2) general array importer header file
3) awk script to produce data file
Regards
Roman Putanowicz
[EMAIL PROTECTED]
1)
The correct results are produced for instance for point [0.96 0.5]
The wrong result are produced for point [0.97 0.5]
----------------------- 8<----------8<----------------------------
data = Import ("header.general");
// Create line parallel to 'y' axis
// set point to [0.96 0.5] to see the correct profile
// set point to [0.97 0.5] to see the incorrect profile
line = Grid ([0.97 0.5],"line", [0 1], {30});
data = Map (line, data);
data = Mark (data, "positions");
data = Compute ("$0.y", data);
data = Unmark (data, "positions");
data = Color(data, "medium turquoise");
data = Options (data, "mark", "triangle", "mark every", 3, "label",
"fluid speed");
image = Plot(data, {"y" "fluid speed"});
camera = AutoCamera (image);
image = Render (image, camera);
Display (image);
------------------------ 8<-- cut here and save as 'plotdata' ------
2)
-------------------------8<--------8<------------------------------
file = data.lis
grid = lines 1
format = text
field = locations, fun_value
structure = 2-vector, scalar
layout = 0, 12, 1, 12
interleaving = field
end
------------------------8<-- cut here and save as 'header.general'
3)
------------------------8<--------8<------------------------------
BEGIN {
n = 100
xl = 1.5;
yl = 2.0;
dx = xl/n;
dy = yl/n;
y = -0.5
# create line of comment and line with grid size
printf ("# quadratic function x^2+y^2 in domain x=[-0.5,1.0]
y=[-0.5,2.0]\n")
printf ("%d %d\n", n+1, n+1)
for (i=0; i<n+1; i++) {
x = -0.5
for (j=0; j<n+1; j++) {
printf ("%12.7f%12.7f %12.7f\n", x, y, x*x+y*y)
x = x+dx;
}
y = y+dy;
}
}
------------------------------8<-- cut here and save as makedata.awk
(If you are working on decent Unix/Linux :-)
To produce data file run the following command:
awk -f makedata.awk > data.lis
To run dx script type
dx -script
and then
include "plotdata"