Re: automatically setting contour levels centered at zero

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed Oct 19 2011 - 10:22:12 MDT

Cathy,

We don't have an automatic way to do this, but I think you could get close if you use nice_mnmxintvl using the absolute max of both the min/max of your data as your end points, and then adjust the values if you have a 0 value.

Here's an example, which you might need to adjust for your needs:

  tmin = -15.5
  tmax = 14.0
  m = nice_mnmxintvl(tmin,tmax,10,False)

;---testspan is an *unadvertised* routine that we don't support.
  values = testspan(m(0),m(1),m(2))
  print("tmin/tmax = " + tmin + "/" + tmax)
  print("min/max/step = " + m(0) + "/" + m(1) + "/" + m(2))
  print("original values = " + values)

  if(any(values.eq.0)) then
    print("'values' contains '0'")
;---Adjust values to remove the 0 value.
    dx = values(1)-values(0)
    new_values = values(ind(values.ne.0))
    new_values = where(new_values.lt.0,new_values+dx/2.,new_values-dx/2.)
  else
    new_values = values
  end if
  print("new values = " + new_values)

Results:

(0) tmin/tmax = -15.5/14
(0) min/max/step = -12/12/4
(0) original values = -12
(1) original values = -8
(2) original values = -4
(3) original values = 0
(4) original values = 4
(5) original values = 8
(6) original values = 12
(0) 'values' contains '0'
(0) new values = -10
(1) new values = -6
(2) new values = -2
(3) new values = 2
(4) new values = 6
(5) new values = 10

--Mary

On Oct 17, 2011, at 4:28 PM, Cathy Smith wrote:

>
> NCL users:
>
> My goal is to have NCL automatically set contour intervals for anomaly or correlation plots that satisfy these 3 goals
>
> 1) They need to be symmetric about zero.
> 2) The contour levels need to be "nice".
> 3) There needs to be an even number of contour levels so that the center interval between levels straddles zero.
>
>
> What I want is to have anomaly or correlation plots with a single zero centered contour interval (which I will color white). I am familiar with
> symMinMaxPlt but it didn't do exactly as I wanted as it had a contour level at zero as opposed to one centered around zero.
>
> I am open to have the middle contour range be wider than the rest (say, -.5,-4,-.3,-.2,-.1,.1,.2,.3,.4,.5). I would really like to avoid having
> to determine the optimum number nice contour intervals myself.
>
> Thanks for any suggestions.
>
> Cathy Smith
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Oct 19 10:22:25 2011

This archive was generated by hypermail 2.1.8 : Wed Oct 19 2011 - 13:36:10 MDT