import copy


def get_midpoint_radius(pos):
    """Return the midpoint and radius of the hex maze as a tuple (x,y), radius.

    Params
    ======
    pos: PositionArray
        nelpy PositionArray containing the trajectory data.

    Returns
    =======
    midpoint: (x0, y0)
    radius: float
    """
    # make a local copy of the trajectory data
    local_pos = copy.copy(pos)

    # merge the underlyng support to make computations easier
    local_pos._support = pos.support.merge(gap=10)

    # apply smoothing to tame some outliers:
    local_pos = local_pos.smooth(sigma=0.02)

    midpoint = local_pos.min() + (local_pos.max() - local_pos.min())/2
    radius = ((local_pos.max() - local_pos.min())/2).mean()

    return midpoint, radius