[ncl-talk] Explicit levels (using WRF output)

Mary Haley haley at ucar.edu
Fri Jan 20 12:13:21 MST 2017


Arianna,

My apologies, I forgot to set a very critical resource to make the plot be
rotated correctly.  I had set the four corners of the projection but forgot
this resource:

  res at mpLimitMode          = "Corners"

Please use the attached script instead, and see the new image.

As a check that the data are being plotted correctly, I created a second
script that plots the data in a Cylindrical Equidistant map projection,
using the XLAT and XLONG read of the file to correctly project the data
onto this projection.  See the attached plotlanduse_mod_latlon.ncl script
and image.

--Mary




On Thu, Jan 19, 2017 at 3:29 PM, Arianna Valmassoi <
arianna.valmassoi at gmail.com> wrote:

> Hi Mary,
> thank you very much, now there is no problem with the filling!
>
> Have you notice (and it happened to me before) that in the light blue you
> can see the world coast-line? (In the figure you sent me there is in the
> bottom right corner a part of Africa and Madagascar).. I wasn't able to do
> anything to remove them (without removing the coordinates..)
>
> Thank you very much again
>
> Cheers
>
> Arianna
>
> Il giorno gio 19 gen 2017 alle ore 22:20 Mary Haley <haley at ucar.edu> ha
> scritto:
>
>> Hi Arianna,
>>
>> NCL does its contouring by filling the contours based on what values fall
>> above or below a contour level, and not exactly equal to a contour level.
>> This causes confusion when your data is all integers.
>>
>> If you specify contour levels of 1,2,3,4,5, then NCL is going to create a
>> contour plot with *6* colors, where the colors represent the following:
>>
>>   color 1 - all values < 1
>>   color 2 - all values >= 1 and < 2
>>   color 3 - all values >= 2 and < 3
>>   color 4 - all values >= 3 and < 4
>>   color 5 - all values >= 4 and < 5
>>   color 6 - all values >= 5
>>
>> This is why you see the extra "Label_1", because NCL only expects (n-1)
>> labels if you have n colors, because it's assuming you are labelling
>> *between* values.  When you tell it to center the labels, then suddenly you
>> are one label short, and hence NCL gives you the "Label_1" label.
>>
>> Back to your contour levels:
>>
>> In your code, you set the first contour level to 1, so this means that
>> the first color (darkgreen) is going to represent all values < 1, which
>> means any value equal to 0, since you only have integer values.
>>
>> Then, then next color, "forestgreen" is going to represent all values >=1
>> and < 2, which, again, in your case, since you just have integers, is going
>> to be all colors equal to 1.
>>
>> If you want the first color to represent all values equal to 1, and the
>> second color all values equal to 2, and you want twenty colors total, where
>> the last color represents values equal to 20, then you need to create 19
>> contour levels that start just slightly higher than 1, 2, 3, 4, etc:
>>
>> This is one way of doing it, by adding 0.1 to the levels:
>>
>>   res at cnLevels  = (/1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11,12,13,14,
>> 15,16,17,18,19/)+0.1
>>
>> I see you are using cnFillPalette, which is okay, but it's better to use
>> cnFillColors when you have a specific color for each contour level.  This
>> way you don't need to mess with gsnSpreadColors:
>>
>>   res at cnFillColors     = colorscheme        ; distinct colors for
>> categories
>>  ; res at gsnSpreadColors = False           ; comment this or remove it
>>
>> If you are trying to plot this data over a map, you generally want to use
>> wrf_contour *and* wrf_map_overlays.  But, your XLAT and XLONG on the file
>> do not have a time dimension, which is going to cause problems for
>> wrf_map_overlays.
>>
>> So, I modified your code to use gsn_csm_contour_map instead, but I used
>> the map projection defined on the file.
>>
>> I've attached the modified script and a new PNG.
>>
>>
>> --Mary
>>
>>
>> On Thu, Jan 19, 2017 at 10:57 AM, Arianna Valmassoi <
>> arianna.valmassoi at gmail.com> wrote:
>>
>> Hi all,
>>
>> I'm working with WRF and it's landuse representation. In the plot output
>> I have the following problems:
>>
>>    - label: there is one more tic in the label with the first color, and
>>    has a name I did not put.
>>    - assign color to discrete numbers: I had to impose to the landcat to
>>    start with zero, not as one as it is, otherwise the first level will not
>>    match
>>    - Domain visualization: I can't use the model coordinates (even using
>>    other plot option)
>>
>>
>> I attach here both the code and the .nc file, in order to help the debug
>> category 13 should be red and category 17 light blue.
>>
>> Thank a lot for any help and sorry if it's a duplicate problem!
>>
>> Cheers,
>> Arianna Valmassoi
>> --
>> Arianna Valmassoi
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>> --
> Arianna Valmassoi
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170120/bc4794d8/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ctrland.png
Type: image/png
Size: 270019 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170120/bc4794d8/attachment-0003.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plotlanduse_mod.ncl
Type: application/octet-stream
Size: 3105 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170120/bc4794d8/attachment-0003.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ctrland_latlon.png
Type: image/png
Size: 244195 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170120/bc4794d8/attachment-0004.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plotlanduse_mod_latlon.ncl
Type: application/octet-stream
Size: 3278 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170120/bc4794d8/attachment-0004.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plotlanduse_mod.ncl
Type: application/octet-stream
Size: 3105 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170120/bc4794d8/attachment-0005.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ctrland.png
Type: image/png
Size: 270019 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170120/bc4794d8/attachment-0005.png 


More information about the ncl-talk mailing list