diff --git a/docs/atacr.rst b/docs/atacr.rst index d49a90b..e10797b 100644 --- a/docs/atacr.rst +++ b/docs/atacr.rst @@ -251,20 +251,28 @@ Usage Server Settings: Settings associated with which datacenter to log into. - -S SERVER, --server SERVER - Specify the server to connect to. Options include: - BGR, ETH, GEONET, GFZ, INGV, IPGP, IRIS, KOERI, LMU, - NCEDC, NEIP, NERIES, ODC, ORFEUS, RESIF, SCEDC, USGS, - USP. [Default IRIS] - --server-url SERVER_URL - Specify the obspy base_url server address (and port if - needed) to open for the fdsn client. Overrides any - settings to '--server'. [Default None] - -U USERAUTH, --user-auth USERAUTH - Enter your Authentification Username and Password - (--user-auth='username:authpassword') to access and - download restricted data. [Default no user and - password] + --server SERVER Base URL of FDSN web service compatible server (e.g. + “http://service.iris.edu”) or key string for + recognized server (one of 'AUSPASS', 'BGR', + 'EARTHSCOPE', 'EIDA', 'EMSC', 'ETH', 'GEOFON', + 'GEONET', 'GFZ', 'ICGC', 'IESDMC', 'INGV', 'IPGP', + 'IRIS', 'IRISPH5', 'ISC', 'KNMI', 'KOERI', 'LMU', + 'NCEDC', 'NIEP', 'NOA', 'NRCAN', 'ODC', 'ORFEUS', + 'RASPISHAKE', 'RESIF', 'RESIFPH5', 'SCEDC', 'TEXNET', + 'UIB-NORSAR', 'USGS', 'USP'). [Default 'IRIS'] + --user-auth USERAUTH Authentification Username and Password for the + waveform server (--user-auth='username:authpassword') + to access and download restricted data. [Default no + user and password] + --eida-token TOKENFILE + Token for EIDA authentication mechanism, see + http://geofon.gfz- + potsdam.de/waveform/archive/auth/index.php. If a token + is provided, argument --user-auth will be ignored. + This mechanism is only available on select EIDA nodes. + The token can be provided in form of the PGP message + as a string, or the filename of a local file with the + PGP message in it. [Default None] Frequency Settings: Miscellaneous frequency settings @@ -586,21 +594,29 @@ Usage Server Settings: Settings associated with which datacenter to log into. - -S SERVER, --server SERVER - Specify the server to connect to. Options include: - BGR, ETH, GEONET, GFZ, INGV, IPGP, IRIS, KOERI, LMU, - NCEDC, NEIP, NERIES, ODC, ORFEUS, RESIF, SCEDC, USGS, - USP. [Default IRIS] - --server-url SERVER_URL - Specify the obspy base_url server address (and port if - needed) to open for the fdsn client. Overrides any - settings to '--server'. [Default None] - -U USERAUTH, --user-auth USERAUTH - Enter your Authentification Username and Password - (--user-auth='username:authpassword') to access and - download restricted data. [Default no user and - password] - + --server SERVER Base URL of FDSN web service compatible server (e.g. + “http://service.iris.edu”) or key string for + recognized server (one of 'AUSPASS', 'BGR', + 'EARTHSCOPE', 'EIDA', 'EMSC', 'ETH', 'GEOFON', + 'GEONET', 'GFZ', 'ICGC', 'IESDMC', 'INGV', 'IPGP', + 'IRIS', 'IRISPH5', 'ISC', 'KNMI', 'KOERI', 'LMU', + 'NCEDC', 'NIEP', 'NOA', 'NRCAN', 'ODC', 'ORFEUS', + 'RASPISHAKE', 'RESIF', 'RESIFPH5', 'SCEDC', 'TEXNET', + 'UIB-NORSAR', 'USGS', 'USP'). [Default 'IRIS'] + --user-auth USERAUTH Authentification Username and Password for the + waveform server (--user-auth='username:authpassword') + to access and download restricted data. [Default no + user and password] + --eida-token TOKENFILE + Token for EIDA authentication mechanism, see + http://geofon.gfz- + potsdam.de/waveform/archive/auth/index.php. If a token + is provided, argument --user-auth will be ignored. + This mechanism is only available on select EIDA nodes. + The token can be provided in form of the PGP message + as a string, or the filename of a local file with the + PGP message in it. [Default None] + Frequency Settings: Miscellaneous frequency settings diff --git a/docs/index.rst b/docs/index.rst index f4bb01c..9a44af8 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -17,7 +17,7 @@ can be used through command-line scripts. .. image:: https://github.com/nfsi-canada/OBStools/workflows/Build/badge.svg :target: https://github.com/nfsi-canada/OBStools/actions .. image:: https://codecov.io/gh/nfsi-canada/OBStools/branch/master/graph/badge.svg - :target: https://codecov.io/gh/nfsi-canada/OBStools + :target: https://codecov.io/gh/nfsi-canada/OBStools .. toctree:: :maxdepth: 1 diff --git a/obstools/scripts/atacr_download_data.py b/obstools/scripts/atacr_download_data.py index edaaf5b..e0cecbe 100644 --- a/obstools/scripts/atacr_download_data.py +++ b/obstools/scripts/atacr_download_data.py @@ -109,33 +109,39 @@ def get_daylong_arguments(argv=None): description="Settings associated with which " "datacenter to log into.") ServerGroup.add_argument( - "-S", "--server", + "--server", action="store", type=str, dest="server", default="IRIS", - help="Specify the server to connect to. Options include: " + - "BGR, ETH, GEONET, GFZ, INGV, IPGP, IRIS, KOERI, LMU, NCEDC, " + - "NEIP, NERIES, ODC, ORFEUS, RESIF, SCEDC, USGS, USP. " + - "[Default IRIS]") + help="Base URL of FDSN web service compatible " + "server (e.g. “http://service.iris.edu”) or key string for recognized " + "server (one of 'AUSPASS', 'BGR', 'EARTHSCOPE', 'EIDA', 'EMSC', 'ETH', " + "'GEOFON', 'GEONET', 'GFZ', 'ICGC', 'IESDMC', 'INGV', 'IPGP', 'IRIS', " + "'IRISPH5', 'ISC', 'KNMI', 'KOERI', 'LMU', 'NCEDC', 'NIEP', 'NOA', " + "'NRCAN', 'ODC', 'ORFEUS', 'RASPISHAKE', 'RESIF', 'RESIFPH5', 'SCEDC', " + "'TEXNET', 'UIB-NORSAR', 'USGS', 'USP'). [Default 'IRIS']") ServerGroup.add_argument( - "--server-url", + "--user-auth", action="store", type=str, - dest="server_url", + dest="userauth", default=None, - help="Specify the obspy base_url server address (and port if needed) " + - "to open for the fdsn client. Overrides any settings to '--server'. " + - "[Default None]") + help="Authentification Username and Password for the " + + "waveform server (--user-auth='username:authpassword') to access " + + "and download restricted data. [Default no user and password]") ServerGroup.add_argument( - "-U", "--user-auth", - action="store", + "--eida-token", + action="store", type=str, - dest="userauth", - default="", - help="Enter your Authentification Username and Password " + - "(--user-auth='username:authpassword') to access and download " + - "restricted data. [Default no user and password]") + dest="tokenfile", + default=None, + help="Token for EIDA authentication mechanism, see " + + "http://geofon.gfz-potsdam.de/waveform/archive/auth/index.php. " + "If a token is provided, argument --user-auth will be ignored. " + "This mechanism is only available on select EIDA nodes. The token can " + "be provided in form of the PGP message as a string, or the filename of " + "a local file with the PGP message in it. [Default None]") """ # Database Settings @@ -258,17 +264,20 @@ def get_daylong_arguments(argv=None): else: args.endT = None - # Parse User Authentification - if not len(args.userauth) == 0: - tt = args.userauth.split(':') - if not len(tt) == 2: - parser.error( - "Error: Incorrect Username and Password Strings for " + - "User Authentification") - else: - args.userauth = tt + # Parse restricted data settings + if args.tokenfile is not None: + args.userauth = [None, None] else: - args.userauth = [] + if args.userauth is not None: + tt = args.userauth.split(':') + if not len(tt) == 2: + msg = ("Error: Incorrect Username and Password Strings for User " + "Authentification") + parser.error(msg) + else: + args.userauth = tt + else: + args.userauth = [None, None] # # Parse Local Data directories # if args.localdata is not None: @@ -283,17 +292,19 @@ def get_daylong_arguments(argv=None): # args.ndval = nan if args.units not in ['DISP', 'VEL', 'ACC']: - raise(Exception( - "Error: invalid --units argument. Choose among " + - "'DISP', 'VEL', or 'ACC'")) + msg = ("Error: invalid --units argument. Choose among " + "'DISP', 'VEL', or 'ACC'") + parser.error(msg) + if args.pre_filt is None: args.pre_filt = [0.001, 0.005, 45., 50.] else: args.pre_filt = [float(val) for val in args.pre_filt.split(',')] args.pre_filt = sorted(args.pre_filt) if (len(args.pre_filt)) != 4: - raise(Exception( - "Error: --pre-filt should contain 4 comma-separated floats")) + msg = ("Error: --pre-filt should contain 4 " + "comma-separated floats") + parser.error(msg) return args @@ -339,24 +350,11 @@ def main(args=None): datapath.mkdir(parents=True) # Establish client - if len(args.userauth) == 0: - if args.server_url is not None: - client = Client( - base_url=args.server_url) - else: - client = Client( - args.server) - else: - if args.server_url is not None: - client = Client( - base_url=args.server_url, - user=args.userauth[0], - password=args.userauth[1]) - else: - client = Client( - args.server, - user=args.userauth[0], - password=args.userauth[1]) + client = Client( + base_url=args.server, + user=args.userauth[0], + password=args.userauth[1], + eida_token=args.tokenfile) # Get catalogue search start time if args.startT is None: diff --git a/obstools/scripts/atacr_download_event.py b/obstools/scripts/atacr_download_event.py index a82fd76..48c87fc 100644 --- a/obstools/scripts/atacr_download_event.py +++ b/obstools/scripts/atacr_download_event.py @@ -112,33 +112,39 @@ def get_event_arguments(argv=None): description="Settings associated with which " "datacenter to log into.") ServerGroup.add_argument( - "-S", "--server", + "--server", action="store", type=str, dest="server", default="IRIS", - help="Specify the server to connect to. Options include: " + - "BGR, ETH, GEONET, GFZ, INGV, IPGP, IRIS, KOERI, LMU, NCEDC, " + - "NEIP, NERIES, ODC, ORFEUS, RESIF, SCEDC, USGS, USP. " + - "[Default IRIS]") + help="Base URL of FDSN web service compatible " + "server (e.g. “http://service.iris.edu”) or key string for recognized " + "server (one of 'AUSPASS', 'BGR', 'EARTHSCOPE', 'EIDA', 'EMSC', 'ETH', " + "'GEOFON', 'GEONET', 'GFZ', 'ICGC', 'IESDMC', 'INGV', 'IPGP', 'IRIS', " + "'IRISPH5', 'ISC', 'KNMI', 'KOERI', 'LMU', 'NCEDC', 'NIEP', 'NOA', " + "'NRCAN', 'ODC', 'ORFEUS', 'RASPISHAKE', 'RESIF', 'RESIFPH5', 'SCEDC', " + "'TEXNET', 'UIB-NORSAR', 'USGS', 'USP'). [Default 'IRIS']") ServerGroup.add_argument( - "--server-url", + "--user-auth", action="store", type=str, - dest="server_url", + dest="userauth", default=None, - help="Specify the obspy base_url server address (and port if needed) " + - "to open for the fdsn client. Overrides any settings to '--server'. " + - "[Default None]") + help="Authentification Username and Password for the " + + "waveform server (--user-auth='username:authpassword') to access " + + "and download restricted data. [Default no user and password]") ServerGroup.add_argument( - "-U", "--user-auth", - action="store", + "--eida-token", + action="store", type=str, - dest="userauth", - default="", - help="Enter your Authentification Username and Password " + - "(--user-auth='username:authpassword') to access and download " + - "restricted data. [Default no user and password]") + dest="tokenfile", + default=None, + help="Token for EIDA authentication mechanism, see " + + "http://geofon.gfz-potsdam.de/waveform/archive/auth/index.php. " + "If a token is provided, argument --user-auth will be ignored. " + "This mechanism is only available on select EIDA nodes. The token can " + "be provided in form of the PGP message as a string, or the filename of " + "a local file with the PGP message in it. [Default None]") # Constants Settings FreqGroup = parser.add_argument_group( @@ -301,17 +307,25 @@ def get_event_arguments(argv=None): else: args.endT = None - # Parse User Authentification - if not len(args.userauth) == 0: - tt = args.userauth.split(':') - if not len(tt) == 2: - parser.error( - "Error: Incorrect Username and Password Strings for User " + - "Authentification") - else: - args.userauth = tt + # Parse restricted data settings + if args.tokenfile is not None: + args.userauth = [None, None] else: - args.userauth = [] + if args.userauth is not None: + tt = args.userauth.split(':') + if not len(tt) == 2: + msg = ("Error: Incorrect Username and Password Strings for User " + "Authentification") + parser.error(msg) + else: + args.userauth = tt + else: + args.userauth = [None, None] + + if args.units not in ['DISP', 'VEL', 'ACC']: + msg = ("Error: invalid --units argument. Choose among " + "'DISP', 'VEL', or 'ACC'") + parser.error(msg) if args.pre_filt is None: args.pre_filt = [0.001, 0.005, 45., 50.] @@ -319,9 +333,9 @@ def get_event_arguments(argv=None): args.pre_filt = [float(val) for val in args.pre_filt.split(',')] args.pre_filt = sorted(args.pre_filt) if (len(args.pre_filt)) != 4: - raise(Exception( - "Error: --pre-filt should contain 4 " + - "comma-separated floats")) + msg = ("Error: --pre-filt should contain 4 " + "comma-separated floats") + parser.error(msg) return args @@ -367,24 +381,14 @@ def main(args=None): eventpath.mkdir(parents=True) # Establish client - if len(args.userauth) == 0: - if args.server_url is not None: - client = Client( - base_url=args.server_url) - else: - client = Client( - args.server) - else: - if args.server_url is not None: - client = Client( - base_url=args.server_url, - user=args.userauth[0], - password=args.userauth[1]) - else: - client = Client( - args.server, - user=args.userauth[0], - password=args.userauth[1]) + client = Client( + base_url=args.server, + user=args.userauth[0], + password=args.userauth[1], + eida_token=args.tokenfile) + + # Establish client for events - Default is 'IRIS'' + event_client = Client() # Get catalogue search start time if args.startT is None: @@ -442,7 +446,7 @@ def main(args=None): print("| ... |") # Get catalogue using deployment start and end - cat = client.get_events( + cat = event_client.get_events( starttime=tstart, endtime=tend, minmagnitude=args.minmag, maxmagnitude=args.maxmag)