python - Using .mean() in numpy -


i given code , i'm familiar numpy, 1 line has me stuck looking answer.

plt.contourf(lat,lev,t.mean(0).mean(-1),extend='both') 

t 4 dimensional variable dependent on time, lat, lon, lev.

my question is, t.mean(0).mean(-1) do?

thanks!

the value passed mean specifies axis along take mean. therefore, t.mean(0) takes mean along 0th axis , returns 3d array. .mean(-1) performs mean along last axis of newly created 3d array, returning 2d array.

which conveniently ideal contourf.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -