i found multiple discussions, but not the solution I’m looking for.
I have multiple Time,level, Lat, lon datafiles (Modeloutput). Now i want to calculate the Anomaly e.g. from Temp.
My Idea was to do that, by moveing averages. It is easy and fast… currently i struggle with the averages.
In python the moving averages can be compute like that:
window_size = 3
i = 0
Initialize an empty list to store moving averages
moving_averages = []
Loop through the array to consider
every window of size 3
while i < len(arr) - window_size + 1:
Store elements from i to i+window_size
in list to get the current window
window = arr[i : i + window_size]
Calculate the average of current window
window_average = round(sum(window) / window_size, 2)
Store the average of current
window in moving average list
moving_averages.append(window_average)
Shift window to right by one position
i += 1
print(moving_averages)
so… if i have a list of data:
file =[ file1, file2, .., , n]
with file.variable[‘T’][:,:,:,:] how i can compute the averages over time and calc afterwards the anomalie by T[time,:,:,:] – avarage_T[on 850hPa pressure field]?