[ncl-talk] Area fill not working on gsn_contour and label string stopped working

Mary Haley haley at ucar.edu
Mon Aug 20 12:34:05 MDT 2018


Hi Adam,

I just ran your script using both NCL V6.5.0 and V6.4.0 on my Mac and had
no problems.

Your mention of cairo makes me think that the issue could be that your
Ubuntu is installing a version of cairo that is incompatible with the
version that NCL expects. Cairo is the engine for NCL graphics, so it's
very likely that this is why you are seeing problems.

Since you are using the Ubuntu-packaged NCL, which is not something the NCL
team created, I'm guessing that it depends on the system cairo and this
could cause issues if the versions are not synced.

*What I recommend is to reinstall NCL using conda, which gives you the
exact environment that you need in order to run NCL correctly. This should
be available for Ubuntu as well as other flavors of Linux.*

This is a bit unrelated, but I took the opportunity to clean up your script
a little. Here are some of the things I changed:

[1] I moved a bunch of resource settings to outside the do loop to make the
code more efficient. Do loops are expensive in general, so any code that
doesn't change for each iteration of a do loop should be moved outside the
do loop.

[2] It looks like this is a WRF output file, which means you can use
wrf_map_resources to set the map projection parameters for you.

Of course, if this is a moving nest, then you will need to adjust these
settings inside the do loop, but I printed the min/max of the lat/lon
variables, and they stayed the same for each iteration across time.

Using the native projection means you don't need to read lat/lon off the
file, so I commented this part out.

[3] Since the data is regional, I added this resource to prevent NCL from
trying to add a cyclic point:

  res at gsnAddCyclic = False

However, I think this might be the default already, so I'm not sure it
changed anything.

[4] Subsets of the TOTRAIN variable was being read inside the do loop,
causing some parts of this array to be read in multiple times. To save
time, at the expense of using more memory, I read all of TOTRAIN into a
local variable.

[5] I set this:

  res at mpFillOn = False

to prevent the land from being unnecessarily filled in gray. The gray land
was being covered up by white contours, so drawing the land in gray was
just adding an extra unneeded step.


[6] I made the labelbar vertical, which is really a personal preference.
You might prefer it to be horizontal.  :-)

[7] Normally you want to add the time step for each iteration as a title on
your plot. Since I wasn't sure what the time step was, I didn't do anything
with this.

See the attached changed script and the animated GIF which I created with:

convert -delay 10 raintest.00*png raintest.gif


--Mary


On Mon, Aug 20, 2018 at 10:32 AM, Adam Dury <adampeterd at hotmail.co.uk>
wrote:

> No worries Mary,
>
>
>
> Just to update you. I made a new ubuntu 18.04.1 server from a fresh and
> installed ncl. Running the rain script I now get a segmentation fault which
> points to a segfault in cairo_ft_font_face_create_for_ft_face().
>
>
>
> Was this error just not showing on the previous desktop or is there a
> general problem with ubuntu 18.04?
>
>
>
> Thanks
>
> Adam
>
>
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
> Windows 10
>
>
>
>>
>> ------------------------------
>> *From:* Mary Haley <haley at ucar.edu>
>> *Sent:* Friday, August 17, 2018 3:11:44 PM
>> *To:* Adam Dury
>> *Cc:* ncl-talk at ucar.edu
>> *Subject:* Re: [ncl-talk] Area fill not working on gsn_contour and label
>> string stopped working
>>
>> Hi Adam,
>>
>> FYI: We just release NCL V6.5.0 so you might want to try this. You can
>> use "conda" to install NCL, which is similar to the way you installed the
>> Ubuntu package.  Instructions can be found here
>> <http://www.ncl.ucar.edu/Download/conda.shtml>.
>>
>> However, I'm not aware of any specific problems in NCL V6.4.0 that would
>> cause these problems. Sometimes the contouring algorithms can have problems
>> if you have coordinate arrays or values for each of your data values and
>> the coordinates are inconsistently spaced. Moving to raster fill definitely
>> changes the algorithm used under the hood.
>>
>> The labelbar strings not appearing is also not something I'm aware of. I
>> would need to know more about how you are creating the plot and what your
>> data looks like.
>>
>> Are you able to provide your script and data so I can have a look? If the
>> date file is small, you can email it and the script to me (and feel free to
>> email them to me personally if you don't want to send them to ncl-talk). If
>> the data is large, you can use our ftp:
>>
>> http://www.ncl.ucar.edu/ftp_files.shtml
>>
>> As for using the Ubuntu package: this shouldn't be the cause of your
>> problems. Do you have any other contour scripts that still work? If you
>> don't have your own scripts, you could try one of our examples. Go to:
>>
>> http://www.ncl.ucar.edu/Applications/plot_data_on_map.shtml
>>
>> where you can download the scripts and the data files.
>>
>> Look over this suite of examples and pick one of the filled contour
>> ones.  The very first one is a good place to start.
>>
>> Hope to hear back from you as I'd like to get to the bottom of this.
>> Thanks!
>>
>> --Mary
>>
>>
>>
>>
>> On Tue, Jul 31, 2018 at 1:48 PM, Adam Dury <adampeterd at hotmail.co.uk>
>> wrote:
>>
>>>
>>>
>>> Hi,
>>>
>>>
>>>
>>> I have been using ncl 6.3 for a while now and recently upgraded to 6.4
>>> to use a new variable you have added.
>>>
>>> One script I have been using uses gsn_contour and uses the default fill
>>> mode of “area fill”. However since upgrading to 6.4 it doesn’t seem to be
>>> plotting colours using this area fill mode, but if I turn on the contour
>>> lines then I can see it is plotting the data correctly.
>>>
>>> I have found a work around to use raster fill and then turn on raster
>>> smoothing which gives roughly the same picture. Just wanted to let you know
>>> as I guess this is a bug introduced into 6.4? I couldn’t find anything else
>>> online about it so I guess not many other people have come across this
>>> error.
>>>
>>>
>>>
>>> Also the labelbarstrings resource doesn’t seem to be working properly
>>> either. I don’t get any errors on command line but the label bar names
>>> never appear properly.
>>>
>>>
>>>
>>> I am using the defauly ubuntu package rather than installing ncl myself
>>> so do you think this is an issue?
>>>
>>>
>>>
>>> Thanks
>>>
>>>
>>>
>>> Adam
>>>
>>>
>>>
>>> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
>>> Windows 10
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> 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/20180820/73f7633a/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: raintest.gif
Type: image/gif
Size: 1962865 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180820/73f7633a/attachment-0001.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rainauto_mod.ncl
Type: application/octet-stream
Size: 3022 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180820/73f7633a/attachment-0001.obj>


More information about the ncl-talk mailing list