# Re: wrf_user_ll_to_ij function

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Tue Nov 12 2013 - 13:31:29 MST

Hi Xin,

When you use "where", you will get all the lat/lon points that fall within the region you've defined.

When you use wrf_user_ll_to_ij, it's just giving you the location of the two min points, and the location of the two max points in the array. When you subscript the array with these indexes, the points in this range don't necessarily represent every point in the range, but rather a rectangular box. And, in fact, this rectangular box may give you values outside your range.

A graphic is the best way to show this. The attached graphic shows a full WRF lat/lon grid on the top, and then the two bottom plots show the two different subsetting methods, where the navy blue points represent the min/max lat and lon.

--Mary

On Nov 11, 2013, at 9:27 PM, Xin Xi <xxi@gatech.edu> wrote:

> Hello,
> I have a 2D field X from WRF with coordinates lat2d and lon2d. I want to calculate the sum of subset of X within lat/lon bounds of (min_lat, max_lat) and (min_lon, max_lon). I tried two different ways, which I expected the same results but they turn out to be different. Which is the correct way?
>
> method 1:
> X=where(lat2d.lt.min_lat .or. lat2d.gt.max_lat .or. \
> lon2d.lt.min_lon.or.lon2d.gt.max_lon, 0, X)
> sum_X=sum(X)
> (in fact, the original X is missing value outside the lat/lon bounds, I use the where function just for precaution).
>
> method 2:
> opt=True
> loc=wrf_user_ll_to_ij(geo_file,(/min_lon,max_lon/),(/min_lat,max_lat/),opt)
> loc=loc-1
> subsetX=X(loc(1,0):loc(1,1) , loc(0,0):loc(0,1))
> sum_X=sum(subsetX)
>
> The sum_X from method 2 is a lot smaller than method 1. Is it because wrf_user_ll_to_ij loses some grids at the bounds?
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Nov 12 13:31:45 2013

This archive was generated by hypermail 2.1.8 : Fri Nov 22 2013 - 09:36:32 MST