Skip to content

updated script args for server settings #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 45 additions & 29 deletions docs/atacr.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
98 changes: 48 additions & 50 deletions obstools/scripts/atacr_download_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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

Expand Down Expand Up @@ -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:
Expand Down
102 changes: 53 additions & 49 deletions obstools/scripts/atacr_download_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -301,27 +307,35 @@ 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.]
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

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand Down
Loading