Python Forum
Looping in a 3D matrix - desperate for assistance!
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Looping in a 3D matrix - desperate for assistance!
#1
Hi there,

I would like to compute all annual maximum values in a 3D matrix using a for loop. To be more specific, the variable "Quantity" is a 3D matrix that is composed of latitude and longitude (both make up latitude and longitude grid cells) and time (expressed in days).

What I would like to do is compute all maximum values by looping all latitudes, all longitudes, and then loop all years in the period. This is done to obtain all maximum values over every grid cell (i.e. composed of latitude and longitude) for every year available (the default time units of "days" must also be converted to "years"), beginning with year 0.

My question is how should I construct a loop to do this? I realize that I would need to use the max() function, but I am uncertain where to use it in the loop.

This is what I have so far:


Quantity=Q

        for lat in range(np.size(Quantity,axis=1)):
                for lon in range(np.size(Quantity,axis=2)):
                        Quantity[:,lat,lon]
How do I account for time in the loop, and convert days to years, so that I may obtain maximum "annual" values for every grid cell?

Thanks, and any assistance would be greatly appreciated!!!!
Reply


Messages In This Thread
Looping in a 3D matrix - desperate for assistance! - by Lightning1800 - May-14-2018, 08:32 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Need desperate help needHelpp 2 2,626 Aug-06-2017, 06:02 PM
Last Post: eyn2k

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020