Skip to content

Commit 30e58dc

Browse files
authored
Merge pull request #45 from nfsi-canada/v015
updated script args for server settings
2 parents e1b2610 + b06a20b commit 30e58dc

File tree

4 files changed

+147
-129
lines changed

4 files changed

+147
-129
lines changed

docs/atacr.rst

+45-29
Original file line numberDiff line numberDiff line change
@@ -251,20 +251,28 @@ Usage
251251
Server Settings:
252252
Settings associated with which datacenter to log into.
253253
254-
-S SERVER, --server SERVER
255-
Specify the server to connect to. Options include:
256-
BGR, ETH, GEONET, GFZ, INGV, IPGP, IRIS, KOERI, LMU,
257-
NCEDC, NEIP, NERIES, ODC, ORFEUS, RESIF, SCEDC, USGS,
258-
USP. [Default IRIS]
259-
--server-url SERVER_URL
260-
Specify the obspy base_url server address (and port if
261-
needed) to open for the fdsn client. Overrides any
262-
settings to '--server'. [Default None]
263-
-U USERAUTH, --user-auth USERAUTH
264-
Enter your Authentification Username and Password
265-
(--user-auth='username:authpassword') to access and
266-
download restricted data. [Default no user and
267-
password]
254+
--server SERVER Base URL of FDSN web service compatible server (e.g.
255+
“http://service.iris.edu”) or key string for
256+
recognized server (one of 'AUSPASS', 'BGR',
257+
'EARTHSCOPE', 'EIDA', 'EMSC', 'ETH', 'GEOFON',
258+
'GEONET', 'GFZ', 'ICGC', 'IESDMC', 'INGV', 'IPGP',
259+
'IRIS', 'IRISPH5', 'ISC', 'KNMI', 'KOERI', 'LMU',
260+
'NCEDC', 'NIEP', 'NOA', 'NRCAN', 'ODC', 'ORFEUS',
261+
'RASPISHAKE', 'RESIF', 'RESIFPH5', 'SCEDC', 'TEXNET',
262+
'UIB-NORSAR', 'USGS', 'USP'). [Default 'IRIS']
263+
--user-auth USERAUTH Authentification Username and Password for the
264+
waveform server (--user-auth='username:authpassword')
265+
to access and download restricted data. [Default no
266+
user and password]
267+
--eida-token TOKENFILE
268+
Token for EIDA authentication mechanism, see
269+
http://geofon.gfz-
270+
potsdam.de/waveform/archive/auth/index.php. If a token
271+
is provided, argument --user-auth will be ignored.
272+
This mechanism is only available on select EIDA nodes.
273+
The token can be provided in form of the PGP message
274+
as a string, or the filename of a local file with the
275+
PGP message in it. [Default None]
268276
269277
Frequency Settings:
270278
Miscellaneous frequency settings
@@ -586,21 +594,29 @@ Usage
586594
Server Settings:
587595
Settings associated with which datacenter to log into.
588596
589-
-S SERVER, --server SERVER
590-
Specify the server to connect to. Options include:
591-
BGR, ETH, GEONET, GFZ, INGV, IPGP, IRIS, KOERI, LMU,
592-
NCEDC, NEIP, NERIES, ODC, ORFEUS, RESIF, SCEDC, USGS,
593-
USP. [Default IRIS]
594-
--server-url SERVER_URL
595-
Specify the obspy base_url server address (and port if
596-
needed) to open for the fdsn client. Overrides any
597-
settings to '--server'. [Default None]
598-
-U USERAUTH, --user-auth USERAUTH
599-
Enter your Authentification Username and Password
600-
(--user-auth='username:authpassword') to access and
601-
download restricted data. [Default no user and
602-
password]
603-
597+
--server SERVER Base URL of FDSN web service compatible server (e.g.
598+
“http://service.iris.edu”) or key string for
599+
recognized server (one of 'AUSPASS', 'BGR',
600+
'EARTHSCOPE', 'EIDA', 'EMSC', 'ETH', 'GEOFON',
601+
'GEONET', 'GFZ', 'ICGC', 'IESDMC', 'INGV', 'IPGP',
602+
'IRIS', 'IRISPH5', 'ISC', 'KNMI', 'KOERI', 'LMU',
603+
'NCEDC', 'NIEP', 'NOA', 'NRCAN', 'ODC', 'ORFEUS',
604+
'RASPISHAKE', 'RESIF', 'RESIFPH5', 'SCEDC', 'TEXNET',
605+
'UIB-NORSAR', 'USGS', 'USP'). [Default 'IRIS']
606+
--user-auth USERAUTH Authentification Username and Password for the
607+
waveform server (--user-auth='username:authpassword')
608+
to access and download restricted data. [Default no
609+
user and password]
610+
--eida-token TOKENFILE
611+
Token for EIDA authentication mechanism, see
612+
http://geofon.gfz-
613+
potsdam.de/waveform/archive/auth/index.php. If a token
614+
is provided, argument --user-auth will be ignored.
615+
This mechanism is only available on select EIDA nodes.
616+
The token can be provided in form of the PGP message
617+
as a string, or the filename of a local file with the
618+
PGP message in it. [Default None]
619+
604620
Frequency Settings:
605621
Miscellaneous frequency settings
606622

docs/index.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ can be used through command-line scripts.
1717
.. image:: https://github.com/nfsi-canada/OBStools/workflows/Build/badge.svg
1818
:target: https://github.com/nfsi-canada/OBStools/actions
1919
.. image:: https://codecov.io/gh/nfsi-canada/OBStools/branch/master/graph/badge.svg
20-
:target: https://codecov.io/gh/nfsi-canada/OBStools
20+
:target: https://codecov.io/gh/nfsi-canada/OBStools
2121

2222
.. toctree::
2323
:maxdepth: 1

obstools/scripts/atacr_download_data.py

+48-50
Original file line numberDiff line numberDiff line change
@@ -109,33 +109,39 @@ def get_daylong_arguments(argv=None):
109109
description="Settings associated with which "
110110
"datacenter to log into.")
111111
ServerGroup.add_argument(
112-
"-S", "--server",
112+
"--server",
113113
action="store",
114114
type=str,
115115
dest="server",
116116
default="IRIS",
117-
help="Specify the server to connect to. Options include: " +
118-
"BGR, ETH, GEONET, GFZ, INGV, IPGP, IRIS, KOERI, LMU, NCEDC, " +
119-
"NEIP, NERIES, ODC, ORFEUS, RESIF, SCEDC, USGS, USP. " +
120-
"[Default IRIS]")
117+
help="Base URL of FDSN web service compatible "
118+
"server (e.g. “http://service.iris.edu”) or key string for recognized "
119+
"server (one of 'AUSPASS', 'BGR', 'EARTHSCOPE', 'EIDA', 'EMSC', 'ETH', "
120+
"'GEOFON', 'GEONET', 'GFZ', 'ICGC', 'IESDMC', 'INGV', 'IPGP', 'IRIS', "
121+
"'IRISPH5', 'ISC', 'KNMI', 'KOERI', 'LMU', 'NCEDC', 'NIEP', 'NOA', "
122+
"'NRCAN', 'ODC', 'ORFEUS', 'RASPISHAKE', 'RESIF', 'RESIFPH5', 'SCEDC', "
123+
"'TEXNET', 'UIB-NORSAR', 'USGS', 'USP'). [Default 'IRIS']")
121124
ServerGroup.add_argument(
122-
"--server-url",
125+
"--user-auth",
123126
action="store",
124127
type=str,
125-
dest="server_url",
128+
dest="userauth",
126129
default=None,
127-
help="Specify the obspy base_url server address (and port if needed) " +
128-
"to open for the fdsn client. Overrides any settings to '--server'. " +
129-
"[Default None]")
130+
help="Authentification Username and Password for the " +
131+
"waveform server (--user-auth='username:authpassword') to access " +
132+
"and download restricted data. [Default no user and password]")
130133
ServerGroup.add_argument(
131-
"-U", "--user-auth",
132-
action="store",
134+
"--eida-token",
135+
action="store",
133136
type=str,
134-
dest="userauth",
135-
default="",
136-
help="Enter your Authentification Username and Password " +
137-
"(--user-auth='username:authpassword') to access and download " +
138-
"restricted data. [Default no user and password]")
137+
dest="tokenfile",
138+
default=None,
139+
help="Token for EIDA authentication mechanism, see " +
140+
"http://geofon.gfz-potsdam.de/waveform/archive/auth/index.php. "
141+
"If a token is provided, argument --user-auth will be ignored. "
142+
"This mechanism is only available on select EIDA nodes. The token can "
143+
"be provided in form of the PGP message as a string, or the filename of "
144+
"a local file with the PGP message in it. [Default None]")
139145

