(inputs)
return im_dict_T1, im_dict_T2
Create the structure of subfolders for each satellite mission

    KV WRL 2018

    Arguments:
    -----------
    inputs: dict
        inputs dictionnary

    Returns:
    -----------
    im_dict_T1: list of dict
        list of images in Tier 1 and Level-1C
    im_dict_T2: list of dict
        list of images in Tier 2 (Landsat only)
Create the structure of subfolders for each satellite mission
Create the structure of subfolders for each satellite mission
def check_images_available(inputs):
    """
    Create the structure of subfolders for each satellite mission

    KV WRL 2018

    Arguments:
    -----------
    inputs: dict
        inputs dictionnary

    Returns:
    -----------
    im_dict_T1: list of dict
        list of images in Tier 1 and Level-1C
    im_dict_T2: list of dict
        list of images in Tier 2 (Landsat only)
    """

    # check if dates are in correct order
    dates = [datetime.strptime(_,'%Y-%m-%d') for _ in inputs['dates']]
    if  dates[1] <= dates[0]:
        raise Exception('Verify that your dates are in the correct order')

    # check if EE was initialised or not
    try:
        ee.ImageCollection('LANDSAT/LT05/C01/T1_TOA')
    except:
        ee.Initialize()

    print('Images available between %s and %s:'%(inputs['dates'][0],inputs['dates'][1]), end='\n')
    # check how many images are available in Tier 1 and Sentinel Level-1C
    col_names_T1 = {'L5':'LANDSAT/LT05/C01/T1_TOA',
                 'L7':'LANDSAT/LE07/C01/T1_TOA',
                 'L8':'LANDSAT/LC08/C01/T1_TOA',
                 'S2':'COPERNICUS/S2'}

    print('- In Landsat Tier 1 & Sentinel-2 Level-1C:')
    im_dict_T1 = dict([])
    sum_img = 0
    for satname in inputs['sat_list']:

        # get list of images in EE collection
        while True:
            try:
                ee_col = ee.ImageCollection(col_names_T1[satname])
                col = ee_col.filterBounds(ee.Geometry.Polygon(inputs['polygon']))\
                            .filterDate(inputs['dates'][0],inputs['dates'][1])
                im_list = col.getInfo().get('features')
                break
            except:
                continue
        # remove very cloudy images (>95% cloud cover)
        im_list_upt = remove_cloudy_images(im_list, satname)
        sum_img = sum_img + len(im_list_upt)
        print('  %s: %d images'%(satname,len(im_list_upt)))
        im_dict_T1[satname] = im_list_upt

    print('  Total: %d images'%sum_img)

    # in only S2 is in sat_list, stop here
    if len(inputs['sat_list']) == 1 and inputs['sat_list'][0] == 'S2':
        return im_dict_T1, []

    # otherwise check how many images are available in Landsat Tier 2
    col_names_T2 = {'L5':'LANDSAT/LT05/C01/T2_TOA',
                 'L7':'LANDSAT/LE07/C01/T2_TOA',
                 'L8':'LANDSAT/LC08/C01/T2_TOA'}
    print('- In Landsat Tier 2:', end='\n')
    im_dict_T2 = dict([])
    sum_img = 0
    for satname in inputs['sat_list']:
        if satname == 'S2': continue
        # get list of images in EE collection
        while True:
            try:
                ee_col = ee.ImageCollection(col_names_T2[satname])
                col = ee_col.filterBounds(ee.Geometry.Polygon(inputs['polygon']))\
                            .filterDate(inputs['dates'][0],inputs['dates'][1])
                im_list = col.getInfo().get('features')
                break
            except:
                continue
        # remove very cloudy images (>95% cloud cover)
        im_list_upt = remove_cloudy_images(im_list, satname)
        sum_img = sum_img + len(im_list_upt)
        print('  %s: %d images'%(satname,len(im_list_upt)))
        im_dict_T2[satname] = im_list_upt

    print('  Total: %d images'%sum_img)

    return im_dict_T1, im_dict_T2
def check_images_available ( inputs ) : # check if dates are in correct order dates = [ datetime . strptime ( _ , '%Y-%m-%d' ) for _ in inputs [ 'dates' ] ] if dates [ 1 ] <= dates [ 0 ] : raise Exception ( 'Verify that your dates are in the correct order' ) # check if EE was initialised or not try : ee . ImageCollection ( 'LANDSAT/LT05/C01/T1_TOA' ) except : ee . Initialize ( ) print ( 'Images available between %s and %s:' % ( inputs [ 'dates' ] [ 0 ] , inputs [ 'dates' ] [ 1 ] ) , end = '\n' ) # check how many images are available in Tier 1 and Sentinel Level-1C col_names_T1 = { 'L5' : 'LANDSAT/LT05/C01/T1_TOA' , 'L7' : 'LANDSAT/LE07/C01/T1_TOA' , 'L8' : 'LANDSAT/LC08/C01/T1_TOA' , 'S2' : 'COPERNICUS/S2' } print ( '- In Landsat Tier 1 & Sentinel-2 Level-1C:' ) im_dict_T1 = dict ( [ ] ) sum_img = 0 for satname in inputs [ 'sat_list' ] : # get list of images in EE collection while True : try : ee_col = ee . ImageCollection ( col_names_T1 [ satname ] ) col = ee_col . filterBounds ( ee . Geometry . Polygon ( inputs [ 'polygon' ] ) ) . filterDate ( inputs [ 'dates' ] [ 0 ] , inputs [ 'dates' ] [ 1 ] ) im_list = col . getInfo ( ) . get ( 'features' ) break except : continue # remove very cloudy images (>95% cloud cover) im_list_upt = remove_cloudy_images ( im_list , satname ) sum_img = sum_img + len ( im_list_upt ) print ( '  %s: %d images' % ( satname , len ( im_list_upt ) ) ) im_dict_T1 [ satname ] = im_list_upt print ( '  Total: %d images' % sum_img ) # in only S2 is in sat_list, stop here if len ( inputs [ 'sat_list' ] ) == 1 and inputs [ 'sat_list' ] [ 0 ] == 'S2' : return im_dict_T1 , [ ] # otherwise check how many images are available in Landsat Tier 2 col_names_T2 = { 'L5' : 'LANDSAT/LT05/C01/T2_TOA' , 'L7' : 'LANDSAT/LE07/C01/T2_TOA' , 'L8' : 'LANDSAT/LC08/C01/T2_TOA' } print ( '- In Landsat Tier 2:' , end = '\n' ) im_dict_T2 = dict ( [ ] ) sum_img = 0 for satname in inputs [ 'sat_list' ] : if satname == 'S2' : continue # get list of images in EE collection while True : try : ee_col = ee . ImageCollection ( col_names_T2 [ satname ] ) col = ee_col . filterBounds ( ee . Geometry . Polygon ( inputs [ 'polygon' ] ) ) . filterDate ( inputs [ 'dates' ] [ 0 ] , inputs [ 'dates' ] [ 1 ] ) im_list = col . getInfo ( ) . get ( 'features' ) break except : continue # remove very cloudy images (>95% cloud cover) im_list_upt = remove_cloudy_images ( im_list , satname ) sum_img = sum_img + len ( im_list_upt ) print ( '  %s: %d images' % ( satname , len ( im_list_upt ) ) ) im_dict_T2 [ satname ] = im_list_upt print ( '  Total: %d images' % sum_img ) return im_dict_T1 , im_dict_T2