Skip to content

Commit

Permalink
filter CSLCs by PGE version, and by processing date (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
scottstanie authored Aug 28, 2024
1 parent 97edf3b commit 9353da6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/opera_utils/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,12 @@ def filter_results_by_date_and_version(results: ASFSearchResults) -> ASFSearchRe
# First, sort the results primarily by 'startTime' and secondarily by 'pgeVersion' in descending order
sorted_results = sorted(
results,
key=lambda r: (r.properties["startTime"], parse(r.properties["pgeVersion"])),
key=lambda r: (
r.properties["startTime"],
r.properties["operaBurstID"],
r.properties["processingDate"],
parse(r.properties["pgeVersion"]),
),
reverse=True,
)

Expand All @@ -281,11 +286,11 @@ def filter_results_by_date_and_version(results: ASFSearchResults) -> ASFSearchRe

# Extract the result with the highest pgeVersion for each group
filtered_results = [
max(group, key=lambda r: parse(r.properties["pgeVersion"]))
max(group, key=lambda r: r.properties["processingDate"])
for _, group in grouped_by_start_time
]

return filtered_results
return ASFSearchResults(filtered_results)


def _get_urls(
Expand Down

0 comments on commit 9353da6

Please sign in to comment.