Commit 9f209e69 authored by Pedro Alfonso Ramirez's avatar Pedro Alfonso Ramirez

Add unzip

parent a065bda4
...@@ -36,7 +36,7 @@ Functions: ...@@ -36,7 +36,7 @@ Functions:
from argparse import ArgumentParser from argparse import ArgumentParser
import os import os
import zipfile
from collections import OrderedDict from collections import OrderedDict
...@@ -71,31 +71,31 @@ SENTINEL_FIND_ARGUMENTS = ArgumentParser(add_help=False) ...@@ -71,31 +71,31 @@ SENTINEL_FIND_ARGUMENTS = ArgumentParser(add_help=False)
SENTINEL_FIND_ARGUMENTS.add_argument("folder", help="Folder to find Sentinel files ") SENTINEL_FIND_ARGUMENTS.add_argument("folder", help="Folder to find Sentinel files ")
SENTINEL_FIND_ARGUMENTS.add_argument("plattform", help="sentinel-1 or sentinel-2") SENTINEL_FIND_ARGUMENTS.add_argument("plattform", help="Sentinel-1 or Sentinel-2")
SENTINEL_UNZIP_ARGUMENTS = ArgumentParser(add_help=False) SENTINEL_UNZIP_ARGUMENTS = ArgumentParser(add_help=False)
SENTINEL_UNZIP_ARGUMENTS.add_argument("folder", help="Folder to find Sentinel files") SENTINEL_UNZIP_ARGUMENTS.add_argument("folder", help="Folder to find Sentinel files")
SENTINEL_UNZIP_ARGUMENTS.add_argument("plattform", help="sentinel-1 or sentinel-2") 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 {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 find_files(args): def find_files(args):
folder = args.folder folder = args.folder
satelite = args.plattform satelite = args.plattform
files = os.listdir(folder) files = os.listdir(folder)
if(satelite=="Sentinel-1"): if(satelite=="Sentinel-1"):
namfil1 = 'S1A_' namfil1 = 'S1A_'+ args.product_type
namfil2 = 'S1B_' namfil2 = 'S1B_'+ args.product_type
files = [f for f in files if f.startswith(namfil1) or f.startswith(namfil2)]
if(satelite=="Sentinel-2"): if(satelite=="Sentinel-2"):
namfil1 = 'S2A_' namfil1 = 'S2A_'+ args.product_type
namfil2 = 'S2B_' namfil2 = 'S2B_'+ args.product_type
files = [f for f in files if f.startswith(namfil1) or f.startswith(namfil2)] files = [f for f in files if f.startswith(namfil1) or f.startswith(namfil2)]
if(len(files)==0):
print"Files not found..."
return files return files
def unzip(list_files,args): def unzip(list_files,args):
......
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