Commit d1efcf2f authored by Adan Salazar Garibay's avatar Adan Salazar Garibay

working with unzip files

parents 6f083144 8eb0aa57
......@@ -23,7 +23,7 @@ Example of unzip Sentinel files in a specific directory
"""
from argparse import ArgumentParser
from geosentinel.ui_utils import (find_files, unzip, SENTINEL_UNZIP_ARGUMENTS)
from geosentinel.ui_utils import (find_files_Sentinel, unzip_files_Sentinel, SENTINEL_UNZIP_ARGUMENTS)
def main():
......@@ -39,8 +39,8 @@ def main():
args = parser.parse_args()
list_files = find_files(args)
unzip(list_files,args)
list_files = find_files_Sentinel(args)
unzip_files_Sentinel(list_files,args)
#print list_files
......
......@@ -26,9 +26,11 @@ Variables:
Functions:
* "find_files" - Discover Sentinel files in directory
* "find_files_Sentinel" - Discover Sentinel files in directory
* "unzip_files_Sentinel" - Unzip Sentinel files in directory
* "download_sentinel_mages" - Calibrate chessboard images discovered in a folder
* "check_existing_directory" - Check out if the folder exist. Create folder if it does not exist
* "check_existing_productType" - Check args if exist
* "select_products" - # Select products that their intersection area is less than a certain percentage threshold
"""
......@@ -80,30 +82,49 @@ SENTINEL_UNZIP_ARGUMENTS.add_argument("folder", help="Folder to find Sentinel fi
SENTINEL_UNZIP_ARGUMENTS.add_argument("plattform", help="Sentinel-1 or Sentinel-2")
SENTINEL_UNZIP_ARGUMENTS.add_argument("product_type", help="sentinel product type {SM_SLC, SM_GRDF, SM_GRDH, SM_GRDM, IW_SLC, IW_GRDH, IW_GDRM, EW_SLC, EW_GRDH, EW_GRDM, WV_SLC, WV_GRDM, MSIL1C, OPER_PRD }")
SENTINEL_UNZIP_ARGUMENTS.add_argument("product_type", help="sentinel product type {all, SM_SLC, SM_GRDF, SM_GRDH, SM_GRDM, IW_SLC, IW_GRDH, IW_GDRM, EW_SLC, EW_GRDH, EW_GRDM, WV_SLC, WV_GRDM, MSIL1C, OPER_PRD }")
def check_existing_productType(product,flag):
if(flag==1):
plattform=['Sentinel-1', 'sentinel-1', 'Sentinel-2', 'sentinel-2']
findProduct = product in plattform
if not findProduct:
print product + " not exist"
sys.exit()
if(flag==2):
product_type=["all", "SM_SLC", "SM_GRDF", "SM_GRDH", "SM_GRDM", "IW_SLC", "IW_GRDH", "IW_GDRM", "EW_SLC", "EW_GRDH", "EW_GRDM", "WV_SLC", "WV_GRDM", "MSIL1C", "OPER_PRD"]
findProduct = product in product_type
if not findProduct:
print product + " not exist"
sys.exit()
def find_files(args):
check_existing_directory(args.folder, 2)
def find_files_Sentinel(args):
folder = args.folder
satelite = args.plattform
satellite = args.plattform
product_typ = args.product_type
check_existing_directory(folder, 2)
check_existing_productType(satellite, 1)
check_existing_productType(product_typ, 2)
files = os.listdir(folder)
if(satelite!="Sentinel-1") or (satelite!="sentinel-1") or (satelite=="Sentinel-2") or (satelite=="sentinel-2"):
print satelite + " not exist"
sys.exit()
if (args.product_type == "all"):
namfil1 = 'S1A_'
namfil2 = 'S1B_'
namfil3 = 'S2A_'
namfil4 = 'S2B_'
files = [f for f in files if f.startswith(namfil1) or f.startswith(namfil2) or f.startswith(namfil3) or f.startswith(namfil4)]
else:
if(satelite=="Sentinel-1")or(satelite=="sentinel-1"):
if(satellite=="Sentinel-1")or(satellite=="sentinel-1"):
namfil1 = 'S1A_'+ args.product_type
namfil2 = 'S1B_'+ args.product_type
if(satelite=="Sentinel-2")or(satelite=="sentinel-2"):
if(satellite=="Sentinel-2")or(satellite=="sentinel-2"):
namfil1 = 'S2A_'+ args.product_type
namfil2 = 'S2B_'+ args.product_type
files = [f for f in files if f.startswith(namfil1) or f.startswith(namfil2)]
if(len(files)==0):
if (len(files) == 0):
print"Files not found..."
return files
def unzip(list_files,args):
def unzip_files_Sentinel(list_files,args):
for image in list_files:
print"Unzziped... ",image
File = args.folder + "\\" +image
......@@ -125,7 +146,6 @@ def check_existing_directory(folder,flag):
sys.exit()
def select_products( products_list , products_df, user_footprint, threshold ) :
......
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