[ncl-talk] plotting grid lines for unstructured grids
Mary Haley
haley at ucar.edu
Thu Apr 7 11:21:32 MDT 2016
[I had to reject my own ncl-talk post because my previous attachment was
too large!]
Adam,
As I said offline, I have a script that draws your grid, but I'm not sure
this is what you want.
You are drawing the grid from a SCRIP file, and it looks like each boundary
is a rectangle and not a pentagon. I recommend drawing the grid from the
original source, rather than the SCRIP file.
Anyway, you should be able to use a modified version of the attached code
to draw the original grid. I actually showed three different ways to draw
the grid, mainly to illustrate the difference in speed of each method. The
timings are as follows:
Elapsed time for method 1 using gsn_add_polyline = 15.9526
Elapsed time for method 2 using gsn_polyline = 19.662
Elapsed time for method 3 using gsn_add_polyline/gsSegments = 0.850868
gsSegments can really speed things up if you have a lot of lines to add.
I've attached the script and only one of the PNG images (since the other
two should be identical).
--Mary
On Thu, Apr 7, 2016 at 11:18 AM, Mary Haley <haley at ucar.edu> wrote:
> Adam,
>
> As I said offline, I have a script that draws your grid, but I'm not sure
> this is what you want.
>
> You are drawing the grid from a SCRIP file, and it looks like each
> boundary is a rectangle and not a pentagon. I recommend drawing the grid
> from the original source, rather than the SCRIP file.
>
> Anyway, you should be able to use a modified version of the attached code
> to draw the original grid. I actually showed three different ways to draw
> the grid, mainly to illustrate the difference in speed of each method. The
> timings are as follows:
>
> Elapsed time for method 1 using gsn_add_polyline = 15.9526
> Elapsed time for method 2 using gsn_polyline = 19.662
> Elapsed time for method 3 using gsn_add_polyline/gsSegments = 0.850868
>
> gsSegments can really speed things up if you have a lot of lines to add.
>
> I've attached the script and only one of the PNG images (since the other
> two should be identical).
>
> --Mary
>
>
>
>
> On Thu, Apr 7, 2016 at 9:37 AM, Mary Haley <haley at ucar.edu> wrote:
>
>> I'll try to take a look soon. I had a tutorial to give yesterday and was
>> not checking email for a bit.
>>
>> Usually, tools want the cells be oriented in counter clockwise order.
>> This becomes critically important to have this consistency in order for
>> things like regridding to be applied correctly.
>>
>> --Mary
>>
>> On Mon, Apr 4, 2016 at 11:43 AM, adamrhster . <adamrhster at gmail.com>
>> wrote:
>>
>>> Hi Mary,
>>>
>>> I'm trying to plot the cubed-sphere grid using cam-se data. This doesn't
>>> appear to be addressed in the "seam" examples. In the attached plot, the
>>> nodes are the red points that I want to connect with ~roughly orthogonal
>>> grid lines. The blue lines are a result of the cnFillMode = "CellFill"
>>> using vertices that aren't really of interest to me (these are for the
>>> interpolating fields to the coupler from file "ne4np4-pentagons.nc")...Alternatively,
>>> the ESMF re-grid generated a sourcefile with seemingly opposite vertex and
>>> center coord data (3 vertices for each center coord, and the vertices
>>> appear to be on the actual computational nodes)
>>>
>>> Maybe gsSegments will work...but I don't know a direction to orient the
>>> line segments since the nodes are not in any particular order. My script
>>> (and data) are on glade:
>>>
>>> /glade/p/work/aherring/grids/seam.ncl
>>>
>>>
>>>
>>> On Mon, Apr 4, 2016 at 12:35 PM, Mary Haley <haley at ucar.edu> wrote:
>>>
>>>> Hi Adam,
>>>>
>>>> We have a function called "gsn_coordinates" which draws grid points or
>>>> grid lines for the given data array, but it doesn't handle the special case
>>>> of an unstructured grid with N cells and NE edges.
>>>>
>>>> However, if your grid is defined such that you have an array of indexes
>>>> that represent vertex edges for another array that contains the nodes, then
>>>> you might be able to use the gsn_add_polyline routine with the special
>>>> "gsSegments" resource.
>>>>
>>>> See example "mpas_faster_2.ncl" which shows the gsSegments method, and
>>>> the mpas_2.ncl example which draws the same thing, but in a slower fashion
>>>> using basic line draws. The point of this example is to show how much
>>>> faster gsSegments can make your code.
>>>>
>>>> https://www.ncl.ucar.edu/Applications/mpas.shtml
>>>>
>>>> The ICON page that Guido pointed you to also makes use of the
>>>> gsSegments resource, in example icon_faster_2.ncl.
>>>>
>>>> https://www.ncl.ucar.edu/Applications/icon.shtml
>>>>
>>>> If you have an unstructured grid that is different from the ICON and
>>>> the MPAS grids, then I would love to add this as yet another example on our
>>>> website. I could help you create the script if necessary, but would need
>>>> access to your data file. I could perhaps use this as a way to enhance
>>>> gsn_coordinates to better handle unstructured grids.
>>>>
>>>> --Mary
>>>>
>>>>
>>>>
>>>>
>>>> On Sun, Apr 3, 2016 at 3:01 PM, Adam Herrington <
>>>> adam.herrington at stonybrook.edu> wrote:
>>>>
>>>>> How would one plot grid lines for a data array on an unstructured
>>>>> grid?
>>>>>
>>>>> I am able to plot grid boxes around nodes by setting cnFillMode =
>>>>> "CellFill" and defining the vertices of the grid box. But what if I want
>>>>> grid lines connecting the nodes? And what if I want to plot grid lines on
>>>>> every other node (not that the data arrays have one dimension for the
>>>>> horizontal dimension, containing all the tiles of the sphere --this is a
>>>>> global model)
>>>>>
>>>>> Any help would be greatly appreciated
>>>>>
>>>>> Adam
>>>>>
>>>>> _______________________________________________
>>>>> 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/20160407/74d39a32/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: seam_grid.ncl
Type: application/octet-stream
Size: 3740 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160407/74d39a32/attachment-0001.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: seam_grid.png
Type: image/png
Size: 908356 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160407/74d39a32/attachment-0001.png
More information about the ncl-talk
mailing list