Skip to content

Commit

Permalink
Merge branch 'test' into cs.v3-test-suite
Browse files Browse the repository at this point in the history
  • Loading branch information
kim committed Apr 2, 2024
2 parents 1641d82 + dc114d9 commit 3650169
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 11 deletions.
14 changes: 10 additions & 4 deletions SearchAPI/CMR/Output/geojson.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,19 @@ def getItem(self, p):
except TypeError:
pass

if p.get('absoluteOrbit') is not None and len(p.get('absoluteOrbit')):
p['absoluteOrbit'] = p['absoluteOrbit'][0]

coordinates = []

if p.get('shape') is not None:
coordinates = [[float(c['lon']), float(c['lat'])] for c in p.get('shape')]

result = {
'type': 'Feature',
'geometry': {
'type': 'Polygon',
'coordinates': [
[[float(c['lon']), float(c['lat'])] for c in p['shape']]
]
'coordinates': coordinates
},
'properties': {
'beamModeType': p['beamModeType'],
Expand All @@ -82,7 +88,7 @@ def getItem(self, p):
'insarStackId': p['insarGrouping'],
'md5sum': p['md5sum'],
'offNadirAngle': p['offNadirAngle'],
'orbit': p['absoluteOrbit'][0],
'orbit': p['absoluteOrbit'],
'pathNumber': p['relativeOrbit'],
'platform': p['platform'],
'pointingAngle': p['pointingAngle'],
Expand Down
9 changes: 8 additions & 1 deletion SearchAPI/CMR/Output/jsonlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ def req_fields_jsonlite():
'subswath',
'pgeVersion',
'operaBurstID',
'additionalUrls'
'additionalUrls',
's3Urls'
]
return fields

Expand Down Expand Up @@ -186,4 +187,10 @@ def getItem(self, p):
if p.get('validityStartDate'):
result['opera']['validityStartDate'] = p.get('validityStartDate')

if p.get('platform') == 'NISAR':
result['nisar'] = {
'additionalUrls': p.get('additionalUrls', []),
's3Urls': p.get('s3Urls', [])
}

return result
3 changes: 3 additions & 0 deletions SearchAPI/CMR/Output/jsonlite2.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,7 @@ def getItem(self, p):
if p.get('opera') is not None:
result['s1o'] = p['opera']

if p.get('nisar') is not None:
result['nsr'] = p['nisar']

return result
2 changes: 1 addition & 1 deletion SearchAPI/CMR/Query.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def chunk_list(source_list, n):
if chunk_type in params:
params[chunk_type] = chunk_list(list(set(params[chunk_type])), 500) # distinct and split

list_param_names = ['platform', 'collections'] # these parameters will dodge the subquery system
list_param_names = ['platform', 'collections', 'shortname'] # these parameters will dodge the subquery system

for k, v in params.items():
if k in list_param_names:
Expand Down
3 changes: 3 additions & 0 deletions SearchAPI/CMR/SubQuery.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ def __init__(self, req_fields, params, extra_params):
self.headers = {}

token = request.args.get("cmr_token")
if token is None:
token = request.form.get('cmr_token')

if token != None:
self.headers['Authorization'] = f'Bearer {token}'

Expand Down
1 change: 1 addition & 0 deletions SearchAPI/CMR/Translate/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def get_field_paths():
'track': attr_path('PATH_NUMBER'),
'pgeVersion': "./PGEVersionClass/PGEVersion",
'additionalUrls': "./OnlineAccessURLs",
's3Urls': "./OnlineAccessURLs",

# BURST FIELDS
'absoluteBurstID': attr_path('BURST_ID_ABSOLUTE'),
Expand Down
3 changes: 2 additions & 1 deletion SearchAPI/CMR/Translate/input_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def input_map():
'absoluteburstid': ['attribute[]', 'int,BURST_ID_ABSOLUTE,{0}', parse_int_list],
'fullburstid': ['attribute[]', 'string,BURST_ID_FULL,{0}', parse_string_list],
'operaburstid': ['attribute[]', 'string,OPERA_BURST_ID,{0}', parse_string_list],
'dataset': [None, '{0}', parse_string_list]
'dataset': [None, '{0}', parse_string_list],
'shortname': ['shortName', '{0}', parse_string_list]
}

return parameter_map
30 changes: 26 additions & 4 deletions SearchAPI/CMR/Translate/parse_cmr_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,19 +205,41 @@ def float_or_none(a):
result['downloadUrl'] = urls[0]
result['fileName'] = result['granuleName'] + '.' + urls[0].split('.')[-1]



def get_all_urls():
accessPath = './OnlineAccessURLs/OnlineAccessURL/URL'
resourcesPath = './OnlineResources/OnlineResource/URL'

access_urls = get_all_vals(accessPath)
if access_urls is None:
access_urls = []

resource_urls = get_all_vals(resourcesPath)
if resource_urls is None:
resource_urls = []

return list(set([*access_urls, *resource_urls]))

def get_http_urls():
return [url for url in get_all_urls() if not url.endswith('.md5') and not url.startswith('s3://') and not 's3credentials' in url]

def get_s3_urls():
return [url for url in get_all_urls() if not url.endswith('.md5') and (url.startswith('s3://') or 's3credentials' in url)]

if result.get('product_file_id', '').startswith('OPERA'):
result['beamMode'] = get_val(attr_path('BEAM_MODE'))
accessUrls = [url for url in get_all_vals('./OnlineAccessURLs/OnlineAccessURL/URL') if not url.endswith('.md5') and not url.startswith('s3://') and not 's3credentials' in url]
OnlineResources = [url for url in get_all_vals('./OnlineResources/OnlineResource/URL') if not url.endswith('.md5') and not url.startswith('s3://') and not 's3credentials' in url]
result['additionalUrls'] = list(set([*accessUrls, *OnlineResources]))
result['additionalUrls'] = get_http_urls()
result['configurationName'] = "Interferometric Wide. 250 km swath, 5 m x 20 m spatial resolution and burst synchronization for interferometry. IW is considered to be the standard mode over land masses."

if (providerbrowseUrls := get_all_vals('./AssociatedBrowseImageUrls/ProviderBrowseUrl/URL')):
result['browse'] = [url for url in providerbrowseUrls if not url.startswith('s3://')]

if 'STATIC' in result['processingLevel']:
result['validityStartDate'] = get_val('./Temporal/SingleDateTime')

if result.get('platform', '') == 'NISAR':
result['additionalUrls'] = get_http_urls()
result['s3Urls'] = get_s3_urls()
return result


Expand Down

0 comments on commit 3650169

Please sign in to comment.