Contour plotting on a non-rectangular grid

Contour plotting on a non-rectangular grid

I'm trying to generate contour plots of Mach number and pressure
distribution around an airfoil.  The problem is that the grid at which
the points are defined is not rectangular.  In other words, I've got
an output file of the form:

X(1,1) Y(1,1) M(1,1)
X(1,2) Y(1,2) M(1,2)
...
X(i,j) Y(i,j) M(i,j)
...
X(imax,jmax) Y(imax,jmax) M(imax,jmax)

Does anyone know of either A) a PC based program that will do this (at
this point, it doesn't matter if it's PD, shareware, or commercial), or
B) an algorithm that will do this and can be implemented in Fortran 77
with GKS?

Any and all help is greatly appreciated.  Please respond via email
and I will post a summary if there's enough interest.  Thanks.

--Troy
+--------------------+----------------------------------------------+
| Troy A. Baer       | "Too much love will kill you,                |

|  ohio-state.edu    |  It'll drain the power that's in you,        |

|   cwru.edu         |  And the pain will drive you crazy,          |
+--------------------+  You're the victim of your crime."           |
| What opinions?     |  -- Brian May, "Too Much Love Will Kill You" |
+--------------------+-----------------------------------+----------+
| Engineer's maxim:  When in doubt, get a bigger hammer. | For rent |
+--------------------------------------------------------+----------+

Contour plotting on a non-rectangular grid

