Skip to content

Instantly share code, notes, and snippets.

View asjohnston-asf's full-sized avatar

Andrew Johnston asjohnston-asf

View GitHub Profile
@asjohnston-asf
asjohnston-asf / find_opera_disp_products.py
Last active February 6, 2025 18:01
Find download URLs for OPERA DISP products in ASF non-production archive by product version and frame id
import requests
def get_download_url(product: dict, protocol: str) -> str:
if protocol not in ['https', 's3']:
raise ValueError(f'Unknown protocol {protocol}; must be https or s3')
for url in product['umm']['RelatedUrls']:
if url['Type'].startswith('GET DATA') and url['URL'].startswith(protocol):
return url['URL']
@asjohnston-asf
asjohnston-asf / coherence-notebook.ipynb
Created December 2, 2022 21:41
"Search the GSSICB STAC Catalog" notebook for AGU 2022
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@asjohnston-asf
asjohnston-asf / gist:c252f6e393299bc4e0079f133de1ebbc
Last active August 31, 2020 20:34
cmr query for average s1 ingest lag time
from statistics import mean
from datetime import timedelta, datetime
import requests
from dateutil.parser import parse
SESSION = requests.Session()
def get_granules(day):
from requests import Session
search_url = 'https://cmr.earthdata.nasa.gov/search/granules'
parameters = {
'scroll': 'true',
'provider': 'ASF',
'page_size': 2000,
# set any search criteria here
#'short_name': ['SENTINEL-1A_SP_GRD_HIGH','SENTINEL-1B_SP_GRD_HIGH','SENTINEL-1A_DP_GRD_HIGH','SENTINEL-1B_DP_GRD_HIGH'],
@app.route(....)
def list_zip_contents():
try:
return do_it()
except RemoteIoError as e:
status_code = get_status_code(e)
abort(status_code)
except KeyError as e:
return 'no such file...', 400
{
"zip_url": "https://datapool.asf.alaska.edu/SLC/SA/S1A_IW_SLC__1SDV_20200127T193344_20200127T193411_030990_038F2E_9EF2.zip",
"zip_filename": "S1A_IW_SLC__1SDV_20200127T193344_20200127T193411_030990_038F2E_9EF2.zip",
"zip_size": 3799270867,
"list_url": "https://unzip-test.asf.alaska.edu/SLC/SA/S1A_IW_SLC__1SDV_20200127T193344_20200127T193411_030990_038F2E_9EF2.zip/",
"contents": [{
"filename": "S1A_IW_SLC__1SDV_20200127T193344_20200127T193411_030990_038F2E_9EF2.SAFE/",
"size": 0,
"url": "https://unzip-test.asf.alaska.edu/SLC/SA/S1A_IW_SLC__1SDV_20200127T193344_20200127T193411_030990_038F2E_9EF2.zip/S1A_IW_SLC__1SDV_20200127T193344_20200127T193411_030990_038F2E_9EF2.SAFE/"
}, {