Re: create array of max value in vertical for multi-dimensional array

From: Dave Allured <dave.allured_at_nyahnyahspammersnyahnyah>
Date: Mon Jan 09 2012 - 23:28:57 MST

So you are inside a loop over jj, and you want to repeat this
calculation for each jj? In other words, you want a 2-D result, but
you want to repeat that 2-D result for the number of time steps?

If so, I think you want this inside the time loop. Note that maxZ will
be overwritten with new values on each iteration:

dim_level = 1
maxZ = dim_max_n (x (jj,0:29,:,:), dim_level)

Or perhaps this would be simpler if you are not really trying to
constrain to the first 30 levels:

dim_level = 1
maxZ = dim_max_n (x (jj,:,:,:), dim_level)



On Mon, Jan 9, 2012 at 10:14 PM, Chris Herbster <> wrote:
> Hi folks,
> I may have tried the wrong search terms while looking for this in the
> archives, but perhaps I can get a quick solution to my quest.
> I would like to obtain the max value at each horizontal point in a
> multi-dimensional array for each time.
> The array is x(time,level,lat,lon) and I am looking for the max value
> for a given time (set with an index value) for each lat/lon location.
> Obviously when I use the max function on the array I get a scalar
> result.  I'd like the scalar result for each location in the horizontal.
> I want to obtain a 2D array out of a 4D array, but I have a loop (on jj)
> that sets the time element to a specific index.  I tried:
> maxZ(:,:) = max (x (jj,0:29,:,:)
>     where jj is a loop over the 24 hours, the second index is Z, the
> range I want the max value out of, and the last two are the lat and long
> index values.
> That gave an error about maxZ not existing.  Is the fix as simple as
> creating the array with the correct dimensions?
> Of course when I tried to do this without an index placeholder then maxZ
> is a scalar and I can't plot that on a map.
> I'm almost certain there is a way to do this without having nested loops
> on the x and y variables.
> Thanks for the help!
> Chris Herbster
> --
>  Dr. Christopher G. Herbster
>  Associate Professor
>  Director of Science and Technology
>  for the ERAU Weather Center
>  Applied Aviation Sciences
>  Embry-Riddle Aeronautical Univ.
>  600 S. Clyde Morris Blvd.
>  Daytona Beach, FL 32114-3900
>  386.226.6444 Office
>  386.226.6446 Weather Center
> Schedule at:
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
Received on Mon Jan 9 23:29:07 2012

This archive was generated by hypermail 2.1.8 : Wed Jan 18 2012 - 09:21:55 MST