contouring algorithm

From: Dave Kennison (kennison AT XXXXXX)
Date: Wed Aug 28 2002 - 15:39:49 MDT


Hauss Reinbold asked the following question:

> From: Hauss Reinbold <reinbold AT dri.edu>
> To: ncl-talk AT ucar.edu
> Subject: contouring algorithm
>
> Hey everyone,
>
> I'm in the process of replacing some GRADS (am I allowed to speak that
> name here?) contour graphs with NCL versions because NCL is prettier. I
> know GRADS uses a Cressman algorithm to contour data and I was wondering
> if anyone knows how NCL does it. I've been comparing the two and the
> results are similar but not the same (but very, very close). The only
> thing is NCL will occasionally have contour lines that cross or spike
> oddly and the same lines in grads won't cross (are instead concentric) and
> never spike so oddly. Beyond that, it seems that contour lines by nature
> shouldn't cross so maybe it's a quirk of the data combined with the
> contouring algorithm. I guess my question on this is, is there another
> contouring algorithm I can use with NCL or do you just have one set up?
> Also, is there anything besides cnSmoothinOn I can set that will maybe get
> rid of contour spikes and crossing lines? I'd like to keep my contour
> interval and levels the same if I can. Sorry if this is all a bit
> confused, it's easier to understand if you could see what I'm talking
> about. As is, I keep waving my hands at the monitor trying to explain it.
> Anyway, I'd be grateful for any help anyone can give me.
>
> Hauss Reinbold

I'm the author of CONPACK, which is accessed from NCL to do contouring.
I know a lot about what's in CONPACK, but not so much about what is or
is not usable from NCL.

I don't know what the "Cressman algorithm" is and I don't know if the
method that we use has anyone's name attached to it, but it's a pretty
simple method that cannot create contour lines crossing each other unless
you turn on the so-called "2D smoother" and set the tension parameter too
small; doing that can also create some odd spikes, so I would guess that's
probably what he's doing. I would recommend that he either turn smoothing
off completely or else use the so-called "3D smoother", which fits a smooth
3D surface to the data and then contours that.

(By the way, I have been known to get up on a soapbox about this issue:
I really don't think a contouring package should do any smoothing at all.
The user ought to be forced to do it for himself, so that he or she will
know what method is being used and what misrepresentations of his or her
data are introduced by that method.)

In the documentation for NCL, I find the following about the use of the 2D
smoother:

 cnSmoothingOn

    When the boolean resource cnSmoothingOn is True, the ContourPlot object
    will smooth the contours using cubic splines under tension. The resources
    cnSmoothingTensionF and cnSmoothingDistanceF control the parameters of
    the smoothing algorithm. Note that when smoothing is turned on, it is
    possible in some cases for adjacent contour lines to cross each other.
    In this case, you need to adjust the cnSmoothingTensionF experimentally
    in order to eliminate the problem.

  Default: False

  cnSmoothingTensionF

    If you give cnSmoothingTensionF a value of 0.0, smoothing is turned off.
    If you give it a negative value, the ContourPlot object performs smoothing
    prior to any transformations of the data space; if you make it positive,
    smoothing takes place after any data space transformations. Small absolute
    values on the order of 0.001 give 'loopy' curves, which are rather likely
    to cross each other. Large absolute values give tight, nearly polygonal
    curves.

    Note that if cnMaxPointDistanceF is set to a non-zero value, smoothing will
    not work properly unless it is applied prior to the transformation of the
    data space. Therefore you should always set cnSmoothingTensionF to a
    negative value when cnMaxPointDistanceF is non-zero.

I find nothing about the 3D smoother, so I don't know how it is "turned on"
from NCL (or even if one can access it - I suspect not, because I think that
there are probably better ways of interpolating to a denser field than I
provided in CONPACK).

Perhaps someone else on the list can post information about better methods
available in NCL to do the equivalent of CONPACK's 3D smoothing.

Dave
_______________________________________________
ncl-talk mailing list
ncl-talk AT ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk



This archive was generated by hypermail 2b29 : Wed Aug 28 2002 - 15:56:41 MDT