Re: find location of max along a center line

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed Nov 10 2010 - 14:25:38 MST

   g420 = GRNHX(:,420,:) ; gwork(t,x) dimension #s 0 and 1
   printVarSummary(g420)
                                ; at each time find the max value
   gmax = dim_max_n( g420, 1) ; gmax(t)

   dimg = dimsizes(gmax) ; ntim
   nx = new ( dimg(0), "integer")
   do nt=0,dimg(0)-1
      n = ind(g420(nt).eq.gmax(nt))
      if (.not.ismissing(n)) then
          nx(nt) = n(0) ; save the 1st instance
      end if
      delete(n) ; may change next iteration
   end do
   print(nx)

There are issues ...
What if there are multiple values = the max value ?
The above would only use the 1st instance.

On 11/10/2010 12:33 PM, Kara Yedinak wrote:
> Hi Dennis,
>
> I can see how that is unclear. I am looking for the physical
> location of the occurrence of a maxima
>
> I have used:
>
> g420 = GRNHX(:,420,:) ; gwork(t,x) dimension #s 0 and 1
> printVarSummary(g420)
> ; at each time find the max value
> gmax = dim_max_n( g420, 1) ; gmax(t)
>
> Which returns the value (magnitude) of the maximum. I am hoping to find
> the location of this maximum magnitude. I have not seen the command
> dim_max_n_Wrap before. I just tried searching for it on the main NCL
> page and could not find it. If you think this is the tool I need, would
> you mind pointing me in the right direction?
>
> Thanks,
> Kara
>
> On Wed, Nov 10, 2010 at 11:26 AM, Dennis Shea <shea@ucar.edu
> <mailto:shea@ucar.edu>> wrote:
>
> Hi Kara
>
> It is not clear what you want. When you say
> "maximum value location (x)"
> Do you mean the index (subscript) at which
> the max value occurs? Or, do you want the max value?
> Something like ...
>
>
> g420 = GRNHX(:,420,:) ; gwork(t,x) dimension #s 0 and 1
> printVarSummary(g420)
> ; at each time find the max value
> gmax = dim_max_n( g420, 1) ; gmax(t)
> or
> gmax = dim_max_n_Wrap( g420, 1) ; contributed.ncl
>
> print(gmax)
>
>
>
> On 11/10/2010 12:07 PM, Kara Yedinak wrote:
>
> Hello all,
>
> I would like to read in a 3D variable GRNHX(t,y,x) and find the
> maximum value location (x) along y=420 for each time step.
> dim_max_n
> returns the maximum value of GRNHX as a fxn of x and t, but over ALL
> values of y. Likewise performing dim_max_n on GRNHX(t,420,x)
> returns
> the maximum value of GRNHX as a fxn of t only. Anyone have an
> idea how
>
>
>
>
> --
> Absence of evidence is not evidence of absence. Carl Sagan

-- 
======================================================
Dennis J. Shea                  tel: 303-497-1361    |
P.O. Box 3000                   fax: 303-497-1333    |
Climate Analysis Section                             |
Climate & Global Dynamics Div.                       |
National Center for Atmospheric Research             |
Boulder, CO  80307                                   |
USA                        email: shea 'at' ucar.edu |
======================================================
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Nov 10 14:25:43 2010

This archive was generated by hypermail 2.1.8 : Mon Nov 15 2010 - 08:55:22 MST