fraymio / modis-tools

Tools for working with the MODIS API and MODIS data.
Apache License 2.0
22 stars 11 forks source link

No file content found using bounding box #26

Closed leocd91 closed 1 year ago

leocd91 commented 1 year ago

Describe the bug No file content found using bounding box (-94.064941,28.960089,-89.055176,32.971804)

To Reproduce Steps to reproduce the behavior:

lsn_bbox = (-94.064941,28.960089,-89.055176,32.971804)
lsn_granules = granule_client.query(start_date="2010-01-01", end_date="2010-01-02", bounding_box=lsn_bbox)
GranuleHandler.download_from_granules(lsn_granules, session)

Expected behavior and actual behavior Expect to receive hdf files of Texas & Lousiana.

Your Environment:

iamchrisearle commented 1 year ago

Hi @leocd91 , which product was this for? I am getting hdf files back for MOD13A1 with the bounding box you provided:

session = ModisSession(username=username, password=password)
collection_client = CollectionApi(session=session)
collections = collection_client.query(short_name="MOD13A1", version="061")
granule_client = GranuleApi.from_collection(collections[0], session=session)

lsn_bbox = (-94.064941,28.960089,-89.055176,32.971804)
lsn_granules = granule_client.query(start_date="2010-01-01", end_date="2010-01-02", bounding_box=lsn_bbox)
GranuleHandler.download_from_granules(lsn_granules, session)
leocd91 commented 1 year ago

yes it was MOD13A1, sorry for not being specific. I'll try making a new env first and see if it make any difference

leocd91 commented 1 year ago
~\Anaconda3\envs\sat_data\lib\site-packages\modis_tools\granule_handler.py in _get(cls, url, modis_session, stream)
    173         content_size = int(req.headers.get("Content-Length", -1))
    174         if content_size <= 1:
--> 175             raise FileNotFoundError("No file content found")
    176         return req
    177 

FileNotFoundError: No file content found

well, it is still the same, any tips?

iamchrisearle commented 1 year ago

I tried changing the version number and was still able to get the expected hdf files back so I haven't be able to recreate the error.

I hope I don't insult your intelligence by suggesting a double check on your MODIS credentials, but invalid credentials can also return a No file content found error:

from modis_tools.auth import ModisSession
from modis_tools.granule_handler import GranuleHandler
from modis_tools.resources import CollectionApi, GranuleApi

username = "NotMyUserName"  # Update this line
password = "NotMyPassword"  # Update this line

# Authenticate a session
session = ModisSession(username=username, password=password)

# Query the MODIS catalog for collection
collection_client = CollectionApi(session=session)
collections = collection_client.query(short_name="MOD13A1", version="006")

# Query the selected collection for granules
granule_client = GranuleApi.from_collection(collections[0], session=session)

lsn_bbox = (-94.064941,28.960089,-89.055176,32.971804)
lsn_granules = granule_client.query(start_date="2010-01-01", end_date="2010-01-02", bounding_box=lsn_bbox)
GranuleHandler.download_from_granules(lsn_granules, session)

will raise

FileNotFoundError: No file content found

Credentials should be the same ones used to login here https://urs.earthdata.nasa.gov/

leocd91 commented 1 year ago

No, it is not :) I see, I am using a different account I normally use, I'll check the authorization etc.