Skip to content

Commit

Permalink
Added circle key to search, useable without opts. Also made it so gen…
Browse files Browse the repository at this point in the history
…erator won't throw on incomplete results, but .search directly will
  • Loading branch information
Cameronsplaze committed Aug 31, 2023
1 parent b5a8910 commit 9dc3a33
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions asf_search/search/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def search(
beamMode: Union[str, Iterable[str]] = None,
beamSwath: Union[str, Iterable[str]] = None,
campaign: Union[str, Iterable[str]] = None,
circle: Tuple[float, float, float] = None,
maxDoppler: float = None,
minDoppler: float = None,
end: Union[datetime.datetime, str] = None,
Expand Down Expand Up @@ -51,6 +52,7 @@ def search(
:param beamMode: The beam mode used to acquire the data.
:param beamSwath: Encompasses a look angle and beam mode.
:param campaign: For UAVSAR and AIRSAR data collections only. Search by general location, site description, or data grouping as supplied by flight agency or project.
:param circle: Search by circle defined by list of three floats: [longitude, latitude, radius in meters]
:param maxDoppler: Doppler provides an indication of how much the look direction deviates from the ideal perpendicular flight direction acquisition.
:param minDoppler: Doppler provides an indication of how much the look direction deviates from the ideal perpendicular flight direction acquisition.
:param end: End date of data acquisition. Supports timestamps as well as natural language such as "3 weeks ago"
Expand Down Expand Up @@ -95,6 +97,9 @@ def search(
results.searchComplete = page.searchComplete
results.searchOptions = page.searchOptions

# Raise if they didn't get everything. If you're okay with partial
# results, use asf.search_generator directly
results.raise_if_incomplete()
results.sort(key=lambda p: (p.properties['stopTime'], p.properties['fileID']), reverse=True)

return results
9 changes: 8 additions & 1 deletion asf_search/search/search_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def search_generator(
beamMode: Union[str, Iterable[str]] = None,
beamSwath: Union[str, Iterable[str]] = None,
campaign: Union[str, Iterable[str]] = None,
circle: Tuple[float, float, float] = None,
maxDoppler: float = None,
minDoppler: float = None,
end: Union[datetime.datetime, str] = None,
Expand Down Expand Up @@ -94,7 +95,13 @@ def search_generator(
logging.error(message)
report_search_error(query, message)
opts.session.headers.pop('CMR-Search-After', None)
raise
# If it's a CMRIncompleteError, we can just stop here and return what we have
# It's up to the user to call .raise_if_incomplete() if they're using the
# generator directly.
if type(exc) == CMRIncompleteError:
return
else:
raise

opts.session.headers.update({'CMR-Search-After': cmr_search_after_header})
last_page = process_page(items, maxResults, subquery_max_results, total, subquery_count, opts)
Expand Down

0 comments on commit 9dc3a33

Please sign in to comment.