You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Test efficient calculation of information entropy with masked arrays
# Step 1: load previously calculated results
importpickleimportnumpyasnp
ua=pickle.load(open("gipps_results.pkl"))
# cast probabilities into numpy arrayua.p_block=np.array(ua.p_block)
defie_standard(ua):
# test standard way to calculate information entropy with nested blocks:# calculate information entropy and store in self.e_blocke_block=np.zeros_like(ua.p_block[1])
forp_blockinua.p_block:
foriinrange(ua.nx):
forjinrange(ua.ny):
forkinrange(ua.nz):
ifp_block[i, j, k] >0:
e_block[i, j, k] -=p_block[i, j, k] *np.log2(p_block[i, j, k])
returne_block