def _get_lon_lat(ds):
    """Return lon and lat extracted from ds."""
    try:
        lon = ds.cf['longitude']
        lat = ds.cf['latitude']
    except (KeyError, AttributeError):
        # KeyError if cfxr doesn't detect the coords
        # AttributeError if ds is a dict
        lon = ds['lon']
        lat = ds['lat']

    return lon, lat