import os
import numpy as np
import matplotlib.pyplot as plt
import boto3
import rasterio
from rasterio.windows import Window
from rasterio.session import AWSSession
import ee
ee.Authenticate()
# Initialize the library.
ee.Initialize()

To authorize access needed by Earth Engine, open the following URL in a web browser and follow the instructions:

<a href=https://accounts.google.com/o/oauth2/auth?client_id=517222506229-vsmmajv00ul0bs7p89v5m89qs8eb9359.apps.googleusercontent.com&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fearthengine+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdevstorage.full_control&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&code_challenge=TuJeYhWcqy2cLQKd8ga6_lJxxu5U1tkfOW-Sqk9xPTc&code_challenge_method=S256>https://accounts.google.com/o/oauth2/auth?client_id=517222506229-vsmmajv00ul0bs7p89v5m89qs8eb9359.apps.googleusercontent.com&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fearthengine+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdevstorage.full_control&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&code_challenge=TuJeYhWcqy2cLQKd8ga6_lJxxu5U1tkfOW-Sqk9xPTc&code_challenge_method=S256</a>

The authorization workflow will generate a code, which you should paste in the box below

Successfully saved authorization token.
table = ee.FeatureCollection("users/robeson1010/zhongguo")
table=table.filterMetadata('id','equals','Hainan')
table=table.toList(1).get(0)
sar=ee.ImageCollection('COPERNICUS/S1_GRD').filter(ee.Filter.eq('transmitterReceiverPolarisation', ["VV","VH"])).filterDate('2017-01-01','2017-12-31').filterBounds(ee.Feature(table).geometry()).filterMetadata('orbitProperties_pass','equals','ASCENDING').filterMetadata('relativeOrbitNumber_start','equals',157).sort('system:time_start', True);

Get datalist from GEE

