How to download Aqua Modis data through API

Use this Forum to find information on, or ask a question about, NASA Earth Science data.
Post Reply
atoste
Posts: 2
Joined: Mon Nov 20, 2023 12:57 pm America/New_York
Answers: 0

How to download Aqua Modis data through API

by atoste » Mon Nov 20, 2023 1:02 pm America/New_York

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!

Tags:

OB.DAAC - SeanBailey
User Services
User Services
Posts: 1470
Joined: Wed Sep 18, 2019 6:15 pm America/New_York
Answers: 1
Been thanked: 5 times

Re: How to download Aqua Modis data through API

by OB.DAAC - SeanBailey » Mon Nov 20, 2023 1:36 pm America/New_York

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

atoste
Posts: 2
Joined: Mon Nov 20, 2023 12:57 pm America/New_York
Answers: 0

Re: How to download Aqua Modis data through API

by atoste » Tue Nov 21, 2023 5:22 am America/New_York

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!

OB WebDev - masoudso
Subject Matter Expert
Subject Matter Expert
Posts: 23
Joined: Tue Dec 22, 2020 2:11 pm America/New_York
Answers: 0
Has thanked: 2 times

Re: How to download Aqua Modis data through API

by OB WebDev - masoudso » Thu Nov 30, 2023 2:00 pm America/New_York

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

OB.DAAC - SeanBailey
User Services
User Services
Posts: 1470
Joined: Wed Sep 18, 2019 6:15 pm America/New_York
Answers: 1
Been thanked: 5 times

Re: How to download Aqua Modis data through API

by OB.DAAC - SeanBailey » Thu Nov 30, 2023 2:33 pm America/New_York

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

Post Reply