def piecewise_p(x, val_a=25, val_b=300, val_c=100):
    """Define piecewise p(x) function.

    The p(x) function has three values at different spatial positions.

    Keyword arguments:
    x -- spatial position to evaluate piecewise p(x)
    val_a -- first value, for x>8 and 2<x<4
    val_b -- second value, for 6<x<8
    val_c -- third value, for 4<x<6 and 0<x<2

    Returns:
    p -- the value of p at a given position x
    """
    if x > 8:
        p = val_a
    elif x > 6:
        p = val_b
    elif x > 4:
        p = val_c
    elif x > 2:
        p = val_a
    else:
        p = val_c

    return p