In article <1993Apr12.221942.6...@magnus.acs.ohio-state.edu>, tab...@magnus.acs.ohio-state.edu (Troy A Baer) writes:
Hi Troy,
|> I'm trying to generate contour plots of Mach number and pressure
|> distribution around an airfoil.  The problem is that the grid at which
|> the points are defined is not rectangular.
|>
|> Does anyone know of either A) a PC based program that will do this (at
|> this point, it doesn't matter if it's PD, shareware, or commercial), or
|> B) an algorithm that will do this and can be implemented in Fortran 77
|> with GKS?
I had a similar problem last year. At the time, I was asked, but "forgot" :{
to post any useful references. Most were in fact posted to the newsgroup,
but here goes (LONG).
--------------------------------------------------------------------------
For general reference, I am aware of
Burrough P.A. "Principles of Geographical Information Systems
for Land Resources Assessment", Clarendon Press,Oxford(1986)
Clarke K.C. "Analytical and Computer Cartography",
Prentice-Hall (1990).

Len.Ma...@mel.dit.csiro.au               | Manager, User Support        |
CSIRO Division of Information Technology | CSIRO Supercomputing Facility|
723 Swanston Street, Carlton             | Tel: +61 3 282 2622          |
VIC 3053, Australia                      | Fax: +61 3 282 2600          |

Here are some better references to "how to do it" from the replies
---------------------------------------------------------------------------
From: Markku_Peltoni...@hut.fi
Subject: Gridding algorithms - expreriences

Here is some information about gridding algorithms. Background for this is
a M.Sc. thesis made here in 1985 by Tuire Valli. She is currently working
at the Geological Survey of Finland, Espoo, Finland. Her results are
shortly and partly summarised as follows.

1. Kriging methods are theoretically superior, but working with real
aeromagnetic data gave disappointing results: the method is extremely
laborous and slow for big amounts of data and requires two phases: first,
estimation of the semivariogram from the input data, and second, estimation
of the grid values. If the input data has regional trends, the
semivariogram must be computed separately for each sub-area, which alone
makes the idea impractical. The sw code used was from Uniras company
(Denmark) and, to put it mildly, had some plenty of bugs (e.g. the trend
option didn't work at all).

2. If you have possibility to include gradient information of the data into
the interpolation algorithm, then the outcome will be much improved. This
is the case for our aeromagnetic data and hence, an interpolation method
which utilizes both the field and the derivative values (F, dF/dx and dF/dy
for every obsevation point) gave the best results for our real-life data.
The method is advantageous as the trends are automatically taken into
account through the derivative information. As far as I know, the method
has not yet been properly documented in English; the best source would be
the thesis. The method has been under development at the Geol Survey of
Finland since mid-70's, first by Mr. Juha Korhonen, geophysicist at the
GSF.

3. By far the best results for synthetic test data were reached using the
smoothing spline -technique, developed at the Univ of Wisconsin-Madison,
Dept of Statistics since mid-70's. The idea is to take care of the errors
of your original data by allowing a user-selectable amount of smoothing to
be done before the application of the splines. The method works fine, but
the software would need upgrading and further testing for our own needs.
That was the reason to use synthetic and not the real data for testing. It
was Tuire's (and my as well) idea to continue work on this after her
graduation, but not much has been been accomplished since.

The run times for 10,000 points of input data were:
Kriging 30 minutes CPU-time on VAX-785;
smoothing spline about 3 minutes on VAX-8600.

References (only to get you started if you find these relevant)

Clarc,I., 1979: Practical Geostatistics. Applied Sci Publ Ltd, England.

Haas & Viallix, 1976: Krigeage applied to geophysics. Geophysical
Prospecting Vol 24 pp 49-69.

Journel & Huijbregts, 1978:  Mining Geostatistics. Academic Press, London.

Reinsch, C.H., 1967: Smoothing by spline functions. Numerische Mathematik
Vol 10 pp 177-183

Reinsch, C.H., 1970: Smoothing by spline functions II. Numerische
Mathematik Vol 16 pp 451-454.

Valli, T., 1985: Estimation of magnetic field between flight lines. M.Sc.
thesis, Helsinki Univ of Technology, Lab of Engineering Geology and
Geophysics, Espoo, Finland. 76 p + app (in Finnish).

Wabha, G., 1979: How to smooth curves and surfaces with splines and
cross-validation. Tech Rep No 555, Univ of Wisconsin-Madison, Dept of
Statistics.

Wendelberger, J.G., 1981: The computation of Laplacian Smoothing Splines
with Examples. Tech Rep No 648, Univ of Wisconsin-Madison, Dept of
Statistics.

Good Luck!
Markku Peltoniemi
Helsinki Univ of Technology

--------------------------------------------------------------------------
From: ch...@mqatmos.cic.mq.edu.au (Chris Skelly)
Subject: gridding

offhand I can recommend two good reference books, none specific
to your problem although they might touch on them somewhat,

Ripley, Brian 1981, Spatial Statistics (or something very close
to this)
Cressie, Noel, 1991, Statistics for spatial data analysis
(again I'm not positive about the title, but I know its
Wiley and Sons)

---------------------------------------------------------------------------
From: w...@ux6.lbl.gov (Wes Bethel)
Subject: Gridding

>Help! Does anyone know of a good gridding program on the network (ie.
>anonamous ftp'able). Or is there a gridder burried in Khoros somewhere?

I have written several gridding modules for AVS.  These are available
via anon ftp from avs.ncsc.org.  The module names are "bivar", "trivar",
"scat 2d" and "scat 3d".    The four modules may be classified as
performing either 2 or 3 variable gridding (surfaces or volumes), and as
distance-based or function-based.  Each has its strengths and weaknesses.
These modules have been used a lot here to do exactly the type of work
you indicate you need to do.
You are certainly welcome to ftp these and hack them into Khoros.

Another option is to poke around at netlib (net...@ornl.gov).  The
function-based numerical code that I use was obtained from netlib and
ported into AVS.  You may find other stuff there that you like.

A final option is to wait for yet another user-supplied toolbox which will
accompany Khoros 2 and the geometry functionality.
The algorithms which will be available in K2 will do the
numerical-based gridding for two- and three-variable
functions as well as weighted-averages of nearby points,
also for two- and three-variable datasets.

---------------------------------------------------------------------------
From: ow...@attmail.com
Subject: Gridding algorithms

It would be interested for you to contact Oleg Musin in Moscow, Russia.
His group developed software, including a few approaches, for
calculating on regular x,y grid z-values. They told me that this is
most powerfull package for this kind of tasks. You can contact them
internet!relcom.kiae.su!uucp!ecosoft.npimsu.msk.su!musin and fax
(095) 939-4407.
Michail Bogdanov
Oklahoma City, USA attmail.com!owusa

---------------------------------------------------------------------------

In article <1992Jun24.005928.23...@uniwa.uwa.edu.au>, wat...@maths.uwa.oz.au (David Watson) writes:

|> Briggs, I.C., 1974, Machine contouring using minimum curvature:
|> Geophysics, v.39, no.1, p. 39-48.
|>
|> The methods described in this paper and over 500 other contouring
|> articles are discussed in "CONTOURING: A guide to the analysis and
|> display of spatial data", by David F Watson.(Pergamon Press 1992).
|> It surveys, and categorizes, all (I think) published methods of
|> interpolation and surface fitting, and includes code for 18
|> interpolation methods.
----------------- cut line --------------------------
\font\sevenrm=cmr7
\font\sevenit=cmti7
% \nopagenumbers
\vskip 1.5pc
\centerline{\bf SELECTED REFERENCES TO CONTOURING LITERATURE}
\vskip 6pt
{\sevenrm
\baselineskip=9pt
\noindent
\hangindent=2pc
\hangafter=1
\frenchspacing
Akima, H., 1978, A method of bivariate interpolation and smooth surface fitting for irregularly distributed data points, ACM Trans.\ Math.\ Software, 4(2), \hbox{148--159.}

\noindent
\hangindent=2pc
\hangafter=1
Bourke, P.D., 1987, A contouring subroutine, Byte, 12, \hbox{143--150.}

\noindent
\hangindent=2pc
\hangafter=1
Cayley, A., 1859, On contour and slope lines, Philosophical Magazine, 18, \hbox{264--268.}

\noindent
\hangindent=2pc
\hangafter=1
Foley, T.A., 1984, Three-stage interpolation to scattered data, Rocky Mountain J.\ Math., 14(1),
\hbox{141--149.}

\noindent
\hangindent=2pc
\hangafter=1
Panofsky, H.A., 1949, Objective weather-map analysis, J.\ Meteorology, 6, \hbox{386--392.}

\noindent
\hangindent=2pc
\hangafter=1
Sawkar, D.G., Shevare, G.R., and Koruthu, S.P., 1987, Contour plotting for scattered data, Computers \& Graphics, 11(2), \hbox{101--104.}

\noindent
\hangindent=2pc
\hangafter=1
Sibson, R., 1981, A brief description of natural neighbour interpolation, {\sevenit in} Interpreting multivariate data, {\sevenit ed}.\ V.\ Barnett, John Wiley, \hbox{21--36.}

\noindent
\hangindent=2pc
\hangafter=1
Simons, S.L.Jr., 1983, Make fast and simple plots on a microcomputer, Byte, 8, \hbox{487--492.}

\noindent
\hangindent=2pc
\hangafter=1
Watson, D.F., 1982, ACORD---Automatic contouring of raw data, Computers \& Geosciences, 8(1), \hbox{97--101.}

\noindent
\hangindent=2pc
\hangafter=1
Watson, D.F., 1985, Natural neighbour sorting, The Australian Computer J., 17(4), \hbox{189--193.}

\noindent ...

Contour plotting on a non-rectangular grid

I am new to this system so please bear with me.  I am looking for some help in
finding and setting up an FTP site to store GIF files of photos.  If you can b

can fill you in on the detail then.  Thanks.

Greg Demetrick
Syracuse University

I am developing an application which will generate contours using a
set of x,y,z data (f(x,y) = z). There are design constraints, which
limit the valid x and y values so the region, which will contain
contours, is a non-rectangular sub-region (this region will have
curved and straight sides). I have two approaches to solving this
problem.

1. Define a rectangular grid of values, which completely encompass the
valid region (calculating values outside the valid region is not a
problem). Then clip the contours to fit within the valid region.

2. Calculate x,y,z data which is only within the valid region and
contour this data grid. The number of x values would vary depending on
the value of y.

The first option allows the use of almost any contour package but has
the added overhead of clipping the contours to fit the desired region.

The second option would require a special contour program design to
work with a very non-rectangular grid. In addition, it is not clear
how well the contour program could generate the contours close to the
constraint boundaries since it will only have data on one side of the
boundary.

How do the professionals solve this problem. Any recommendations would
greatly be appreciated.

Thanks,

John Chauvin