Python Forum
Converting days to years in loop while computing values across grid cells
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Converting days to years in loop while computing values across grid cells
#2
Do you have to use loops for this task? If not I would recommend using numpy without loops.
if you have a huge amount of data this way is much much more efficient than loops in combination with numpy.
if we can say, that your data has the dimensions: timexlatitudexlongitude then you can do following:
import numpy as np
# quantity would be given at this point and is an 3-dimensional numpy array.
new_quantity = np.add.reduceat(quantity, range(0, quantity.shape[0], 365))
here is the documentation of reduceat https://docs.scipy.org/doc/numpy/referen...uceat.html
i havent tested it yet, but it may work :)
Reply


Messages In This Thread
RE: Converting days to years in loop while computing values across grid cells - by ThiefOfTime - May-15-2018, 08:17 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Cloud computing advice needed sawtooth500 3 456 Apr-18-2024, 09:23 PM
Last Post: sawtooth500
  Matplotlib scatter plot in loop with None values ivan_sc 1 2,314 Nov-04-2021, 11:25 PM
Last Post: jefsummers
  Computing the distance between each pair of points Truman 11 4,328 Jun-20-2020, 01:15 PM
Last Post: Truman
  newbie: loop, modify dataframe cells expat_th 5 3,799 Mar-03-2020, 09:05 PM
Last Post: jefsummers
  Learning python specific syntax after using other scripting languages for years Arcs 12 6,152 Dec-13-2017, 07:18 PM
Last Post: Arcs
  Error in computing FFT operation raady07 1 4,330 Jan-18-2017, 08:30 AM
Last Post: j.crater

Forum Jump:

User Panel Messages

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