Commit b45443e5 authored by Mario Chirinos Colunga's avatar Mario Chirinos Colunga 💬

update

parent 13f2a486
......@@ -28,8 +28,8 @@ from datetime import date
# products = sentinel.getProducts(wkt, (startDate, endDate), {"platformname":platform, "cloudcoverpercentage":"[0 TO "+str(cloud)+"]"})
# return products
productsCodes = {"L1C":"L1C","L2A":"L1C"}
#productsCodes = {"L1C":"L1C","L2A":"L1C"}
productType = {"L1C":"S2MSI1C", "L2A":"S2MSI2A"}
def main(argv):
if len(sys.argv) != 2:
......@@ -41,36 +41,59 @@ def main(argv):
sentinel = APISentinel.APISentinel(cfg['username'], cfg['password'])
wkt = polygonToBox.getWKTPolygonBoundingBox(cfg['wkt'], True)
productList = sentinel.getProducts(wkt, (cfg['startDate'], cfg['endDate']), {"platformname":cfg['platform'], "cloudcoverpercentage":"[0 TO "+str(cfg['clouds'])+"]"}, "Contains")
productList = sentinel.getProducts(wkt, (cfg['startDate'], cfg['endDate']), {"producttype":productType[cfg["productLevel"]], "platformname":cfg['platform'], "cloudcoverpercentage":"[0 TO "+str(cfg['clouds'])+"]"}, "Contains")
if len(productList)<=0:
print ("No products found with 'Contains' trying with 'Intersects'")
productList = sentinel.getProducts(wkt, (cfg['startDate'], cfg['endDate']), {"platformname":cfg['platform'], "cloudcoverpercentage":"[0 TO "+str(cfg['clouds'])+"]"})
fileNames = [productList[k]['filename'].replace("SAFE", "zip").replace(productsCodes[cfg['productLevel']], cfg['productLevel']) for k in productList.keys() ]
inDir = cfg["productsDir"]
outdir = cfg["linksDir"]
dirList = os.listdir(inDir)
productList = sentinel.getProducts(wkt, (cfg['startDate'], cfg['endDate']), {"producttype":productType[cfg["productLevel"]], "platformname":cfg['platform'], "cloudcoverpercentage":"[0 TO "+str(cfg['clouds'])+"]"})
# fileNames = [productList[k]['filename'].replace("SAFE", "zip").replace(productsCodes[cfg['productLevel']], cfg['productLevel']) for k in productList.keys() ]
fileNames = [productList[k]['filename'].replace("SAFE", "zip") for k in productList.keys() ]
downloadDir = cfg["productsDir"]+cfg["productLevel"]+"/"
dirList = os.listdir(downloadDir)
matchingProducts = set(fileNames).intersection(set(dirList))
print ( str(len(matchingProducts))+" of " + str(len(fileNames)) +" products found.")
rawDir = inDir.replace(cfg['productLevel'],productsCodes[cfg['productLevel']])
print(rawDir)
print ( str(len(matchingProducts))+" of " + str(len(fileNames)) +" "+ cfg["productLevel"] + " products found.")
# rawDir = inDir.replace(cfg['productLevel'],productsCodes[cfg['productLevel']])
# print(rawDir)
text =""
while text != "yes" and text != "no":
text = raw_input("Do you want to download this products to "+rawDir+ " ? (yes, no)")
text = raw_input("Do you want to download this products to "+downloadDir+ " ? (yes, no)")
if text=="yes":
#sentinel.downloadProducts(productList,rawDir)
print("L1CProductListToL2A.sh "+rawDir+" "+inDir+" 1")
#os.system("L1CProductListToL2A.sh "+rawDir+" "+inDir+" 1")
sentinel.downloadProducts(productList,downloadDir)
L2ADir = cfg["productsDir"]+"L2A/"
if cfg["productLevel"]=="L1C":
fileNamesL2A = [productList[k]['filename'].replace("SAFE", "zip").replace("L1C", "L2A") for k in productList.keys() ]
L1CDir = os.listdir(cfg["productsDir"]+"L1C/")
matchingProducts = set(fileNames).intersection(set(L1CDir))
print ( str(len(matchingProducts))+" of " + str(len(fileNames)) +" L1C products found in L2A.")
text =""
while text != "yes" and text != "no":
text = raw_input("Do you want to download this products to "+downloadDir+ " ? (yes, no)")
if text=="yes":
#print("L1CProductListToL2A.sh "+rawDir+" "+inDir+" 1")
os.system("L1CProductListToL2A.sh "+L1CDir+" "+L2ADir+" 1")
text =""
linksDir=cfg["projectDir"]+"L2A/"
while text != "yes" and text != "no":
text = raw_input("Do you want to link this products to "+outdir+ " ? (yes, no)")
text = raw_input("Do you want to link this products to "+linksDir+ " ? (yes, no)")
if text=="yes":
fileNames = [productList[k]['filename'].replace("SAFE", "zip").replace("L1C", "L2A") for k in productList.keys() ]
dirList = os.listdir(L2ADir)
matchingProducts = set(fileNames).intersection(set(dirList))
for f in matchingProducts:
print (f)
os.system("ln -s " + inDir+f + " " + outdir+f)
print (str(len(matchingProducts)) + " Linked to " + outdir)
os.system("ln -s " + L2ADir+f + " " + linksDir+f)
print (str(len(matchingProducts)) + " Linked to " + linksDir)
if __name__ == "__main__":
main(sys.argv)
......
......@@ -34,8 +34,7 @@ def imageMissingData(filename, wkt):
data = np.bitwise_and(data, rasterwkt)
inputImage = None
return (data>0).sum()/(rasterwkt>0).sum()
return (data>0).sum()/float((rasterwkt>0).sum())
#-------------------------------------------------------------------------------
def main(argv):
......
......@@ -160,7 +160,6 @@ else
cd ../TCI
done
fi
#6.-Creating Thumbnails
echo ${RED}"Creating Thumbnails"${NC}
if [ $BYTILE -ne "0" ]; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment