Failed to download OPERA_L2_RTC-S1
Posted: Tue Feb 11, 2025 6:41 am America/New_York
Hi there, I am a newbie in this forum and won't be probably able to apply the correct protocol how to ask here. Pls be patient.
I am trying to download via Python VV bands from product Opera_S1_RTC. The login credentials seem to be ok, but I get following error:
Failed to download OPERA_L2_RTC-S1_T042-088916-IW3_20231114T140829Z_20231116T163134Z_S1A_30_v1.0_VV.tif: No connection adapters were found for '/vsicurl/https://datapool.asf.alaska.edu/RTC/OPERA-S1/OPERA_L2_RTC-S1_T042-088916-IW3_20231114T140829Z_20231116T163134Z_S1A_30_v1.0_VV.tif'
Here the code (jupyter notebook) with the response:
import asf_search
import os
from getpass import getpass
import requests
# Define search options
options = {
'intersectsWith': 'POLYGON((-122.5306 37.6278,-122.1372 37.6207,-122.1372 37.9566,-122.5287 37.9554,-122.5306 37.6278))',
'dataset': 'OPERA-S1',
'start': '2023-11-14T14:00:00Z',
'end': '2023-11-14T15:00:00Z',
'flightDirection': 'DESCENDING',
'processingLevel': 'RTC',
'maxResults': '1000'
}
# Perform the search
results = asf_search.search(**options)
print(f'Found {len(results)} products that match your search criteria')
# Filter results by polarization
polarization = 'VV'
urls = []
for result in results:
for url in result.umm['RelatedUrls']:
if url['URL'].startswith('https://') and url['URL'].endswith(f'{polarization}.tif'):
urls.append('/vsicurl/' + url['URL'])
# Set up environment variables for GDAL
os.environ['GDAL_HTTP_COOKIEFILE'] = '/tmp/cookies.txt'
os.environ['GDAL_HTTP_COOKIEJAR'] = '/tmp/cookies.txt'
os.environ['GDAL_HTTP_NETRC'] = 'YES'
os.environ['GDAL_HTTP_NETRC_FILE'] = 'temp_netrc'
# Get NASA Earthdata Login credentials
username = getpass('NASA Earthdata Login username: ')
password = getpass('NASA Earthdata Login password: ')
# Write credentials to the netrc file
with open(os.environ['GDAL_HTTP_NETRC_FILE'], 'w') as f:
f.write(f'machine urs.earthdata.nasa.gov login {username} password {password}')
with open(os.environ['GDAL_HTTP_NETRC_FILE'], 'r') as f:
content = f.read()
if username in content and password in content:
print("Credentials correctly written to netrc file.")
else:
print("Credentials not found in netrc file.")
# Function to download a file
def download_file(url, local_filename):
with requests.Session() as session:
session.auth = (username, password)
response = session.get(url, stream=True)
response.raise_for_status()
with open(local_filename, 'wb') as f:
for chunk in response.iter_content(chunk_size=8192):
f.write(chunk)
# Download the files
for url in urls:
# Extract the filename from the URL
filename = url.split('/')[-1]
print(f'Downloading {filename}...')
try:
download_file(url, filename)
print(f'Successfully downloaded {filename}')
except requests.exceptions.RequestException as e:
print(f'Failed to download {filename}: {e}')
Response:
Found 3 products that match your search criteria
NASA Earthdata Login username: ········
NASA Earthdata Login password: ········
Credentials correctly written to netrc file.
Downloading OPERA_L2_RTC-S1_T042-088917-IW3_20231114T140831Z_20231116T163134Z_S1A_30_v1.0_VV.tif...
Failed to download OPERA_L2_RTC-S1_T042-088917-IW3_20231114T140831Z_20231116T163134Z_S1A_30_v1.0_VV.tif: No connection adapters were found for '/vsicurl/https://datapool.asf.alaska.edu/RTC/OPERA-S1/OPERA_L2_RTC-S1_T042-088917-IW3_20231114T140831Z_20231116T163134Z_S1A_30_v1.0_VV.tif'
Downloading OPERA_L2_RTC-S1_T042-088916-IW3_20231114T140829Z_20231116T163134Z_S1A_30_v1.0_VV.tif...
Failed to download OPERA_L2_RTC-S1_T042-088916-IW3_20231114T140829Z_20231116T163134Z_S1A_30_v1.0_VV.tif: No connection adapters were found for '/vsicurl/https://datapool.asf.alaska.edu/RTC/OPERA-S1/OPERA_L2_RTC-S1_T042-088916-IW3_20231114T140829Z_20231116T163134Z_S1A_30_v1.0_VV.tif'
Downloading OPERA_L2_RTC-S1_T042-088915-IW3_20231114T140826Z_20231116T163134Z_S1A_30_v1.0_VV.tif...
Failed to download OPERA_L2_RTC-S1_T042-088915-IW3_20231114T140826Z_20231116T163134Z_S1A_30_v1.0_VV.tif: No connection adapters were found for '/vsicurl/https://datapool.asf.alaska.edu/RTC/OPERA-S1/OPERA_L2_RTC-S1_T042-088915-IW3_20231114T140826Z_20231116T163134Z_S1A_30_v1.0_VV.tif'
Here some additional parameters:
Download attempt: 2025-02-11
OS: macOS 15.1.1
Python version: 12.9
Help is very much appreciated! Thanks in advance!
I am trying to download via Python VV bands from product Opera_S1_RTC. The login credentials seem to be ok, but I get following error:
Failed to download OPERA_L2_RTC-S1_T042-088916-IW3_20231114T140829Z_20231116T163134Z_S1A_30_v1.0_VV.tif: No connection adapters were found for '/vsicurl/https://datapool.asf.alaska.edu/RTC/OPERA-S1/OPERA_L2_RTC-S1_T042-088916-IW3_20231114T140829Z_20231116T163134Z_S1A_30_v1.0_VV.tif'
Here the code (jupyter notebook) with the response:
import asf_search
import os
from getpass import getpass
import requests
# Define search options
options = {
'intersectsWith': 'POLYGON((-122.5306 37.6278,-122.1372 37.6207,-122.1372 37.9566,-122.5287 37.9554,-122.5306 37.6278))',
'dataset': 'OPERA-S1',
'start': '2023-11-14T14:00:00Z',
'end': '2023-11-14T15:00:00Z',
'flightDirection': 'DESCENDING',
'processingLevel': 'RTC',
'maxResults': '1000'
}
# Perform the search
results = asf_search.search(**options)
print(f'Found {len(results)} products that match your search criteria')
# Filter results by polarization
polarization = 'VV'
urls = []
for result in results:
for url in result.umm['RelatedUrls']:
if url['URL'].startswith('https://') and url['URL'].endswith(f'{polarization}.tif'):
urls.append('/vsicurl/' + url['URL'])
# Set up environment variables for GDAL
os.environ['GDAL_HTTP_COOKIEFILE'] = '/tmp/cookies.txt'
os.environ['GDAL_HTTP_COOKIEJAR'] = '/tmp/cookies.txt'
os.environ['GDAL_HTTP_NETRC'] = 'YES'
os.environ['GDAL_HTTP_NETRC_FILE'] = 'temp_netrc'
# Get NASA Earthdata Login credentials
username = getpass('NASA Earthdata Login username: ')
password = getpass('NASA Earthdata Login password: ')
# Write credentials to the netrc file
with open(os.environ['GDAL_HTTP_NETRC_FILE'], 'w') as f:
f.write(f'machine urs.earthdata.nasa.gov login {username} password {password}')
with open(os.environ['GDAL_HTTP_NETRC_FILE'], 'r') as f:
content = f.read()
if username in content and password in content:
print("Credentials correctly written to netrc file.")
else:
print("Credentials not found in netrc file.")
# Function to download a file
def download_file(url, local_filename):
with requests.Session() as session:
session.auth = (username, password)
response = session.get(url, stream=True)
response.raise_for_status()
with open(local_filename, 'wb') as f:
for chunk in response.iter_content(chunk_size=8192):
f.write(chunk)
# Download the files
for url in urls:
# Extract the filename from the URL
filename = url.split('/')[-1]
print(f'Downloading {filename}...')
try:
download_file(url, filename)
print(f'Successfully downloaded {filename}')
except requests.exceptions.RequestException as e:
print(f'Failed to download {filename}: {e}')
Response:
Found 3 products that match your search criteria
NASA Earthdata Login username: ········
NASA Earthdata Login password: ········
Credentials correctly written to netrc file.
Downloading OPERA_L2_RTC-S1_T042-088917-IW3_20231114T140831Z_20231116T163134Z_S1A_30_v1.0_VV.tif...
Failed to download OPERA_L2_RTC-S1_T042-088917-IW3_20231114T140831Z_20231116T163134Z_S1A_30_v1.0_VV.tif: No connection adapters were found for '/vsicurl/https://datapool.asf.alaska.edu/RTC/OPERA-S1/OPERA_L2_RTC-S1_T042-088917-IW3_20231114T140831Z_20231116T163134Z_S1A_30_v1.0_VV.tif'
Downloading OPERA_L2_RTC-S1_T042-088916-IW3_20231114T140829Z_20231116T163134Z_S1A_30_v1.0_VV.tif...
Failed to download OPERA_L2_RTC-S1_T042-088916-IW3_20231114T140829Z_20231116T163134Z_S1A_30_v1.0_VV.tif: No connection adapters were found for '/vsicurl/https://datapool.asf.alaska.edu/RTC/OPERA-S1/OPERA_L2_RTC-S1_T042-088916-IW3_20231114T140829Z_20231116T163134Z_S1A_30_v1.0_VV.tif'
Downloading OPERA_L2_RTC-S1_T042-088915-IW3_20231114T140826Z_20231116T163134Z_S1A_30_v1.0_VV.tif...
Failed to download OPERA_L2_RTC-S1_T042-088915-IW3_20231114T140826Z_20231116T163134Z_S1A_30_v1.0_VV.tif: No connection adapters were found for '/vsicurl/https://datapool.asf.alaska.edu/RTC/OPERA-S1/OPERA_L2_RTC-S1_T042-088915-IW3_20231114T140826Z_20231116T163134Z_S1A_30_v1.0_VV.tif'
Here some additional parameters:
Download attempt: 2025-02-11
OS: macOS 15.1.1
Python version: 12.9
Help is very much appreciated! Thanks in advance!