I am new to this so I apologize if I am missing something. I am trying to get a probability range of a dataset with three dimensions (time, lat, lon). For 1 "cell" (single lat/lon combination), I have done the following:
# create some data
mu, sigma = 0, 0.1
s = np.random.normal(mu, sigma,900)
# get 90th - 100th percentiles
t_90x_ref= np.percentile(s, 90,interpolation="nearest")
t_100x_ref=np.percentile(s,100,interpolation="nearest")
# apply gaussian_kde function
AbnomRef_pdf= gaussian_kde(s)
# get probability range
Prob_range_90_100_Ref=AbnomRef_pdf.integrate_box_1d(t_90x_ref, t_100x_ref)*100
I would now like to repeat this exact process for each grid cell (lat/lon combination) along the time axis (with 900 timesteps,like above).
lat= np.linspace(-38.28,34.76, 167)
lon = np.linspace(143.92,207.72, 146)
# 3dim data
Anomalies_ref = np.random.rand(900, 167,146)
# get percentiles for 3 dim data
t_90x_ref= np.percentile(Anomalies_ref, 90,interpolation="nearest", axis=0)
Here is where I get stuck with the gaussian_kde function (neither a for-loop worked, nor was I able to flatten the gaussian_kde results). I have seen this case Using scipy.stats.gaussian_kde with 2 dimensional data but can`t really apply it to my problem.Ultimately, my goal is to get a Prob_range_90_100_Ref with shape (167,146)
Any help would be very much appreciated!
Thanks!