[ncl-talk] Subsetting a circle of data
Jake Huff
jake.huff at stonybrook.edu
Mon Aug 14 12:19:42 MDT 2017
Thank you both for your suggestions.
I went with what Alan showed me and it worked like I was hoping.
Thanks again,
Jake
On Mon, Aug 14, 2017 at 11:58 AM, Alan Brammer <abrammer at albany.edu> wrote:
>
> Hi Jake,
>
> From that square, which should fully encompass your circle. You could then
> pass the latitude and longitudes of the grid points to gc_inout
> <https://www.ncl.ucar.edu/Document/Functions/Built-in/gc_inout.shtml> to
> find which grid points are actually within your circle.
>
> e.g. (not tested, always test and double check)
>
> ;; Make lat and lon a 2d grid
> lat2d = conform( newTRMMyearly,newTRMMyearly&lat, 0) ; coord names may
> not be correct
> lon2d = conform( newTRMMyearly,newTRMMyearly&lon, 1)
>
> in_circle = gc_inout( lat2d, lon2d, clat, clon)
> newTRMMyearly = where( in_circle, newTRMMyearly, newTRMMyearly at _FillValue)
> ; mask points out of circle
>
>
> set gsnAddCyclic = False and you should be able to plot the grid on a map.
>
> Good luck,
>
> Alan
>
>
> On Aug 13, 2017, at 2:43 PM, Jake Huff <jake.huff at stonybrook.edu> wrote:
>
> Hello,
>
> I am working on reading in precipitation data that corresponds to a radius
> of a 500km around a tropical cyclone. I have a variable that contains
> precipitation over the Eastern US and into the Atlantic Ocean. Below is
> some of my code.
>
> ;Snippet of code
>
> obtracks = addfile("Allstorms.ibtracs_wmo.v03r05.nc
> <http://allstorms.ibtracs_wmo.v03r05.nc/>","r") ;Read in IBTrACS
> lat_wmo = short2flt(obtracks->lat_wmo) ;(storm,time)
> lon_wmo = short2flt(obtracks->lon_wmo) ;(storm,time)
>
>
> ; Read in Precipitation Files
>
> precipfile = addfile("TRMMdata.nc","r")
> AvgYearlyTRMM = precipfile->AvgYearlyTRMM ;(time,lat,lon)
>
> clat = new(61,float)
> clon = new(61,float)
> radius = 5.0
>
> lat_location = lat_wmo(0,0) ; location for 1st TC and time step
> lon_location = lon_wmo(0,0) ; location for 1st TC and time step
> nggcog(lat_location,lon_location,radius,clat,clon) ;calculate circle
>
> min_lat = min(clat)
> max_lat = max(clat)
> min_lon = min(clon)
> max_lon = max(clon)
>
>
> newTRMMyearly = AvgYearlyTRMM(0,{min_lat:max_lat},{min_lon:max_lon})
> ;reads in square of data
>
> So the above reads in the data correctly but gives me a square of data
> instead of the circle that I create with the nggcog function above since
> I'm using the min/max of the circle.
>
>
> I was wanting to know if anyone knows of a way to read in the clat/clon
> from my AvgYearlyTRMM dataset. I have attempted some indexing of the
> clat/clon varibles to put the index into AvgYearlyTRMM, but then the
> lat/lon arrays are no longer monotonic so trying to use gsn_csm_contour_map
> doesn't work.
>
>
> Thanks for any help.
> Jake
>
>
> _______________________________________________
> 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/20170814/d15a9c27/attachment.html
More information about the ncl-talk
mailing list