-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updates to prevent re-delivery of a complex
- Loading branch information
Phil Brodrick
committed
Apr 9, 2024
1 parent
c33645c
commit c4ef433
Showing
4 changed files
with
73 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
|
||
import requests | ||
import math | ||
import time | ||
import argparse | ||
import numpy as np | ||
|
||
CMR_OPS = 'https://cmr.earthdata.nasa.gov/search' # CMR API Endpoint | ||
url = f'{CMR_OPS}/{"granules"}' | ||
collections = 'C2748088093-LPCLOUD' # L2BCH4PLM | ||
datetime_range = '2022-08-01T00:00:00Z,2024-12-31T08:00:00Z' # Overall date range of granules to be searched | ||
page_size=2000 | ||
|
||
# open arguments | ||
parser = argparse.ArgumentParser(description='Get a list of granules from a CMR collection.') | ||
parser.add_argument('token', type=str, help='CMR token') | ||
parser.add_argument('outfile', type=str, help='output file') | ||
args = parser.parse_args() | ||
|
||
print(args.token) | ||
|
||
timelist = [] | ||
for n in range(1,3): | ||
print(url) | ||
response = requests.get(url, | ||
params={'concept_id': collections, | ||
'temporal': datetime_range, | ||
'page_size': page_size, | ||
'page_num': n, | ||
}, | ||
headers={ | ||
'Accept': 'application/json', | ||
'Authorization':f'Bearer {args.token}' | ||
} | ||
) | ||
print(response.status_code) | ||
granules = response.json()['feed']['entry'] | ||
|
||
for g in granules: | ||
timelist.extend([(g['title'],g['updated'])]) | ||
# Show the count of how many granules meet the above parameters | ||
print(f"Number of granules found: {response.headers['CMR-Hits']}") # Resulting quantity of granules/items. | ||
|
||
|
||
|
||
|
||
updated = [x[1] for x in timelist] | ||
order = np.argsort(updated) | ||
|
||
timelist = [timelist[i] for i in order[::-1]] | ||
|
||
out_fidlist = [x[0] for x in timelist] | ||
|
||
with open(args.outfile,'w') as f: | ||
for item in out_fidlist: | ||
f.write("%s\n" % item) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters