Re: find grid position [lat,lon] for specfic value

From: Dave Allured - NOAA Affiliate <dave.allured_at_nyahnyahspammersnyahnyah>
Date: Wed Jan 09 2013 - 16:30:56 MST

Use the maxind function, not dim_max_n. Suppose X(lat,lon) is a 2-D
variable with coordinate variables lat and lon. The lat and lon
coordinate variables are required for this to work:

  dims = dimsizes (X)
  x1d = ndtooned (X)
  inds = ind_resolve (maxind (x1d), dims)
  ilat = inds(0,0)
  ilon = inds(0,1)
  lat_max = X&lat(ilat)
  lon_max = X&lon(ilon)
  print (lat_max + ", " + lon_max)

Example 3 on the page for the ind_resolve function is a more general
example of finding the real coordinates of grid points meeting certain
conditions. Note that extracting the real lat and lon coordinates is
just the final step, the grid indices ilat and ilon are the primary
result. HTH.

Suggestion for NCL documentation: Please add the above example to the
doc pages for minind and maxind. I think this is a common user
question.

--Dave

On Wed, Jan 9, 2013 at 4:19 AM, Ahmad Farsyud <a.farsyud@gmail.com> wrote:
> Dear NCL,
>
> How could I obtain the location [grid] for a specific value in my dataset,
> for instance i want to find grid position [lat,lon] where X(variable) equal
> to max value.
> I did try to use dim_max_n , but it gives me some indices instead of real
> grid position.
>
> Thanks for any hints.
>
> Ahmad F.
>
>
> _______________________________________________
> 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 Wed Jan 9 16:31:06 2013

This archive was generated by hypermail 2.1.8 : Mon Jan 14 2013 - 14:31:38 MST