[ncl-talk] Resend of contour line color issue

Alison Bridger alison.bridger at sjsu.edu
Wed Feb 14 11:03:02 MST 2018


HI Mary,

Thanks for the input - much appreciated!

The res at cnLineThicknessF = 3 fix alone had no impact, but the
res at cnLinesOn = True fix DID!

So now I have big fat contours.

cnLinesOn also fixed the color issue, so I have big fat red contours!

Sorry my code is so clunky - I can certainly tidy it up, but the 1st task
is make sure the numbers and geography are correct !

Thanks again, Alison


On Tue, Feb 13, 2018 at 2:39 PM, Mary Haley <haley at ucar.edu> wrote:

> 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:
>
>     grad = new((/71,41/),"float")
>     grad = grdx + grdy
>
> You can just have:
>
>     grad = grdx + grdy
>
> 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:
>
>     grad = tofloat(grdx + grdy)
>
> 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 file zgrad_gradient_...ps (not attached).
>>
>> 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
>>
>>
>


-- 

                 Alison F.C. Bridger
                  Professor & Chair

    Department of Meteorology and Climate Science

    San Jose State University      tel  408.924.5206
    One Washington Square          fax  408.924.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>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180214/0d6a2317/attachment.html>


More information about the ncl-talk mailing list