Re: white line on plot at meridian 0

From: Kyle Griffin <ksgriffin2_at_nyahnyahspammersnyahnyah>
Date: Tue Apr 15 2014 - 12:55:26 MDT

This is modified some from my code, simply because the function I was using
is now a full part of NCL, called span_color_rgba (new to 6.2.0)

http://ncl.ucar.edu/Document/Functions/Built-in/span_color_rgba.shtml

This also assumes you know the number of levels that you will be contouring
(let's say nlevels, in your example this looks like 16). This is also
specifically written as your contours aren't symmetric about zero (there
are more positive levels than negative, so I've specifically chosen the
levels to set to zero rather than calculate them assuming symmetry)

; This should read the colormap and only pull colors necessary to span
nlevels
cmap = span_color_rgba("yourmap",nlevels)
; These two lines will set the opacity on levels 6 and 7 to 0
; note: each line could also be = (/1,1,1,0/) to ensure white and
transparent,
; but the first three numbers shouldn't matter as long as the fourth is 0
cmap(5,3) = 0.
cmap(6,3) = 0.
res@cnFillColors = cmap

It's important to ensure that dimsizes(cmap) and nlevels are the same
value, otherwise the code will error - but that should be taken care of
internally, as long as you don't change any of the levels associated with
res before you make that particular plot.

Kyle

----------------------------------------
Kyle S. Griffin
Department of Atmospheric and Oceanic Sciences
University of Wisconsin - Madison
Room 1421
1225 W Dayton St, Madison, WI 53706
Email: ksgriffin2@wisc.edu

On Tue, Apr 15, 2014 at 1:29 PM, Ioana Colfescu <colfescu@cola.iges.org>wrote:

> Hi Kyle,
>
> Thanks so much for all the help and info ! I added gsnAddCyclic = True and
> it works - my white line is finally gone.
> I looked into all the options you listed for getting the white color from
> -x and +x and I think I'll go for reading the color table myself and set
> the colors manually.
> If you have any part of code/script for that and can send me would be
> great, I'll be super grateful but even if not it was a lot of help the mail
> already !
> Oh yea and it doesn't matter if the code is not clean :)) ha ha ... I'm a
> PhD student ( at George Mason University/COLA ) and ... PhD students don't
> even have clean codes :)) is enough it works and I get my things done with
> it.
>
> Cheers,
> Ioana
>
>
> Thanks so much for the help and for all the information!
>
> On 4/15/14, 2:14 PM, Kyle Griffin wrote:
>
> Hi Ioana,
>
> Have you tried setting gsnAddCyclic = True in your resources for the
> contours? That should fix the problem.
>
> There are a couple of approaches to get the near-zero contours to be
> white. One option is to create a custom color table, as you can do via the
> instructions found at
> http://ncl.ucar.edu/Document/Graphics/create_color_table.shtml
>
> You can also try to read in the color table yourself (with
> read_colormap_file) and manually set the two colors you want white to be
> white (e.g. cmap(5,:) = (/0,0,0,0/) if you want the 6th color from the
> beginning to be white). This is probably the most efficient way, once you
> learn how to set it up.
>
> Along the same lines, you can manually specify the levels and use an
> array of the colors you specify in that color table either as RGB triplets,
> like (/(/255,0,0/),(/0,0,255/),(/255,0,255/)/) for a color set of red,
> blue, and purple or an array of named colors, like ("red","blue","purple")
> for the same effect. Assign this array of colors to cnFillColors once your
> levels are set appropriately.
>
> Finally you can also make two plots - one for the values >0.01 and one
> for the values <-0.01 and have the colors cut off appropriately, leaving
> the white space in between blank.
>
> It does not seem, unfortunately, like there is a straightforward
> solution. If you'd like, I can provide some of my code to get this done
> (with the read_colormap_file based solution), although my code isn't
> exactly in line with the best practices for version of NCL 6.1.0 and newer.
>
>
> Kyle
>
> ----------------------------------------
> Kyle S. Griffin
> Department of Atmospheric and Oceanic Sciences
> University of Wisconsin - Madison
> Room 1421
> 1225 W Dayton St, Madison, WI 53706
> Email: ksgriffin2@wisc.edu
>
>
> On Tue, Apr 15, 2014 at 11:43 AM, Ioana Colfescu <colfescu@cola.iges.org>wrote:
>
>> Hi,
>>
>> I'm using lonFlip and when I use it I get this white line ( see plot
>> attached ) at lon 0 . Could someone please tell me what should I do to get
>> rid of that line ?
>> Also, I'd like to have the contours between -0.01 and 0.01 white - what
>> should I do for that ? ( and still use the same color table).
>> Thanks,
>> Ioana
>>
>>
>>
>> _______________________________________________
>> 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 Tue Apr 15 12:55:58 2014

This archive was generated by hypermail 2.1.8 : Wed Apr 16 2014 - 09:14:14 MDT