def era5_pos(lon, lat):
    """ Returns nearest location available in the ERA5 dataset corresponding to
    the given location.

    Author: Marie Schroeder

    Parameters
    ----------
    lon : float
        The longitude
    lat : float
        The latitude

    Returns
    -------
    float
        Longitude and latitude available in ERA5

    Raises
    ------
    ValueError
        When longitude or latitude are out of range
    """

    # Check input
    if abs(lat) > 90 or abs(lon) > 180:
        raise ValueError('The given coordinates ({}, {}) '.format(lon, lat) +
                         'do not fit to the available data range.')

    # Compute
    dx = 180 + lon

    # Round to 0.25
    dx = float(round(dx * 4) / 4)
    lat = float(round(lat * 4) / 4)

    return dx, lat