def sample_at(field, x=0, y=0, point=None):
    """
    Sample from a 2D scalar field at a given coordinate; return 1 if given coordinate is out-of-bounds
    Works with either a named point argument or x and y coordinates positionally following the filed argument.
    In case all three are specified and point is not None, it will override the x and y arguments.
    :param field: field from which to sample
    :type field: numpy.ndarray
    :param x: x coordinate for sampling location
    :type x: int
    :param y: y coordinate for sampling location
    :type y: int
    :param point: full coordinate for sampling location.
    :type point: Point2d
    :return: scalar value at given coordinate if (x,y) are within bounds of the scalar field, 1 otherwise
    """
    if point is not None:
        x = point.x
        y = point.y
    if x < 0 or x >= field.shape[1] or y < 0 or y >= field.shape[0]:
        return 1
    return field[y, x]