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

update

parent 13f2a486
...@@ -28,8 +28,8 @@ from datetime import date ...@@ -28,8 +28,8 @@ from datetime import date
# products = sentinel.getProducts(wkt, (startDate, endDate), {"platformname":platform, "cloudcoverpercentage":"[0 TO "+str(cloud)+"]"}) # products = sentinel.getProducts(wkt, (startDate, endDate), {"platformname":platform, "cloudcoverpercentage":"[0 TO "+str(cloud)+"]"})
# return products # return products
productsCodes = {"L1C":"L1C","L2A":"L1C"} #productsCodes = {"L1C":"L1C","L2A":"L1C"}
productType = {"L1C":"S2MSI1C", "L2A":"S2MSI2A"}
def main(argv): def main(argv):
if len(sys.argv) != 2: if len(sys.argv) != 2:
...@@ -41,36 +41,59 @@ def main(argv): ...@@ -41,36 +41,59 @@ def main(argv):
sentinel = APISentinel.APISentinel(cfg['username'], cfg['password']) sentinel = APISentinel.APISentinel(cfg['username'], cfg['password'])
wkt = polygonToBox.getWKTPolygonBoundingBox(cfg['wkt'], True) 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: if len(productList)<=0:
print ("No products found with 'Contains' trying with 'Intersects'") 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'])+"]"}) 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() ]
inDir = cfg["productsDir"] # fileNames = [productList[k]['filename'].replace("SAFE", "zip").replace(productsCodes[cfg['productLevel']], cfg['productLevel']) for k in productList.keys() ]
outdir = cfg["linksDir"] fileNames = [productList[k]['filename'].replace("SAFE", "zip") for k in productList.keys() ]
dirList = os.listdir(inDir)
downloadDir = cfg["productsDir"]+cfg["productLevel"]+"/"
dirList = os.listdir(downloadDir)
matchingProducts = set(fileNames).intersection(set(dirList)) matchingProducts = set(fileNames).intersection(set(dirList))
print ( str(len(matchingProducts))+" of " + str(len(fileNames)) +" products found.") print ( str(len(matchingProducts))+" of " + str(len(fileNames)) +" "+ cfg["productLevel"] + " products found.")
rawDir = inDir.replace(cfg['productLevel'],productsCodes[cfg['productLevel']]) # rawDir = inDir.replace(cfg['productLevel'],productsCodes[cfg['productLevel']])
print(rawDir)
# print(rawDir)
text ="" text =""
while text != "yes" and text != "no": 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": if text=="yes":
#sentinel.downloadProducts(productList,rawDir) sentinel.downloadProducts(productList,downloadDir)
print("L1CProductListToL2A.sh "+rawDir+" "+inDir+" 1")
#os.system("L1CProductListToL2A.sh "+rawDir+" "+inDir+" 1")
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 ="" text =""
linksDir=cfg["projectDir"]+"L2A/"
while text != "yes" and text != "no": 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": 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: for f in matchingProducts:
print (f) print (f)
os.system("ln -s " + inDir+f + " " + outdir+f) os.system("ln -s " + L2ADir+f + " " + linksDir+f)
print (str(len(matchingProducts)) + " Linked to " + outdir) print (str(len(matchingProducts)) + " Linked to " + linksDir)
if __name__ == "__main__": if __name__ == "__main__":
main(sys.argv) main(sys.argv)
......
...@@ -34,8 +34,7 @@ def imageMissingData(filename, wkt): ...@@ -34,8 +34,7 @@ def imageMissingData(filename, wkt):
data = np.bitwise_and(data, rasterwkt) data = np.bitwise_and(data, rasterwkt)
inputImage = None inputImage = None
return (data>0).sum()/float((rasterwkt>0).sum())
return (data>0).sum()/(rasterwkt>0).sum()
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
def main(argv): def main(argv):
......
...@@ -160,7 +160,6 @@ else ...@@ -160,7 +160,6 @@ else
cd ../TCI cd ../TCI
done done
fi fi
#6.-Creating Thumbnails #6.-Creating Thumbnails
echo ${RED}"Creating Thumbnails"${NC} echo ${RED}"Creating Thumbnails"${NC}
if [ $BYTILE -ne "0" ]; then 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