[ncl-talk] how to take area average of a user-defined polygon region

Mary Haley haley at ucar.edu
Mon Sep 28 11:50:42 MDT 2015


Mira,

[I had already started this email before Adam responded, so I'm going to go
ahead and send this. Adam's suggestions are perfectly valid as well.]

One way to average data over a particular region is to use a shapefile to
provide the lat/lon area of interest, and then use the gc_inout function to
collect all the points that fall inside (or outside) the region of
interest, so you can then take an average.  Of course, this average is not
very meaningful because it's taken over a rather large area, but I wanted
to show how you would do it.

We have a number of examples of doing this using shapefiles (the country
shapefiles are usually downloaded from the gadm.org/country).  See:

http://www.ncl.ucar.edu/Applications/shapefiles.shtml

In particular, see example shapefile_19.ncl, which uses
"shapefile_mask_data" to mask the data based on outlines in a shapefile. It
uses "gc_inout" under the hood.

The tricky part for you is that it sounds like you only want to mask the
data based on a particular subset of Greenland, which I don't know if it is
available in a shapefile.

I've attached an example that uses two regions of Greenland called
 "Ammassalik" and "Illoqqortoormiut", which I downloaded from
gadm.org/country (GRL_adm2.shp).

The second image shows the original data grid drawn with markers, and the
red markers indicate data that were set to missing by the masking routine.

You can get the ts_Amon NetCDF data file from
http://www.ncl.ucar.edu/Applications/Data/

--Mary


On Sun, Sep 27, 2015 at 12:30 PM, <mberdahl at envsci.rutgers.edu> wrote:

> Hi all,
>
> I have model output for the north atlantic/greenland region and I would
> like to take regional averages of precipitation.  I'm wondering how to
> define the regions with NCL.  For example, I would like to take the
> average of precipitation over the Southeast of Greenland, this region
> would have to be a polygon defined by the user.  I would only like to
> consider grid cells on land as well.  Does anyone have any advice on this?
>
> Independent of this, I would like to be able to choose the grid cell
> closest to a lat/lon point that is user-defined.  Can someone point me in
> the right direction please?
>
> Thanks very much,
> Mira
>
> _______________________________________________
> 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/20150928/18e7ebc8/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: greenland_mask.ncl
Type: application/octet-stream
Size: 4416 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150928/18e7ebc8/attachment-0001.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: greenland_mask.1.png
Type: image/png
Size: 166248 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150928/18e7ebc8/attachment-0002.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: greenland_mask.2.png
Type: image/png
Size: 369534 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150928/18e7ebc8/attachment-0003.png 


More information about the ncl-talk mailing list