This question already has an answer here:
I want to perform raster smoothing on a DEM file. I want to to assign the elevation of each pixel using the average elevations of its 8 neighbors. The ESRI's "Python scripting for ArcGIS" has a chapter on using python for raster but it did not help me to write a code for this. I'm looking for any useful literature, tutorial, or sample code...! please note that r.buffer and r.neighbors is not a good answer for me since I want to learn how to write this code completely.