Re: incorrect plotting of polymarkers

From: Kantave Greene <kantave.m.greene_at_nyahnyahspammersnyahnyah>
Date: Tue Nov 27 2012 - 14:17:05 MST

Thank You Mary

I now see my mistake. I was plotting indices instead of lat/lon values
which gsn_add_polymarkers uses.
That note might need to be added to that function reference.
It now works.
You guys do a great service. Keep up the good work

On 11/27/2012 10:30 AM, Mary Haley wrote:
> On Nov 26, 2012, at 3:05 PM, Kantave Greene wrote:
>
>> Hi Mary
>> I tried executing what you suggested but it returns, " Loop end must be
>> scalar, can't execute loop"
> Hi Kantave,
>
> My apologies, there's an error in the code I sent you. I should have used "lat" and "lon" and not "lat2d" and "lon2d". The "lat" and "lon" are what you read off the GRB file.
>
> Also, you already had nlat set, so remove the line:
>
>>> nlat = dimsizes(lat)
> which is wrong anyway.
>
>
>
>> I am assuming:
>> 1. that lat2d /lon2d are the variables to which grb lat/lon are read into?
> Yes, but I had typed the variable names wrong. You called them "lat" and "lon".
>
>> 2. lat_pts/lon_pts are new arrays of size nlat?
> Yes, the "new" command creates new arrays given a size and a type.
>
> But I had that wrong (not my greatest day, yesterday!) They were
> supposed to be arrays of the same size as lat_s and lon_s, because
> these are the lat/lon values you want to plot the closest locations of:
>
>
> npts = dimsizes(lat_s) ; should be 9
> lat_pts = new(npts,typeof(lat_s))
> lon_pts = new(npts,typeof(lon_s))
>
>
>> 3. lat_pts(k) and lon_pts(k) are 1D arrays of indices?
> No, lat_pts and lon_pts are 1D arrays of lat/lon values. You must pass lat/lon values
> to gsn_add_polymarker, not indexes.
>
> You used "getind_latlon2d" to get the index values of the lat/lon locations that were closest to some set of desired lat/lon values (lat_s/lon_s):
>
> nm = getind_latlon2d (lat,lon, lat_s, lon_s)
>
> nm is now a 2D array dimensioned 9 x 2, where you had 9 values in lat_s/lon_s, and the 2nd (rightmost) dimension gives you your lat /lon indexes.
>
> I then used the nm array to collect the 9 lat/lon pairs, and put them into 1D arrays called lat_pts and lon_pts. This is what you should pass to gsn_add_polymarker.
>
> --Mary
>
>
>> Based on the script i submitted I was plotting an array of lat/lon
>> indices called lat_markers and lon_markers which were derived from the
>> loop/ function getind_latlon2d.
>> Are you saying that the way I was associating the indices to the lat/lon
>> was incorrect and that is why I should use the loop you provided?
>>
>> On 11/26/2012 3:25 PM, Mary Haley wrote:
>>> I think you want to do this:
>>>
>>> nlat = dimsizes(lat)
>>> lat_pts = new(nlat,typeof(lat2d))
>>> lon_pts = new(nlat,typeof(lon2d))
>>> do k=0,nlat-1
>>> n = nm(k,0)
>>> m = nm(k,1)
>>> lat_pts(k) = lat2d(n,m)
>>> lon_pts(k) = lon2d(n,m)
>>> end do
>>>
>>> dum = gsn_add_polymarker(wks,map,lon_pts,lat_pts, mres)
>>>
>>>
>>> On Nov 26, 2012, at 10:57 AM, Kantave Greene wrote:
>>>
>>>> Hello
>>>>> I am having a problem with polymarkers being plotting incorrectly on a lambert conformal map although there indices are valid and correct. The attached image is the output from the script.
>>>>> Based on the user specified lat/lon, getind_latlon2d returns the indices which polymarker then plots. Using the following statement:
>>>>> print(n+" "+m+" "+lat(n,m)+" "+lon(n,m))
>>>>> I confirmed that the indices are returning the nearest lat/lon to the indices.
>>>>> Can you help me get the script to plot the indices correctly?
>>>>>
>>>>> Please find attached a copy of the code and output file I am using. Thanks for all your help.
>>>>>
>>>> --
>>>> Kantave Greene
>>>> Instructor
>>>> Meteorology Department
>>>> Jackson State University
>>>> P.O. Box 17660
>>>> Jackson, MS 39217
>>>> (601) 979-1293
>>>>
>>>> <plot_polygon.ncl><polygon_orig.ps>_______________________________________________
>>>> ncl-talk mailing list
>>>> List instructions, subscriber options, unsubscribe:
>>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>> --
>> Kantave Greene
>> Instructor
>> Meteorology Department
>> Jackson State University
>> P.O. Box 17660
>> Jackson, MS 39217
>> (601) 979-1293
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>

-- 
Kantave Greene
Instructor
Meteorology Department
Jackson State University
P.O. Box 17660
Jackson, MS 39217
(601) 979-1293
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Nov 27 14:17:19 2012

This archive was generated by hypermail 2.1.8 : Fri Dec 07 2012 - 13:30:06 MST