def com_find(ar_grid):
f_x = <NUM_LIT:0><EOL>f_y = <NUM_LIT:0><EOL>f_m = <NUM_LIT:0><EOL>for i in range(len(ar_grid)):<EOL><INDENT>for j in range(len(ar_grid[i])):<EOL><INDENT>if ar_grid[i][j]:<EOL><INDENT>f_x += (j+<NUM_LIT:1>) * ar_grid[i][j]<EOL>f_y += (i+<NUM_LIT:1>) * ar_grid[i][j]<EOL>f_m += ar_grid[i][j]<EOL><DEDENT><DEDENT><DEDENT>f_com = array( (float(f_x)/f_m , float(f_y)/f_m) )<EOL>return f_com<EOL>
Find the center of mass in array grid <ar_grid>. Mass elements
are grid index values.

Return an array, in format (x, y), i.e. col, row!