[ncl-talk] Masking points based on gsn_csm_contour_map limits

Daniel Adriaansen - NCAR dadriaan at ucar.edu
Tue Feb 20 14:49:28 MST 2018


Hi Mary,

Not a problem at all.

Thank you so much for the example- this was exactly what I was trying to
accomplish and you provided lots of additional great ideas like applying
the mask to a data field in a different way than I had done. I was
successfully able to determine only those points shown in the viewport for
the map.

Really appreciate it, and thanks again Mary!

-Dan

On Mon, Feb 12, 2018 at 10:05 PM, Mary Haley <haley at ucar.edu> wrote:

> Hi Dan,
>
> Sorry for the long delay. Most of the NCL team was out last week for a
> workshop.
>
> I decided to create an example based on your question, since it's an
> interesting one that we don't have an example of yet. Hopefully I
> understood your question correctly!
>
> See example mask_18.ncl at:
>
> http://www.ncl.ucar.edu/Applications/mask.shtml#ex18
>
> I started off on the same path you did, by creating a lambert conformal
> plot. I then used this plot to retrieve the viewport coordinates of the
> plot axes.  The viewport coordinates give me the four corners of the plot
> in NDC space, which I then used "ndctodata" on to calculate the lat/lon
> locations.
>
> It's not enough to just provide the four corners of the plot, however,
> because the lambert conformal boundary is curved. So, for each of the four
> axes, I created an array of equally spaced viewport coordinates between the
> start and end of each axis, so this would give me more values to
> interpolate the lat/lon boundary.  See the "get_latlon_bounding_polygon"
> function.
>
> Once I had the lat/lon boundary, I used "gc_inout" to create a mask array.
>
> This example uses a data array that is on a rectilinear grid, and which
> has lat/lon coordinate arrays called "lat" and "lon". If your data is not
> rectilinear or you don't have coordinate arrays, then you'll need to modify
> the create_mask_array function to handle the type of lat/lon grid your data
> is on.
>
> Let me know if you have any questions.
>
> --Mary
>
>
> On Tue, Feb 6, 2018 at 12:49 PM, Daniel Adriaansen - NCAR <
> dadriaan at ucar.edu> wrote:
>
>> Hello,
>>
>> I am plotting a Lambert Conformal map using res at mpLimitMode set to
>> "Corners". The map limits are configured to zoom in on a subset of the full
>> domain of the gridded dataset in the x-y dimensions (lat-lon). I am then
>> calling gsn_csm_contour_map to plot the data.
>>
>> What I would like to do, is use the "Corners" resources, to create a
>> polygon so that I can perform statistics on the data only within the view
>> shown in the map that is drawn by gsn_csm_contour_map. The problem is, I
>> have not figured out how gsn_csm_contour_map determines what the bounds are
>> for the domain drawn when using the "Corners" resources.
>>
>> My first attempt was to create a polygon from the "Corners" resources
>> (res at mpLeftCornerLonF, res at mpLeftCornerLatF, res at mpRightCornerLonF, and
>> res at mpRightCornerLatF) and then use gc_inout to identify which points
>> from the gridded dataset are within the map limits. When I plot the
>> resultant boolean mask however, the points "inside" the polygon do not
>> directly match the view shown in the bounding box from gsn_csm_contour_map
>> (see attached figure, Mask1.png).
>>
>> The end goal is to make sure the statistics being computed are created
>> from exactly those grid cells shown within the bounding region created by
>> gsn_csm_contour_map.
>>
>> Any suggestions or ideas are appreciated. Thanks!
>>
>> -Dan
>>
>>
>>
>> _______________________________________________
>> 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/20180220/0e8df9fa/attachment.html>


More information about the ncl-talk mailing list