Re: zooming in on a map plot

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Thu Nov 08 2012 - 09:06:59 MST

Hi Nicole,

The WRF plotting functions have a special ZoomIn map parameter that allows you to zoom.
Even though you are not using wrf plotting functions, I think you can still use the
basic concept behind this parameter.

First, you need to call wrf_user_ll_to_ij to get the the i,j indexes of the area you want to zoom in on
You then use these i,j indexes to subscript your data.

Here's an example code snippet that zooms in on an area with 20N, 90W at the southwest corner and 30N, 80W at the NE corner:

  lats = (/ 20.0, 30.0 /)
  lons = (/ -93.0, -80.0 /)
  loc = wrf_user_ll_to_ij(a, lons, lats, True)
;
; loc(0,;) is west-east (x) ; loc(1,:) is south-north (y)
; subtract one since we want to use it as an index in NCL
;
  x1 = loc(0,0) - 1
  x2 = loc(0,1) - 1
  y1 = loc(1,0) - 1
  y2 = loc(1,1) - 1

Then, when you set your resources and plot your data, you will also need this:

  res@mpLeftCornerLatF = lat(y1,x1)
  res@mpLeftCornerLonF = lon(y1,x1)
  res@mpRightCornerLatF = lat(y2,x2)
  res@mpRightCornerLonF = lon(y2,x2)

This is assuming you have read "XLONG" and "XLAT" off the file into local variables "lon" and "lat".
You can call these whatever you want.

Finally, you need to subscript your data and plot "data_zoom" instead of "data":

  data_zoom = data(y1:y2,x1:x2) ; create a zoomed area

Hope this helps,

--Mary

On Nov 7, 2012, at 7:25 PM, Schiffer, Nicole June wrote:

> I'm not using the wrf plotting functions because I got frustrated with all
> the user-friendly features (kind of like Python).
>
> I was afraid those were my only two options. Oh well. Thanks for
> entertaining my question.
>
> -Nicole
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> * Nicole Schiffer
> * Science Writing Intern (NCSA)
> * Graduate Research Fellow (Dept. of Energy)
> * Department of Atmospheric Sciences
> * University of Illinois, Urbana-Champaign
> * Email: nschiff2 [at] illinois [dot] edu
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
>
>
>
> "Adam Phillips", 11/7/12 5:04 PM:
>
>> Hi Nicole,
>> If it didn't work for your WRF data I assume you are using the various
>> WRF plotting functions to create the plots. The wrf* routines set a lot
>> of things up automatically for you behind the scenes, which is
>> convenient if you're happy with how they set things up. However, it
>> sometimes is not the easiest to alter settings with regards to the wrf*
>> routines. I do not regularly plot WRF data, but I do not know of a way
>> to automatically zoom in on a region while using the wrf* plotting
>> routines.
>>
>> I think your two options are:
>> 1) subset the data using region_ind (which I know you'd rather not do):
>> http://www.ncl.ucar.edu/Document/Functions/Contributed/region_ind.shtml
>> 2) Attach your 2D lat/lons as attributes to the array to be plotted, and
>> create your plot using regular NCL plotting functions
>> (gsn_csm_contour_map for example).. See here:
>> http://www.ncl.ucar.edu/Applications/wrf.shtml
>>
>> Adam
>>
>>
>>
>> On 11/07/2012 03:20 PM, Schiffer, Nicole June wrote:
>>> That works fine for TRMM data, but it seems to smash all of the WRF data
>>> into a window of that size rather than lining it up with the proper
>>> lat-lon values. Do I need to set another resource for WRF to work?
>>>
>>> Thanks,
>>> Nicole
>>>
>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>> * Nicole Schiffer
>>> * Science Writing Intern (NCSA)
>>> * Graduate Research Fellow (Dept. of Energy)
>>> * Department of Atmospheric Sciences
>>> * University of Illinois, Urbana-Champaign
>>> * Email: nschiff2 [at] illinois [dot] edu
>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>
>>>
>>>
>>>
>>>
>>> "Adam Phillips", 11/7/12 4:08 PM:
>>>
>>>> Hi Nicole,
>>>> You can usually do this by setting mpLimitMode along with a few
>>>> complimentary resources. For instance:
>>>>
>>>> res@mpLimitMode = "LatLon"
>>>> res@mpMinLonF = 130.
>>>> res@mpMaxLonF = 220.
>>>> res@mpCenterLonF = (res@mpMinLonF+res@mpMaxLonF)/2.
>>>> res@mpMinLatF = 20.
>>>> res@mpMaxLatF = 75.
>>>>
>>>> See:
>>>>
>>>> http://www.ncl.ucar.edu/Document/Graphics/Resources/mp.shtml#mpLimitMode
>>>>
>>>> Hope that helps! Adam
>>>>
>>>> On 11/07/2012 02:27 PM, Schiffer, Nicole June wrote:
>>>>> Is there a way to zoom in on a map plot without plotting only a subset
>>>>> of
>>>>> the data or masking the data?
>>>>>
>>>>> Masking shows only the data I want, but it doesn't fill the whole plot
>>>>> window. Plotting a subset of the data is not trivial, but is doable
>>>>> if I
>>>>> can't just limit the bounds of the plot.
>>>>>
>>>>> Thanks,
>>>>> Nicole
>>>>>
>>>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>>> * Nicole Schiffer
>>>>> * Science Writing Intern (NCSA)
>>>>> * Graduate Research Fellow (Dept. of Energy)
>>>>> * Department of Atmospheric Sciences
>>>>> * University of Illinois, Urbana-Champaign
>>>>> * Email: nschiff2 [at] illinois [dot] edu
>>>>> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> ncl-talk mailing list
>>>>> List instructions, subscriber options, unsubscribe:
>>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>> --
>>>> ______________________________________________________________
>>>> Adam Phillips asphilli@ucar.edu
>>>> NCAR/Climate and Global Dynamics Division (303) 497-1726
>>>> P.O. Box 3000
>>>> Boulder, CO 80307-3000 http://www.cgd.ucar.edu/cas/asphilli
>>>>
>>>> _______________________________________________
>>>> 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
>>
>> --
>> ______________________________________________________________
>> Adam Phillips asphilli@ucar.edu
>> NCAR/Climate and Global Dynamics Division (303) 497-1726
>> P.O. Box 3000
>> Boulder, CO 80307-3000 http://www.cgd.ucar.edu/cas/asphilli
>>
>> _______________________________________________
>> 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 Nov 8 09:07:15 2012

This archive was generated by hypermail 2.1.8 : Tue Nov 13 2012 - 14:27:24 MST