def gradient_y(pc, cells, p):
    """
    Creates a spatial gradient along the y-axis from 0 to 1 over a patch
    of cells defined by indices.

    If p.is_ecm is True, the data is defined and returned on membrane
    midpoints, otherwise cell centres are the defining structure.

    Parameters
    ----------
    pc                 Indices of membranes
    cells              Instance of Cells module
    p                  Instance of parameters

    Returns
    ---------
    fy
        Data values from 0 to 1 defining a gradient in the y-direciton. If
        p.is_ecm == True, length of fy is number of membranes, otherwise length
        of fy is equal to cell number.
    dynamics
        Null quantity corresponding to time dynamics.
    """
    if len(pc) == len(cells.mem_i):
        y_vals_o = cells.mem_mids_flat[:, (1)]
    elif len(pc) == len(cells.cell_i):
        y_vals_o = cells.cell_centres[:, (1)]
    min_grad = y_vals_o.min()
    y_vals = y_vals_o - min_grad
    y_vals = y_vals / y_vals.max()
    y_mid = 0.5 + p.gradient_y_properties['x-offset']
    n = p.gradient_y_properties['exponent']
    grad_slope = (y_vals / y_mid) ** n / (1 + (y_vals / y_mid) ** n)
    fy = grad_slope * p.gradient_y_properties['slope'
        ] + p.gradient_y_properties['z-offset']
    dynamics = lambda t: 1
    return fy, dynamics
