Gabriel-Desharnais / Modis-python-suite

Python module to download modis data
MIT License
9 stars 6 forks source link

Issue running script #16

Closed jorgeirun closed 2 years ago

jorgeirun commented 6 years ago

Hi, I tested the following code

import modisSuite
#Create object
print ("start..")
prod="MOD35_L2"
username="XXX"
password="XXX"
startdate="2010-02-20"
d=1 #Download days
tiles=['h13v04']
folder="/" #will download all file in the folder test
doo=modisSuite.downloader(prod,username,password,date=startdate,delta=d,tuiles=tiles,output=folder)
for day in doo.telechargerTout():
  print([aFile.name for aFile in day.files])
  day.mosaic()

and I get the following error on every try

Traceback (most recent call last):
  File "Desktop/modisSuite_test.py", line 15, in <module>
    for day in doo.telechargerTout():
  File "/anaconda3/lib/python3.6/site-packages/modisSuite/Downloader.py", line 218, in telechargerTout
    for date in LListeDate:
UnboundLocalError: local variable 'LListeDate' referenced before assignment

I already tested my credentials and they work fine, also no connection problems on my end. would this be a problem on the lib or on my end?

Gabriel-Desharnais commented 6 years ago

Hi thanks for reporting the issue. The error you get is created from my end by a bad error handling in the script. I shall solve that relatively quickly, but the product you're trying to download is not supported at the moment I'll work on that as soon as possible. Could you give me the link you are using to download your data at the moment?

jorgeirun commented 6 years ago

Hi, sure.. I'm trying to download 2 products actually Cloud Mask files: MOD35_L2 and their corresponding geolocation files: MOD03

The ftp full addresses would be: Cloud Mask: ftp://ladsweb.nascom.nasa.gov/allData/61/MOD35_L2/ Geolocation files: ftp://ladsweb.nascom.nasa.gov/allData/61/MOD03/ In those folder I can find all

I was looking at the code and trying to figure out how you do to match the files with the tiles selected by the user? I was trying to figure out how to "translate" a tile like h12v11 to match/get the right file.

I found the library you made super useful and if these items can be downloaded will help me a great deal with my research. Let me know anything I can help you with.

Thanks.

VP08 commented 6 years ago

Gabriel: I had the same problem with Dowloader:
File "/usr/local/lib/python2.7/dist-packages/modisSuite/Downloader.py", line 215, in telechargerTout LListeDate.remove(da) UnboundLocalError: local variable 'LListeDate' referenced before assignment Please let me know when it's fixed!

Jogeirun: not sure if I understand your question about the tiles correctly but maybe I can help. h12v11 refers to the tile ID in the MODIS tiling grid (https://modis-land.gsfc.nasa.gov/MODLAND_grid.html), if you just use the downloader module in MODISSUITE, the downloaded file will have the tile number in the name.... whereas if you use the mosaïcking option, they will no longer be visible in the name since 2 or more tiles are "stiched" together in one file.

jorgeirun commented 6 years ago

Hi @VP08 thanks for the info, it does help to understand more but here's what I'm looking for exactly:

This is the full name of an HDF file downloaded (for Jan 1, 2018, cloud mask product, for tile h12v11): MOD35_L2.A2018001.1505.061.2018002053315.hdf being: MOD35_L2: code for cloud mask product A2018001: for the day (date) Jan 1, 2018 1505: exact time HHMM 061: I believe is the code for the collection the product is in 2018002053315: this is the part I'm not sure what it represents, would it have to do with coordinates or tiles? I understand that h12v11 is how we select the tile, but how do I link that code with the correct item that is MOD35_L2.A2018001.1505.061.2018002053315.hdf?

VP08 commented 6 years ago

I think L2 (Level 2) modis products are not yet tiled (whereas Level 3 are). Check carefully the product documentation but it says "5-Min L2 Swath" ... I think MODISSUITE does not support Level 2 product as we used it initially for level 3 product. Gabriel will know more about that.

Gabriel-Desharnais commented 6 years ago

I think the connection is solved I'll have to test it again in order to be sure. As for the downloading of L2 product, although the ModisSuite wasn't create with these product in mind, it is abstracted enough to be able to download them. Instead of specifying a tile identifier you'll have to specify the time e.g. 0315. That said I'll ad other DAAC (I already have 2 of 12) to the script (That'll keep me busy). I will start by the one that delivers MOD35_L2 and MOD03. Instead of using the FTP link I'll use https://ladsweb.modaps.eosdis.nasa.gov/archive since it is a complete archive instead of near real time.

jorgeirun commented 6 years ago

Amazing man! Looking forward to test the updates!

jorgeirun commented 6 years ago

About specifying the time, it’s not a problem but if we don’t specify tiles how would we selec them?

VP08 commented 6 years ago

Gabriel : I'm not sure to understand if you corrected the issue or not for "UnboundLocalError: local variable 'LListeDate' referenced before assignment" as I don't see any new commit for the code...

thanks for your help!