def grid_coarse(in_grid, in_ny, in_nx, out_ny, out_nx, factor):
    """Replace a grid with one that is more coarse

        Inputs:
            in_ny -- number of input grid rows
            in_nx -- number of input grid columns
            out_ny -- number of output grid rows
            out_nx -- number of output grid columns
            factor -- input grid box length divided by output grid box length
            
    """

    out_grid = Numeric.zeros((out_ny, out_nx), in_grid.typecode())

    for j in xrange(0, out_ny):
        xjfine = float(j) * factor 
        jfine = int (float(j) * factor)
        dj = xjfine - float(jfine)
        jp1 = min(in_ny-1, jfine+1)
        jm1 = max(0, jfine-1)

        for i in xrange(0, out_nx):
            xifine = float(i) * factor
            ifine = int (float(i) * factor)
            di = xifine - float(ifine)
            ip1 = min(in_nx-1, ifine+1)

            xval = (1.-di) * (1.-dj) * in_grid[jfine, ifine] + (1.-di) * dj * in_grid[jp1, ifine] + di * (1.-dj) * in_grid[jfine, ip1] + di * dj * in_grid[jp1, ip1]
 
            out_grid[j, i] = xval
    return out_grid
Replace a grid with one that is more coarse

        Inputs:
            in_ny -- number of input grid rows
            in_nx -- number of input grid columns
            out_ny -- number of output grid rows
            out_nx -- number of output grid columns
            factor -- input grid box length divided by output grid box length
            
    
recipes/Python/414084_Extracting_low_resolutigrid_high/recipe-414084.py