def get_arguments(): """ Manages inputs :return: """ argParser = argparse.ArgumentParser() argParser.add_argument('-i', '--input_metadata', required=True, help='Path to input MNT') argParser.add_argument('-s', "--sensor", choices=['s2', 'l8'], required=True) argParser.add_argument('-w', '--working_directory', required=True, help='Path to working directory') args = argParser.parse_args(sys.argv[1:]) input_metadata = os.path.realpath(args.input_metadata) sensor = args.sensor working_dir = args.working_directory logger.debug("Arguments ok") logger.debug("Managing output directories") # checking existence of input mnt if not os.path.isfile(input_metadata): print "ERROR: Missing input metadata" usage(argParser) # creating directory if it does not exist if not os.path.isdir(working_dir): os.mkdir(working_dir) return input_metadata, sensor, working_dir
def get_arguments(): """ Manages inputs :return: """ logger.debug("Checking arguments") argParser = argparse.ArgumentParser() argParser.add_argument('-i', '--input_mnt', required=True, help='Path to input MNT') argParser.add_argument('-w', '--working_directory', required=True, help='Path to working directory') args = argParser.parse_args(sys.argv[1:]) input_mnt = os.path.realpath(args.input_mnt) working_dir = args.working_directory logger.debug("Arguments ok") logger.debug("Managing output directories") # checking existence of input mnt if not os.path.isfile(input_mnt): print "ERROR: Missing input image" usage(argParser) # creating directory if it does not exist if not os.path.isdir(working_dir): os.mkdir(working_dir) return input_mnt, working_dir
def get_arguments(): """ Manages inputs :return: """ argParser = argparse.ArgumentParser() argParser.add_argument('-i', '--input_metadata', required=True, help='Path to input image') argParser.add_argument('-d', '--srtm_directory', required=True, help='Path to SRTM directory') argParser.add_argument('-w', '--working_directory', required=True, help='Path to working directory') argParser.add_argument('-s', "--sensor", choices=['s2', 'l8'], required=True) args = argParser.parse_args(sys.argv[1:]) input_metadata = os.path.realpath(args.input_metadata) sensor = args.sensor srtm_dir = args.srtm_directory working_dir = args.working_directory # creating directories if they don't exist if not os.path.isdir(working_dir): os.mkdir(working_dir) # checking srtm directory existence if not os.path.isdir(srtm_dir): print "ERROR srtm dir is missing" usage(argParser) # checking if inputs exists if not input_metadata or not os.path.isfile(input_metadata): print "input directory missing" sys.exit(2) return input_metadata, srtm_dir, working_dir, sensor
def get_arguments(): """ Manages inputs :return: """ argParser = argparse.ArgumentParser() argParser.add_argument('-i', '--input_mnt', required=True, help='Path to input MNT') argParser.add_argument('-s', '--support_image', required=True, help='Image at RX resolution') argParser.add_argument('-o', '--output_mnt', required=True, help='Path to output mnt') args = argParser.parse_args(sys.argv[1:]) input_mnt = os.path.realpath(args.input_mnt) support_image = os.path.realpath(args.support_image) working_dir = args.working_directory logger.debug("Arguments ok") logger.debug("Managing output directories") # checking existence of input mnt if not os.path.isfile(input_mnt): print "ERROR: Missing input MNT" usage(argParser) # checking support image if not os.path.isdir(support_image): print "ERROR: Support image is missing" usage(argParser) return input_mnt, support_image, output_mnt
def get_arguments(): """ Manages inputs :return: """ argParser = argparse.ArgumentParser() argParser.add_argument('-i', '--input_mnt', required=True, help='Path to input MNT') argParser.add_argument('-w', '--working_directory', required=True, help='Path to working directory') # argParser.add_argument('-s', '--slope', required=True, # help='Path to output slope file') # argParser.add_argument('-a', '--aspect', required=True, # help='Path to output aspect file') args = argParser.parse_args(sys.argv[1:]) input_mnt = os.path.realpath(args.input_mnt) # slope = os.path.realpath(args.slope) # aspect = os.path.realpath(args.aspect) working_dir = os.path.realpath(args.working_directory) # checking input mnt if not input_mnt or not os.path.isfile(input_mnt): print "Input mnt is missing" usage(argParser) sys.exit(2) # creating directory if it does not exist if not os.path.isdir(working_dir): os.mkdir(working_dir) logger.debug("Arguments ok") return input_mnt, working_dir # slope, aspect
def get_arguments(): """ Manages inputs :return: """ # ####### MANAGING ARGUMENTS ######## # TODO : set path to downloadwb as an argument # check inputs logger.info("######## MANAGING ARGUMENTS ########") logger.debug("Checking arguments") argParser = argparse.ArgumentParser() argParser.add_argument('-i', '--input_directory', help='Path to input directory') argParser.add_argument('-z', '--input_zone_directory', help='Path to input directory') argParser.add_argument('-s', "--sensor", choices=['s2', 'l8'], required=True) input_directory = input_zone = None logger.debug(len(sys.argv)) if len(sys.argv) != 3: print "Nb args = ", len(sys.argv), " required: 3." usage(argParser) args = argParser.parse_args(sys.argv[1:]) input_directory = args.input_directory input_zone = args.input_zone_directory sensor = args.sensor logger.debug("Arguments ok") if input_directory: input_directory = os.path.realpath(input_directory) # creating directories if they don't exist logger.debug("Managing input directories") if not os.path.isdir(input_directory): usage(argParser) sys.exit(2) if input_zone: input_zone = os.path.realpath(input_zone) # creating directories if they don't exist logger.debug("Managing input directories") if not os.path.isdir(input_zone): usage(argParser) sys.exit(2) display_parameters(locals(), "checkdem_get_arguments") return input_directory, input_zone, sensor
def get_arguments(): """ Manages inputs :return: """ argParser = argparse.ArgumentParser() argParser.add_argument('-i', '--input_zone', required=True, help='Path to input zone ex: /media/Input/China/') argParser.add_argument('-o', '--output_directory', required=True, help='Path to output directory ex: /tmp/') argParser.add_argument('-d', '--srtm_directory', required=True, help='Path to SRTM directory ex: /media/mysrtm ') argParser.add_argument('-w', '--working_directory', required=True, help='Path to working directory ex: /tmp/wd') argParser.add_argument('-s', "--sensor", choices=['s2', 'l8'], required=True) argParser.add_argument( '-v', '--l8_vector', help='Path to l8 vector ex: wrs2_descending/wrs2_descending.shp') args = argParser.parse_args(sys.argv[1:]) input_zone = os.path.realpath(args.input_zone) sensor = args.sensor srtm_dir = args.srtm_directory working_dir = args.working_directory l8_vector = args.l8_vector output_directory = os.path.realpath(args.output_directory) # creating directories if they don't exist wd_zone = os.path.join(working_dir, os.path.basename(input_zone)) if not os.path.isdir(wd_zone): os.makedirs(wd_zone) out_zone = os.path.join(output_directory, os.path.basename(input_zone)) if not os.path.isdir(out_zone): os.makedirs(out_zone) # checking srtm directory existence if not os.path.isdir(srtm_dir): print "ERROR srtm dir is missing" usage(argParser) if sensor == "l8" and not args.l8_vector: print "Missing L8 extent vector" usage(argParser) # checking if inputs exists if not input_zone or not os.path.isdir(input_zone): print "input metadata are missing" sys.exit(2) return input_zone, srtm_dir, wd_zone, sensor, l8_vector, out_zone
def get_arguments(): """ Manages inputs :return: """ # ####### MANAGING ARGUMENTS ######## # TODO : set path to downloadwb as an argument # check inputs logger.info("######## MANAGING ARGUMENTS ########") logger.debug("Checking arguments") argParser = argparse.ArgumentParser() required_arguments = argParser.add_argument_group('required arguments') required_arguments.add_argument('-i', '--input_directory', required=True, help='Path to input image') required_arguments.add_argument('-o', '--output_directory', required=True, help='Path to output directory') required_arguments.add_argument('-v', '--l8_vector', required=True, help='Path to l8 vector ex: wrs2_descending/wrs2_descending.shp') required_arguments.add_argument('-w', '--working_directory', required=True, help='Path to working directory') required_arguments.add_argument('-t', '--tile_id', required=True, help='Current product tile id') logger.debug(len(sys.argv)) if len(sys.argv) != 11: usage(argParser) args = argParser.parse_args(sys.argv[1:]) input_directory = os.path.realpath(args.input_directory) output_directory = os.path.realpath(args.output_directory) l8_vector = args.l8_vector working_dir = args.working_directory tile_id = args.tile_id logger.debug("Arguments ok") # crating directories if they don't exist logger.debug("Managing output directories") if not os.path.isdir(output_directory): os.mkdir(output_directory) if not os.path.isdir(working_dir): os.mkdir(working_dir) if not os.path.isdir(input_directory): print "Error, input dir is missing " usage(argParser, 2) logger.debug("Output directories ok") # checking if inputs exist if not input_directory: print "input image missing" sys.exit(2) if not l8_vector: print "l8_vector missing" sys.exit(2) # get path, row of the product txt = os.path.join(input_directory, tile_id + "_MTL.txt") path, row = getPathRowFromMTL(txt) display_parameters(locals(), "l8_align_get_arguments") return input_directory, l8_vector, output_directory, working_dir, path, row