I would like to add thousands of 4D arrays element wise and accounting for nans. A simple example using 1D arrays would be:
X = array([4,7,89,nan,89,65, nan])
Y = array([0,5,4, 9, 8, 100,nan])
z = X+Y
print z = array([4,12,93,9,97,165,nan])
I've written a simple for loop around this but it takes forever - not a smart solution. Another solution could be creating a larger array and use bottleneck nansum but this would take too much memory for my laptop. I need a running sum over 11000 cases.
Does anyone have a smart and fast way to do this?