Page 1 of 1

Request.get attributes for a function call

Posted: Fri Jun 24, 2022 1:33 am America/New_York
by yusriy
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!

Re: Request.get attributes for a function call

Posted: Thu Jul 07, 2022 8:14 am America/New_York
by OB WebDev - dana.r.wilson