Re: Zooming in on map and calculating

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Thu Aug 30 2012 - 11:57:31 MDT

Correction to T_sub line. It should be:

> T_sub = T(loc(1,0):loc(1,1),loc(0,0):loc(0,1)) ; Subscripted over desired lat/lon range

On Aug 30, 2012, at 11:17 AM, Mary Haley wrote:

> Hi Chris,
>
> The thing you have to be careful with on wrf_user_ll_to_ij is that you subtract 1 from the return values, because the indexes returned are for Fortran indexing (1 to n), whereas NCL uses 0 to n-1 for indexing.
>
> Also, the lefmost value (loc(0,:)) returned from this function is for the longitude index, and the rightmost (ij(1,:)) is for the latitude index.
>
> Your code should look something like this (untested)
>
> minlat = 40
> maxlat = 56
> minlon = 117
> maxlon = 137
>
> opt = True
> loc = wrf_user_ll_to_ij(a,(/minlon,maxlon/),(/minlat,maxlat/),opt)
> loc = loc-1 ; To convert to NCL indexes
>
> ;---These values should be close
> print("Requested min/max xlon = " + minlon + "/" + maxlon)
> print("Calculated min/max xlon = " + xlon(loc(1,0),loc(0,0)) + "/" + \
> xlon(loc(1,1),loc(0,1)))
>
> print("Requested min/max xlat = " + minlat + "/" + maxlat)
> print("Calculated min/max xlat = " + xlat(loc(1,0),loc(0,0)) + "/" + \
> xlat(loc(1,1),loc(0,1)))
>
> Remember that xlat and xlon are dimensioned lat x lon, so you have to use the latitude index in the leftmost position of the xlat/xlon array, and the longitude index in the rightmost position. I know this can get very confusing!
>
> Use "loc" to subscript your data array in the same way. For example if "T" is a 4D array on the file:
>
> T = a->T(0,0,:,:) ; first timestep and level
> T_sub = T(loc(1,0):loc(1,1),loc(0,0):loc(1,1)) ; Subscripted over desired lat/lon range
>
>
> If you continue to have problems with this, would you be able to provide your script and data? Please see this URL for ftp information:
>
> http://www.ncl.ucar.edu/report_bug.shtml#HowToFTP
>
> You can just email me with the information, if you don't want to email the whole list. I will post back to ncl-talk if there's an answer.
>
> --Mary
>
> On Aug 30, 2012, at 9:30 AM, Chris Klich wrote:
>
>> Hi all,
>>
>> I am currently plotting variables and calculations using WRF model output, however, I am using normal NCL functions. I am plotting 3 separate domains, however, I am plotting them zoomed in, so they all cover the same exact area. For example, for domains 1, 2, and 3, I have the following in the resources:
>>
>> opts@mpLimitMode = "LatLon"
>> opts@mpMinLatF = 40.
>> opts@mpMaxLatF = 56.
>> opts@mpMinLonF = 117.
>> opts@mpMaxLonF = 137.
>>
>> This zooms in fine. However, I would like to calculate a variable specifically within this zoomed region. It does not have to be exact, but I've tried every combination of lat/lon and i/j starting and ending points, and can't seem to get a "box" that fits almost perfectly within the zoomed area. I used wrf_user_ll_to_ij to try and convert the zoomed in lats and lons to i,j locations for whichever domain I am using, in order to try and get the area I want. However, when I plot a "box" to see if it is roughly the size of the plot, it is not very close at all. The bulk of my script is the following:
>>
>> i_start = 69
>> i_end = 100
>>
>> j_start = 52
>> j_end = 94
>>
>> lon_ll = xlon(j_start,i_start)
>> lat_ll = xlat(j_start,i_start)
>> lon_lr = xlon(j_start,i_end)
>> lat_lr = xlat(j_start,i_end)
>> lon_ur = xlon(j_end,i_end)
>> lat_ur = xlat(j_end,i_end)
>> lon_ul = xlon(j_end,i_start)
>> lat_ul = xlat(j_end,i_start)
>>
>> print("Lower Left: " + lon_ll + ", " + lat_ll)
>> print("Lower Right: " + lon_lr + ", " + lat_lr)
>> print("Upper Right: " + lon_ur + ", " + lat_ur)
>> print("Upper Left: " + lon_ul + ", " + lat_ul)
>>
>> lnres = True
>> lnres@gsLineThicknessF = 3.0
>> lnres@gsLineColor = "Black"
>> xbox = (/ lon_ll, lon_lr, lon_ur, lon_ul, lon_ll /)
>> ybox = (/ lat_ll, lat_lr, lat_ur, lat_ul, lat_ll /)
>> gsn_polyline(wks, plot, xbox, ybox, lnres)
>>
>> This may seem like a roundabout way of doing this, but in the end, I would like to be able to draw a box, and calculate values specifically within that box. The "box" and plot that results is the following: http://fuelberg.met.fsu.edu/pub/cklich/ . I understand the zoom-in portion of the script just plots the min and max lat/lon, I am just unsure how to get the exact i,j locations of the 4 corners of the area.
>>
>> Thank you,
>> Chris
>> _______________________________________________
>> 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

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Aug 30 11:57:41 2012

This archive was generated by hypermail 2.1.8 : Tue Sep 11 2012 - 15:30:42 MDT