140146
"""
141147
# Database Settings
@@ -258,17 +264,20 @@ def get_daylong_arguments(argv=None):
258264
else:
259265
args.endT = None
260266

261-
# Parse User Authentification
262-
if not len(args.userauth) == 0:
263-
tt = args.userauth.split(':')
264-
if not len(tt) == 2:
265-
parser.error(
266-
"Error: Incorrect Username and Password Strings for " +
267-
"User Authentification")
268-
else:
269-
args.userauth = tt
267+
# Parse restricted data settings
268+
if args.tokenfile is not None:
269+
args.userauth = [None, None]
270270
else:
271-
args.userauth = []
271+
if args.userauth is not None:
272+
tt = args.userauth.split(':')
273+
if not len(tt) == 2:
274+
msg = ("Error: Incorrect Username and Password Strings for User "
275+
"Authentification")
276+
parser.error(msg)
277+
else:
278+
args.userauth = tt
279+
else:
280+
args.userauth = [None, None]
272281

273282
# # Parse Local Data directories
274283
# if args.localdata is not None:
@@ -283,17 +292,19 @@ def get_daylong_arguments(argv=None):
283292
# args.ndval = nan
284293

285294
if args.units not in ['DISP', 'VEL', 'ACC']:
286-
raise(Exception(
287-
"Error: invalid --units argument. Choose among " +
288-
"'DISP', 'VEL', or 'ACC'"))
295+
msg = ("Error: invalid --units argument. Choose among "
296+
"'DISP', 'VEL', or 'ACC'")
297+
parser.error(msg)
298+
289299
if args.pre_filt is None:
290300
args.pre_filt = [0.001, 0.005, 45., 50.]
291301
else:
292302
args.pre_filt = [float(val) for val in args.pre_filt.split(',')]
293303
args.pre_filt = sorted(args.pre_filt)
294304
if (len(args.pre_filt)) != 4:
295-
raise(Exception(
296-
"Error: --pre-filt should contain 4 comma-separated floats"))
305+
msg = ("Error: --pre-filt should contain 4 "
306+
"comma-separated floats")
307+
parser.error(msg)
297308

298309
return args
299310

@@ -339,24 +350,11 @@ def main(args=None):
339350
datapath.mkdir(parents=True)
340351

341352
# Establish client
342-
if len(args.userauth) == 0:
343-
if args.server_url is not None:
344-
client = Client(
345-
base_url=args.server_url)
346-
else:
347-
client = Client(
348-
args.server)
349-
else:
350-
if args.server_url is not None:
351-
client = Client(
352-
base_url=args.server_url,
353-
user=args.userauth[0],
354-
password=args.userauth[1])
355-
else:
356-
client = Client(
357-
args.server,
358-
user=args.userauth[0],
359-
password=args.userauth[1])
353+
client = Client(
354+
base_url=args.server,
355+
user=args.userauth[0],
356+
password=args.userauth[1],
357+
eida_token=args.tokenfile)
360358

361359
# Get catalogue search start time
362360
if args.startT is None:

obstools/scripts/atacr_download_event.py

+53-49
Original file line numberDiff line numberDiff line change
@@ -112,33 +112,39 @@ def get_event_arguments(argv=None):
112112
description="Settings associated with which "
113113
"datacenter to log into.")
114114
ServerGroup.add_argument(
115-
"-S", "--server",
115+
"--server",
116116
action="store",
117117
type=str,
118118
dest="server",
119119
default="IRIS",
120-
help="Specify the server to connect to. Options include: " +
121-
"BGR, ETH, GEONET, GFZ, INGV, IPGP, IRIS, KOERI, LMU, NCEDC, " +
122-
"NEIP, NERIES, ODC, ORFEUS, RESIF, SCEDC, USGS, USP. " +
123-
"[Default IRIS]")
120+
help="Base URL of FDSN web service compatible "
121+
"server (e.g. “http://service.iris.edu”) or key string for recognized "
122+
"server (one of 'AUSPASS', 'BGR', 'EARTHSCOPE', 'EIDA', 'EMSC', 'ETH', "
123+
"'GEOFON', 'GEONET', 'GFZ', 'ICGC', 'IESDMC', 'INGV', 'IPGP', 'IRIS', "
124+
"'IRISPH5', 'ISC', 'KNMI', 'KOERI', 'LMU', 'NCEDC', 'NIEP', 'NOA', "
125+
"'NRCAN', 'ODC', 'ORFEUS', 'RASPISHAKE', 'RESIF', 'RESIFPH5', 'SCEDC', "
126+
"'TEXNET', 'UIB-NORSAR', 'USGS', 'USP'). [Default 'IRIS']")
124127
ServerGroup.add_argument(
125-
"--server-url",
128+
"--user-auth",
126129
action="store",
127130
type=str,
128-
dest="server_url",
131+
dest="userauth",
129132
default=None,
130-
help="Specify the obspy base_url server address (and port if needed) " +
131-
"to open for the fdsn client. Overrides any settings to '--server'. " +
132-
"[Default None]")
133+
help="Authentification Username and Password for the " +
134+
"waveform server (--user-auth='username:authpassword') to access " +
135+
"and download restricted data. [Default no user and password]")
133136
ServerGroup.add_argument(
134-
"-U", "--user-auth",
135-
action="store",
137+
"--eida-token",
138+
action="store",
136139
type=str,
137-
dest="userauth",
138-
default="",
139-
help="Enter your Authentification Username and Password " +
140-
"(--user-auth='username:authpassword') to access and download " +
141-
"restricted data. [Default no user and password]")
140+
dest="tokenfile",
141+
default=None,
142+
help="Token for EIDA authentication mechanism, see " +
143+
"http://geofon.gfz-potsdam.de/waveform/archive/auth/index.php. "
144+
"If a token is provided, argument --user-auth will be ignored. "
145+
"This mechanism is only available on select EIDA nodes. The token can "
146+
"be provided in form of the PGP message as a string, or the filename of "
147+
"a local file with the PGP message in it. [Default None]")
142148

143149
# Constants Settings
144150
FreqGroup = parser.add_argument_group(
@@ -301,27 +307,35 @@ def get_event_arguments(argv=None):
301307
else:
302308
args.endT = None
303309

304-
# Parse User Authentification
305-
if not len(args.userauth) == 0:
306-
tt = args.userauth.split(':')
307-
if not len(tt) == 2:
308-
parser.error(
309-
"Error: Incorrect Username and Password Strings for User " +
310-
"Authentification")
311-
else:
312-
args.userauth = tt
310+
# Parse restricted data settings
311+
if args.tokenfile is not None:
312+
args.userauth = [None, None]
313313
else:
314-
args.userauth = []
314+
if args.userauth is not None:
315+
tt = args.userauth.split(':')
316+
if not len(tt) == 2:
317+
msg = ("Error: Incorrect Username and Password Strings for User "
318+
"Authentification")
319+
parser.error(msg)
320+
else:
321+
args.userauth = tt
322+
else:
323+
args.userauth = [None, None]
324+
325+
if args.units not in ['DISP', 'VEL', 'ACC']:
326+
msg = ("Error: invalid --units argument. Choose among "
327+
"'DISP', 'VEL', or 'ACC'")
328+
parser.error(msg)
315329

316330
if args.pre_filt is None:
317331
args.pre_filt = [0.001, 0.005, 45., 50.]
318332
else:
319333
args.pre_filt = [float(val) for val in args.pre_filt.split(',')]
320334
args.pre_filt = sorted(args.pre_filt)
321335
if (len(args.pre_filt)) != 4:
322-
raise(Exception(
323-
"Error: --pre-filt should contain 4 " +
324-
"comma-separated floats"))
336+
msg = ("Error: --pre-filt should contain 4 "
337+
"comma-separated floats")
338+
parser.error(msg)
325339

326340
return args
327341

@@ -367,24 +381,14 @@ def main(args=None):
367381
eventpath.mkdir(parents=True)
368382

369383
# Establish client
370-
if len(args.userauth) == 0:
371-
if args.server_url is not None:
372-
client = Client(
373-
base_url=args.server_url)
374-
else:
375-
client = Client(
376-
args.server)
377-
else:
378-
if args.server_url is not None:
379-
client = Client(
380-
base_url=args.server_url,
381-
user=args.userauth[0],
382-
password=args.userauth[1])
383-
else:
384-
client = Client(
385-
args.server,
386-
user=args.userauth[0],
387-
password=args.userauth[1])
384+
client = Client(
385+
base_url=args.server,
386+
user=args.userauth[0],
387+
password=args.userauth[1],
388+
eida_token=args.tokenfile)
389+
390+
# Establish client for events - Default is 'IRIS''
391+
event_client = Client()
388392

389393
# Get catalogue search start time
390394
if args.startT is None:
@@ -442,7 +446,7 @@ def main(args=None):
442446
print("| ... |")
443447

444448
# Get catalogue using deployment start and end
445-
cat = client.get_events(
449+
cat = event_client.get_events(
446450
starttime=tstart, endtime=tend,
447451
minmagnitude=args.minmag, maxmagnitude=args.maxmag)
448452

0 commit comments

Comments
 (0)