def ESAcloudMask(img):
    """
    European Space Agency (ESA) clouds from 'QA60', i.e. Quality Assessment band at 60m

    parsed by Nick Clinton

    Parameters
    ----------
    img : gee.image.Image
        Sentinel-2 Image for which the cloud mask should be calculated

    Returns
    -------
    img : gee.image.Image
        Sentinel-2 image with cloud score as extra band
    """
    qa = img.select('QA60')
    cloudBitMask = int(2 ** 10)
    cirrusBitMask = int(2 ** 11)
    clear = qa.bitwiseAnd(cloudBitMask).eq(0).And(qa.bitwiseAnd(
        cirrusBitMask).eq(0))
    cloud = clear.Not().rename(['ESA_clouds'])
    return img.addBands(cloud)
