May-15-2018, 04:38 PM
Greetings,
Using a for loop, I recently tried to compute the maximum values across grid cells (which are composed of 64 degrees latitude and 128 degrees longitude), which are part of a 3D matrix (the variable called "Quantity" below). However, I am not sure what is the best way to do this. This matrix is composed of the elements of time, latitude, longitude. Time is given in units of days, but I would like to use units of years in the for loop. Also, how would you construct the for loop to compute all maximum values for every year for every grid cell?
To give an idea of what I mean, here is how I started my loop, but I am uncertain how to finish it to include every year (***remember that the default time units is in days***). Ultimately, I would like to compute all maximum ***annual*** values (I already imported numpy as np to use the max () function) across every latitude and longitude for every year available (140 years, which is, by default expressed as 51100 days). So, the idea is to go from year 0 to year 139, getting the loop to compute all maximum values across every grid cell.
Here is what I have:
I think that is the right way to start, but how would you finish that loop to include time (to be expressed in years)?
Any help would be greatly appreciated!!!
Using a for loop, I recently tried to compute the maximum values across grid cells (which are composed of 64 degrees latitude and 128 degrees longitude), which are part of a 3D matrix (the variable called "Quantity" below). However, I am not sure what is the best way to do this. This matrix is composed of the elements of time, latitude, longitude. Time is given in units of days, but I would like to use units of years in the for loop. Also, how would you construct the for loop to compute all maximum values for every year for every grid cell?
To give an idea of what I mean, here is how I started my loop, but I am uncertain how to finish it to include every year (***remember that the default time units is in days***). Ultimately, I would like to compute all maximum ***annual*** values (I already imported numpy as np to use the max () function) across every latitude and longitude for every year available (140 years, which is, by default expressed as 51100 days). So, the idea is to go from year 0 to year 139, getting the loop to compute all maximum values across every grid cell.
Here is what I have:
1 2 3 4 5 |
Quantity = Q for lat in range (np.size(Quantity,axis = 1 )): for lon in range (np.size(Quantity,axis = 2 )): Quantity[:,lat,lon] |
Any help would be greatly appreciated!!!