""" Module checking the input parameter """ from argparse import ArgumentParser, FileType, RawTextHelpFormatter from .io import test_coordiantes def arg_parser(): """ Argument parser of input line Returns: ArgumentParser.arguments """ parser = ArgumentParser( prog="tws_covariances.sh", description="Programm to compute the covariances of given region and return the " "standard deviation of the mean TWS of this region and/or the full " "covariance matrix", formatter_class=RawTextHelpFormatter, ) parser.add_argument( "-f", "--filename", required=True, type=FileType(), help="Filename of the netcdf TWS input file, as downloaded from gravis.gfz-potsdam.de" ) parser.add_argument( "-r", "--region", required=True, type=FileType(), help="Filename of the ascii file defining the requested region. List of coordinates " "lon, lat, each line one coordinate." "Coordinates have to be on an even spaced grid. Comment lines have to start with '#'. " ) parser.add_argument( "-o", "--output", required=True, type=str, help="Filename of the netcdf output file" ) parser.add_argument( "-m", "--matrix", action="store_true", help="Return full covariance matrix" ) parser.add_argument( "-u", "--uncertainty", action="store_true", help="Return time series of standard deviations for mean TWS time series" ) parser.add_argument( "-t", "--timeseries", action="store_true", help="Return mean TWS time series" ) args = parser.parse_args() if not args.matrix and not args.uncertainty and not args.timeseries: raise RuntimeError("Either covariance matrix (-m) or uncertainties (-u) or timeseries (-t) " "have to be set for the output!") test_coordiantes(args.region.name) return args