Hi,
I hope anyone can help with the entry names for a request.get() call to the CMR.
I want to generate a list of URLs for the chlorophyll-a data of MODIS. An example file name is 'A2016345.L3m_DAY_CHL_chlor_a_4km.nc.'
The python code I used in the jupyter notebook is written below:
collection_id = 'C1442922862-OB_DAAC'#'C1449861405-OB_DAAC'
date_range = '2015-01-01T00:00:00Z,2016-12-30T23:59:59Z'
bbox = '87.407227,0.527336,105.600586,15.792254’
response = requests.get(url,
params={
'concept_id': collection_id,
'temporal': date_range,
'bounding_box': bbox,
'page_size': 10,
},
headers=headers
)
print(response.status_code)
The output of the call is
OB_DAAC | Aqua MODIS Global Mapped Chlorophyll (CHL) Data, version 2018 | G1449570461-OB_DAAC
OB_DAAC | Aqua MODIS Global Mapped Chlorophyll (CHL) Data, version 2018 | G1449570462-OB_DAAC
OB_DAAC | Aqua MODIS Global Mapped Chlorophyll (CHL) Data, version 2018 | G1449570463-OB_DAAC
OB_DAAC | Aqua MODIS Global Mapped Chlorophyll (CHL) Data, version 2018 | G1449570464-OB_DAAC
OB_DAAC | Aqua MODIS Global Mapped Chlorophyll (CHL) Data, version 2018 | G1449620403-OB_DAAC
[truncated]
When I pprint(granules[0]), the output is just one nc file, while I expected a list of nc files for the dates in the date_range:
https_urls = [l['href'] for l in granules[0]['links'] if 'https' in l['href'] and '.nc' in l['href']]
https_urls
['https://oceandata.sci.gsfc.nasa.gov (/cmr/getfile/A20021822017212.L3m_MC_CHL_chl_ocx_4km.nc)',
'https://oceandata.sci.gsfc.nasa.gov (/opendap/MODISA/L3SMI/2002/182/A20021822017212.L3m_MC_CHL_chl_ocx_4km.nc)']
How can I narrow down the search to just the chlor a 4 km nc files? Maybe, I need to know other param attributes so that it can only list the wanted files.
Thanks for any assistance provided!
Request.get attributes for a function call
-
- Posts: 71
- Joined: Mon Apr 20, 2020 8:04 am America/New_York
Re: Request.get attributes for a function call
If you are searching by collection you can use a pattern
https://cmr.earthdata.nasa.gov/search/site/docs/search/api.html#find-all-collections
Search by granule below.
https://cmr.earthdata.nasa.gov/search/granules.umm_json?page_size=50&page_num=1&short_name=MODISA_L3m_CHL&temporal=2015-01-01T00:00:00Z,2016-12-30T23:59:59Z&bounding_box=87.407227,0.527336,105.600586,15.792254
https://cmr.earthdata.nasa.gov/search/site/docs/search/api.html#find-all-collections
Search by granule below.
https://cmr.earthdata.nasa.gov/search/granules.umm_json?page_size=50&page_num=1&short_name=MODISA_L3m_CHL&temporal=2015-01-01T00:00:00Z,2016-12-30T23:59:59Z&bounding_box=87.407227,0.527336,105.600586,15.792254