# [ncl-talk] Resend of contour line color issue

Mary Haley haley at ucar.edu
Tue Feb 13 15:39:51 MST 2018

```Hi Alison,

The cnLineThicknesses resource is for when you need to use an array of line
thicknesses to set different contour lines to different thicknesses.

If you want to change all the thicknesses to the same value, use
cnLineThicknessF:

res at cnLineThicknessF = 3

Second, I believe that in wrf_contour, if you set cnFillOn to True, it is
internally setting cnLinesOn to False. So try adding:

res at cnLinesOn = True

to force contour lines to be drawn as well as the fill.

Thirdly, and this is just a suggestion: you don't need to use "new" in
cases like this:

You can just have:

because NCL will automatically do the array arithmetic for you, and figure
out the correct return size and type.

If one of grdx or grdy is type double and you really need a float, then you
can do:

Fourthly, double do loops can be slow in interpreted languages like NCL,
Python, matlab, etc.  Where possible, let NCL do the array arithmetic for
you.

In the double do loop below:

dzdy = new((/71,41/),"float")
grdy = new((/71,41/),"float")
do j = 50,120
do i = 120,160
dzdy(j-50,i-120) = ter(j,i) - ter(j,i-1)
dzdy(j-50,i-120) = dzdy(j-50,i-120) / 4000.
grdy(j-50,i-120) = dzdy(j-50,i-120) * va(6,j-50,i-120)
end do
end do

the "ter" calculation makes sense in a do loop, but the other two commands
can be done outside the loop and you can get rid of the internal do loop.
This means you can also get rid of the "new" line for grdy.

Note that this code is untested, but hopefully you can follow what it's
supposed to be doing:

dzdy = new((/71,41/),float)  ; The quotes are not needed around "float"
do j = 50,120
dzdy(j-50,:) = ter(j,120:160) - ter(j,119:159)
end do
dzdy = dzdy / 4000.
grdy = dzdy * va(6,:,:)

--Mary

On Tue, Feb 13, 2018 at 11:44 AM, Alison Bridger <alison.bridger at sjsu.edu>
wrote:

> Hi, This is a re-send with smaller files attached!
>
> I am working on a calculation and decided to start from the ground up (as
> opposed to using a pre-written ncl code).
>
> slope4.ncl is attached (it's really simple!)
>
> I make 2 sets of plots in a loop: (1) the field I want ("grad" in wks1) to
>
> To make sure I know where I am geographically, the 2nd set of plots (wks2)
> is *terrain plus shoreline *(file zgrad_terrain_...ps attached)...this is
> the main focus of my question.
>
> After a certain amount of hacking, I was able to plot the shoreline (!)
> and terrain (!) *BUT I cannot get the contour line colors (or
> thicknesses) to change*!
>
> I was under the impression that cnLineColor would fix the color - but no
> luck.
> I also tried playing with cnLineThicknesses - no luck.
>
> Any help?
>
> Thanks, Alison
>
>
> --
>
>                  Alison F.C. Bridger
>                   Professor & Chair
>
>     Department of Meteorology and Climate Science
>
>     San Jose State University      tel  408.924.5206 <(408)%20924-5206>
>     One Washington Square          fax  408.924.5191 <(408)%20924-5191>
>     San Jose, CA 95192-0104
>
>              email:   Alison.Bridger at sjsu.edu
>
>        *Global CO2 levels...400 ppm and still rising...happy?*
>
>
>                  www.sjsu.edu/meteorology <http://www.met.sjsu.edu>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180213/03ba6113/attachment.html>
```