Page 1 of 1

How to download Aqua Modis data through API

Posted: Mon Nov 20, 2023 1:02 pm America/New_York
by atoste
Hey guys,

I am pretty new with getting data so I would like to ask a beginner question.
I have seen this page about how to use NASA API: https://oceancolor.gsfc.nasa.gov/data/download_methods/ and have tried to use the obdaac_download python file in there but maybe I might just do the wrong command.
I have tried to download the AQUA_MODIS.20231115.L3m.DAY.PIC.pic.4km.NRT.nc file.
I have tried the following command: python obdaac_download.py --verbose -v --force --appkey {{APP_KEY_VALUE}} AQUA_MODIS.20231115.L3m.DAY.PIC.pic.4km.NRT.nc
I already have an API KEY

Can you please help me identify what I am doing incorrectly?

Thank you for your time!

Re: How to download Aqua Modis data through API

Posted: Mon Nov 20, 2023 1:36 pm America/New_York
by OB.DAAC - SeanBailey
First, I'll make the assumption that you replaced {{APP_KEY}} with your app key value :D

Since you had --verbose set, what (if any) errors did it output?

Sean

Re: How to download Aqua Modis data through API

Posted: Tue Nov 21, 2023 5:22 am America/New_York
by atoste
Hi Sean,

Thank you for your response. It's great to feel that I have support.
Yes I did use the APPKEY that I have, for security reasons I put in a variable format (the same applies in this output log).
I had tried to put the APPKEY and the filename inside the quotes and this is the message I get in all these cases:


Output directory: /Users/eyecondev/Documents/Andre/Habtrail/gee_test/download_data
Retrieving AQUA_MODIS.20231115.L3m.DAY.PIC.pic.4km.NRT.nc
Session started
DEBUG:urllib3.util.retry:Converted retries value: 5 -> Retry(total=5, connect=None, read=None, redirect=None, status=None)
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): oceandata.sci.gsfc.nasa.gov:443
DEBUG:urllib3.connectionpool:https://oceandata.sci.gsfc.nasa.gov:443 "GET /ob/getfile/AQUA_MODIS.20231115.L3m.DAY.PIC.pic.4km.NRT.nc?appkey={{APP_KEY_VALUE}} HTTP/1.1" 301 None
DEBUG:urllib3.connectionpool:https://oceandata.sci.gsfc.nasa.gov:443 "GET /getfile/AQUA_MODIS.20231115.L3m.DAY.PIC.pic.4km.NRT.nc?appkey={{APP_KEY_VALUE}} HTTP/1.1" 200 None
Traceback (most recent call last):
File "/Users/eyecondev/Documents/Andre/Habtrail/gee_test/download_data/obdaac_download.py", line 314, in <module>
status = retrieveURL(request,localpath=outpath, uncompress=args.uncompress,
File "/Users/eyecondev/Documents/Andre/Habtrail/gee_test/download_data/obdaac_download.py", line 227, in retrieveURL
status = httpdl(server, netpath, localpath=localpath, uncompress=uncompress, verbose=verbose,force_download=force_download)
File "/Users/eyecondev/Documents/Andre/Habtrail/gee_test/download_data/obdaac_download.py", line 129, in httpdl
total_length = int(total_length)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

Thank you again for your time!

Re: How to download Aqua Modis data through API

Posted: Thu Nov 30, 2023 2:00 pm America/New_York
by masoudso
Hello,
Please check your appkey and make sure it's not expired. You may want to try the code by passing the value directly (instead of using the variable):
Navigate to the directory where the code is saved and try:
./<file_name> -v --appkey <paste your appkey here> AQUA_MODIS.20231115.L3m.DAY.PIC.pic.4km.NRT.nc

Please let us know if that works.

Masoud

Re: How to download Aqua Modis data through API

Posted: Thu Nov 30, 2023 2:33 pm America/New_York
by OB.DAAC - SeanBailey
Make sure the appkey was entered correctly, as well. The code will fail with the error you saw if the appkey is invalid (mistyped, or expired...We need to update the code trap this error better :shock: ).

Sean