ll=sar.aggregate_array('system:index').getInfo()
ll
['S1A_IW_GRDH_1SDV_20170109T104832_20170109T104901_014754_018052_647B',
 'S1A_IW_GRDH_1SDV_20170109T104901_20170109T104926_014754_018052_C602',
 'S1A_IW_GRDH_1SDV_20170121T104831_20170121T104900_014929_0185D0_A6F6',
 'S1A_IW_GRDH_1SDV_20170121T104900_20170121T104925_014929_0185D0_BEBC',
 'S1A_IW_GRDH_1SDV_20170202T104831_20170202T104900_015104_018B17_2A64',
 'S1A_IW_GRDH_1SDV_20170202T104900_20170202T104925_015104_018B17_33D9',
 'S1A_IW_GRDH_1SDV_20170214T104831_20170214T104900_015279_0190A0_2E30',
 'S1A_IW_GRDH_1SDV_20170214T104900_20170214T104925_015279_0190A0_023E',
 'S1A_IW_GRDH_1SDV_20170226T104831_20170226T104900_015454_0195F7_1353',
 'S1A_IW_GRDH_1SDV_20170226T104900_20170226T104925_015454_0195F7_95F6',
 'S1A_IW_GRDH_1SDV_20170310T104831_20170310T104900_015629_019B43_B07B',
 'S1A_IW_GRDH_1SDV_20170310T104900_20170310T104925_015629_019B43_0F16',
 'S1A_IW_GRDH_1SDV_20170322T104847_20170322T104916_015804_01A07A_771E',
 'S1A_IW_GRDH_1SDV_20170322T104916_20170322T104941_015804_01A07A_5146',
 'S1A_IW_GRDH_1SDV_20170403T104848_20170403T104917_015979_01A5AB_26E1',
 'S1A_IW_GRDH_1SDV_20170403T104917_20170403T104942_015979_01A5AB_8FDD',
 'S1A_IW_GRDH_1SDV_20170415T104848_20170415T104917_016154_01AB03_C3C0',
 'S1A_IW_GRDH_1SDV_20170415T104917_20170415T104942_016154_01AB03_65E3',
 'S1A_IW_GRDH_1SDV_20170427T104849_20170427T104918_016329_01B053_6FF1',
 'S1A_IW_GRDH_1SDV_20170427T104918_20170427T104943_016329_01B053_ACC3',
 'S1A_IW_GRDH_1SDV_20170509T104850_20170509T104919_016504_01B5AC_67F0',
 'S1A_IW_GRDH_1SDV_20170509T104919_20170509T104944_016504_01B5AC_7197',
 'S1A_IW_GRDH_1SDV_20170521T104850_20170521T104919_016679_01BB04_5410',
 'S1A_IW_GRDH_1SDV_20170521T104919_20170521T104944_016679_01BB04_32EE',
 'S1A_IW_GRDH_1SDV_20170602T104851_20170602T104920_016854_01C069_E081',
 'S1A_IW_GRDH_1SDV_20170602T104920_20170602T104945_016854_01C069_0A65',
 'S1A_IW_GRDH_1SDV_20170614T104852_20170614T104921_017029_01C5D4_379D',
 'S1A_IW_GRDH_1SDV_20170614T104921_20170614T104946_017029_01C5D4_B17F',
 'S1A_IW_GRDH_1SDV_20170626T104852_20170626T104921_017204_01CB29_4691',
 'S1A_IW_GRDH_1SDV_20170626T104921_20170626T104946_017204_01CB29_EF7C',
 'S1A_IW_GRDH_1SDV_20170708T104853_20170708T104922_017379_01D06B_0171',
 'S1A_IW_GRDH_1SDV_20170708T104922_20170708T104947_017379_01D06B_4C47',
 'S1A_IW_GRDH_1SDV_20170720T104854_20170720T104923_017554_01D5C0_3296',
 'S1A_IW_GRDH_1SDV_20170720T104923_20170720T104948_017554_01D5C0_BFE3',
 'S1A_IW_GRDH_1SDV_20170801T104854_20170801T104923_017729_01DB20_7838',
 'S1A_IW_GRDH_1SDV_20170801T104923_20170801T104948_017729_01DB20_A127',
 'S1A_IW_GRDH_1SDV_20170813T104855_20170813T104924_017904_01E06A_1538',
 'S1A_IW_GRDH_1SDV_20170813T104924_20170813T104949_017904_01E06A_4DD4',
 'S1A_IW_GRDH_1SDV_20170825T104856_20170825T104925_018079_01E5BA_2D64',
 'S1A_IW_GRDH_1SDV_20170825T104925_20170825T104950_018079_01E5BA_E406',
 'S1A_IW_GRDH_1SDV_20170906T104856_20170906T104925_018254_01EB0D_9C01',
 'S1A_IW_GRDH_1SDV_20170906T104925_20170906T104950_018254_01EB0D_77F3',
 'S1A_IW_GRDH_1SDV_20170918T104857_20170918T104926_018429_01F07A_683A',
 'S1A_IW_GRDH_1SDV_20170918T104926_20170918T104951_018429_01F07A_5FE4',
 'S1A_IW_GRDH_1SDV_20170930T104857_20170930T104926_018604_01F5D8_660E',
 'S1A_IW_GRDH_1SDV_20170930T104926_20170930T104951_018604_01F5D8_5C88',
 'S1A_IW_GRDH_1SDV_20171012T104857_20171012T104926_018779_01FB27_6CE5',
 'S1A_IW_GRDH_1SDV_20171012T104926_20171012T104951_018779_01FB27_86C4',
 'S1A_IW_GRDH_1SDV_20171024T104857_20171024T104926_018954_020083_9BD4',
 'S1A_IW_GRDH_1SDV_20171024T104926_20171024T104951_018954_020083_C17B',
 'S1A_IW_GRDH_1SDV_20171105T104857_20171105T104926_019129_0205E1_F330',
 'S1A_IW_GRDH_1SDV_20171105T104926_20171105T104951_019129_0205E1_821B',
 'S1A_IW_GRDH_1SDV_20171117T104857_20171117T104926_019304_020B54_DBED',
 'S1A_IW_GRDH_1SDV_20171117T104926_20171117T104951_019304_020B54_D976',
 'S1A_IW_GRDH_1SDV_20171129T104856_20171129T104925_019479_0210D9_FDB3',
 'S1A_IW_GRDH_1SDV_20171129T104925_20171129T104950_019479_0210D9_905F',
 'S1A_IW_GRDH_1SDV_20171211T104856_20171211T104925_019654_021653_581E',
 'S1A_IW_GRDH_1SDV_20171211T104925_20171211T104950_019654_021653_D88F',
 'S1A_IW_GRDH_1SDV_20171223T104855_20171223T104924_019829_021BB6_33C7',
 'S1A_IW_GRDH_1SDV_20171223T104924_20171223T104949_019829_021BB6_B07D']

Read data from S3 by Cloud based TIFF

%%time
aws_session = AWSSession(aws_access_key_id=access_key,aws_secret_access_key=secret_access_key,region_name=region_name,requester_pays=True)
for l in ll:
    infos=l.split('_')
    s3url='s3://sentinel-s1-l1c/GRD/'+infos[4][:4]+'/'+str(int(infos[4][4:6]))+'/'+str(int(infos[4][6:8]))+'/'+infos[1]+'/'+infos[3][2:]+'/'+l+'/measurement/iw-vh.tiff'
    with rasterio.Env(aws_session):
        with rasterio.open(s3url) as src:
            profile = src.profile
            temp=src.read(window=Window(5000,5000,512,512))
CPU times: user 3.3 s, sys: 692 ms, total: 4 s
Wall time: 39.4 s
plt.imshow(temp[0])
<matplotlib.image.AxesImage at 0x7f81ac202340>

PlaneteryComputer Way

%%time
import planetary_computer as pc
for l in ll:
    infos=l.split('_')
    pcurl='https://sentinel1euwest.blob.core.windows.net/s1-grd/GRD/'+infos[4][:4]+'/'+str(int(infos[4][4:6]))+'/'+str(int(infos[4][6:8]))+'/'+infos[1]+'/'+infos[3][2:]+'/'+l+'/measurement/iw-vh.tiff'
    pcurl=pc.sign_url(pcurl)
    with rasterio.open(pcurl) as src:
        profile = src.profile
        temp=src.read(window=Window(5000,5000,512,512))
CPU times: user 3.11 s, sys: 636 ms, total: 3.74 s
Wall time: 50.9 s
plt.imshow(temp[0])
<matplotlib.image.AxesImage at 0x7f4499e8c520>