Skip to content

Commit e1b2610

Browse files
authored
Merge pull request #44 from nfsi-canada/v014
New version 0.1.5 Added ability to specify ZComp name (instead of just "Z"), to handle CH[123] data from NFSI. Added ability to specify a local base_url for the fdsnws data_select. Fixed all scripts and corresponding docs
2 parents 23194fb + 5b9e38c commit e1b2610

File tree

7 files changed

+145
-76
lines changed

7 files changed

+145
-76
lines changed

.github/workflows/deploy.yml

+18-19
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,19 @@ on:
1717
jobs:
1818
# This workflow contains a single job called "build"
1919
build:
20-
name: Python ${{ matrix.python-version }}
20+
name: ${{ matrix.os }} Python ${{ matrix.python-version }}
2121
# The type of runner that the job will run on
2222
runs-on: ${{ matrix.os }}
2323
strategy:
2424
matrix:
25-
os: [ubuntu-latest]
26-
python-version: ['3.7', '3.8', '3.9']
25+
os: ["ubuntu-latest"]
26+
python-version: ["3.10"]
2727

2828
steps:
2929
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
30-
- uses: actions/checkout@v3
31-
- uses: conda-incubator/setup-miniconda@v2
30+
- uses: actions/checkout@v4
31+
- uses: conda-incubator/setup-miniconda@v3
3232
with:
33-
auto-update-conda: true
3433
python-version: ${{ matrix.python-version }}
3534
activate-environment: test
3635
auto-activate-base: false
@@ -40,22 +39,22 @@ jobs:
4039
run: |
4140
conda info
4241
conda config --add channels conda-forge
43-
conda install obspy pandas
42+
conda install obspy pandas libstdcxx-ng
4443
pip install stdb
45-
pip install -e .
44+
pip install .
4645
47-
- name: Tests
48-
shell: bash -l {0}
49-
run: |
50-
export MPLBACKEND=Agg
51-
mkdir empty
52-
cd empty
53-
conda install pytest-cov
54-
pytest -v --cov=obstools ../obstools/tests/
55-
bash <(curl -s https://codecov.io/bash)
46+
# - name: Tests
47+
# shell: bash -l {0}
48+
# run: |
49+
# export MPLBACKEND=Agg
50+
# mkdir empty
51+
# cd empty
52+
# conda install pytest-cov
53+
# pytest -v --cov=obstools ../obstools/tests/
54+
# bash <(curl -s https://codecov.io/bash)
5655

5756
- name: Make docs
58-
if: matrix.python-version == '3.8'
57+
if: matrix.python-version == '3.10'
5958
shell: bash -l {0}
6059
run: |
6160
cd docs
@@ -66,7 +65,7 @@ jobs:
6665
cd ..
6766
6867
- name: Deploy 🚀
69-
if: matrix.python-version == '3.8'
68+
if: matrix.python-version == '3.10'
7069
uses: JamesIves/[email protected]
7170
with:
7271
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

docs/atacr.rst

+24-8
Original file line numberDiff line numberDiff line change
@@ -243,20 +243,26 @@ Usage
243243
correction. [Default looks for both horizontal and
244244
pressure and allows for both tilt AND compliance
245245
corrections]
246+
--zcomp ZCOMP Specify the Vertical Component Channel Identifier.
247+
[Default Z].
246248
-O, --overwrite Force the overwriting of pre-existing data. [Default
247249
False]
248250
249251
Server Settings:
250252
Settings associated with which datacenter to log into.
251253
252-
-S SERVER, --Server SERVER
254+
-S SERVER, --server SERVER
253255
Specify the server to connect to. Options include:
254256
BGR, ETH, GEONET, GFZ, INGV, IPGP, IRIS, KOERI, LMU,
255257
NCEDC, NEIP, NERIES, ODC, ORFEUS, RESIF, SCEDC, USGS,
256258
USP. [Default IRIS]
257-
-U USERAUTH, --User-Auth USERAUTH
258-
Enter your IRIS Authentification Username and Password
259-
(--User-Auth='username:authpassword') to access and
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
260266
download restricted data. [Default no user and
261267
password]
262268
@@ -572,20 +578,26 @@ Usage
572578
correction. [Default looks for both horizontal and
573579
pressure and allows for both tilt AND compliance
574580
corrections]
581+
--zcomp ZCOMP Specify the Vertical Component Channel Identifier.
582+
[Default Z].
575583
-O, --overwrite Force the overwriting of pre-existing data. [Default
576584
False]
577585
578586
Server Settings:
579587
Settings associated with which datacenter to log into.
580588
581-
-S SERVER, --Server SERVER
589+
-S SERVER, --server SERVER
582590
Specify the server to connect to. Options include:
583591
BGR, ETH, GEONET, GFZ, INGV, IPGP, IRIS, KOERI, LMU,
584592
NCEDC, NEIP, NERIES, ODC, ORFEUS, RESIF, SCEDC, USGS,
585593
USP. [Default IRIS]
586-
-U USERAUTH, --User-Auth USERAUTH
587-
Enter your IRIS Authentification Username and Password
588-
(--User-Auth='username:authpassword') to access and
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
589601
download restricted data. [Default no user and
590602
password]
591603
@@ -599,6 +611,10 @@ Usage
599611
--pre-filt PRE_FILT Specify four comma-separated corner frequencies
600612
(float, in Hz) for deconvolution pre-filter. [Default
601613
0.001,0.005,45.,50.]
614+
--window WINDOW Specify window length in seconds. Default value is
615+
highly recommended. Program may not be stable for
616+
large deviations from default value. [Default 7200.
617+
(or 2 hours)]
602618
603619
Event Settings:
604620
Settings associated with refining the events to include in matching

obstools/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
110110
"""
111111

112-
__version__ = '0.1.4'
112+
__version__ = '0.1.5'
113113

114114
__author__ = 'Pascal Audet & Helen Janiszewski'
115115

obstools/atacr/classes.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -642,13 +642,11 @@ def average_daily_spectra(self, calc_rotation=True, fig_average=False,
642642
643643
Attributes
644644
----------
645-
f : :class:`~numpy.ndarray`
646-
Positive frequency axis for corresponding window parameters
647645
power : :class:`~obstools.atacr.classes.Power`
648646
Container for the Power spectra
649647
cross : :class:`~obstools.atacr.classes.Cross`
650648
Container for the Cross power spectra
651-
rotation : :class:`~obstools.atacr.classes.Cross`, optional
649+
rotation : :class:`~obstools.atacr.classes.Rotation`, optional
652650
Container for the Rotated power and cross spectra
653651
654652
Examples

obstools/comply/classes.py

-3
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ class Comply(object):
5555
components (obtained from the
5656
:class:`~obstools.atacr.classes.DayNoise` or the
5757
:class:`~obstools.atacr.classes.StaNoise` noise objects)
58-
complyfunc : Dict
59-
Dictionary of compliance and coherence functions given the available
60-
components.
6158
6259
"""
6360

obstools/scripts/atacr_download_data.py

+49-20
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ def get_daylong_arguments(argv=None):
8888
"for tilt correction. Specifying 'P' allows for compliance " +
8989
"correction. [Default '12,P' looks for both horizontal and " +
9090
"pressure and allows for both tilt AND compliance corrections]")
91+
parser.add_argument(
92+
"--zcomp",
93+
dest="zcomp",
94+
type=str,
95+
default="Z",
96+
help="Specify the Vertical Component Channel Identifier. "+
97+
"[Default Z].")
9198
parser.add_argument(
9299
"-O", "--overwrite",
93100
action="store_true",
@@ -102,23 +109,32 @@ def get_daylong_arguments(argv=None):
102109
description="Settings associated with which "
103110
"datacenter to log into.")
104111
ServerGroup.add_argument(
105-
"-S", "--Server",
112+
"-S", "--server",
106113
action="store",
107114
type=str,
108-
dest="Server",
115+
dest="server",
109116
default="IRIS",
110117
help="Specify the server to connect to. Options include: " +
111118
"BGR, ETH, GEONET, GFZ, INGV, IPGP, IRIS, KOERI, LMU, NCEDC, " +
112119
"NEIP, NERIES, ODC, ORFEUS, RESIF, SCEDC, USGS, USP. " +
113120
"[Default IRIS]")
114121
ServerGroup.add_argument(
115-
"-U", "--User-Auth",
122+
"--server-url",
123+
action="store",
124+
type=str,
125+
dest="server_url",
126+
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+
ServerGroup.add_argument(
131+
"-U", "--user-auth",
116132
action="store",
117133
type=str,
118-
dest="UserAuth",
134+
dest="userauth",
119135
default="",
120-
help="Enter your IRIS Authentification Username and Password " +
121-
"(--User-Auth='username:authpassword') to access and download " +
136+
help="Enter your Authentification Username and Password " +
137+
"(--user-auth='username:authpassword') to access and download " +
122138
"restricted data. [Default no user and password]")
123139

124140
"""
@@ -243,16 +259,16 @@ def get_daylong_arguments(argv=None):
243259
args.endT = None
244260

245261
# Parse User Authentification
246-
if not len(args.UserAuth) == 0:
247-
tt = args.UserAuth.split(':')
262+
if not len(args.userauth) == 0:
263+
tt = args.userauth.split(':')
248264
if not len(tt) == 2:
249265
parser.error(
250266
"Error: Incorrect Username and Password Strings for " +
251267
"User Authentification")
252268
else:
253-
args.UserAuth = tt
269+
args.userauth = tt
254270
else:
255-
args.UserAuth = []
271+
args.userauth = []
256272

257273
# # Parse Local Data directories
258274
# if args.localdata is not None:
@@ -323,11 +339,24 @@ def main(args=None):
323339
datapath.mkdir(parents=True)
324340

325341
# Establish client
326-
if len(args.UserAuth) == 0:
327-
client = Client(args.Server)
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)
328349
else:
329-
client = Client(
330-
args.Server, user=args.UserAuth[0], password=args.UserAuth[1])
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])
331360

332361
# Get catalogue search start time
333362
if args.startT is None:
@@ -420,7 +449,7 @@ def main(args=None):
420449
continue
421450

422451
channels = sta.channel.upper()+'1,'+sta.channel.upper() + \
423-
'2,'+sta.channel.upper()+'Z'
452+
'2,'+sta.channel.upper()+args.zcomp
424453

425454
# Get waveforms from client
426455
try:
@@ -455,7 +484,7 @@ def main(args=None):
455484
t2 += dt
456485
continue
457486

458-
channels = sta.channel.upper() + 'Z'
487+
channels = sta.channel.upper() + args.zcomp
459488

460489
# Get waveforms from client
461490
try:
@@ -517,7 +546,7 @@ def main(args=None):
517546
continue
518547

519548
channels = sta.channel.upper()+'1,'+sta.channel.upper() + \
520-
'2,'+sta.channel.upper()+'Z'
549+
'2,'+sta.channel.upper()+args.zcomp
521550

522551
# Get waveforms from client
523552
try:
@@ -580,14 +609,14 @@ def main(args=None):
580609
continue
581610

582611
sth = st.select(component='1') + st.select(component='2') + \
583-
st.select(component='Z')
612+
st.select(component=args.zcomp)
584613

585614
# Remove responses
586615
print("* -> Removing responses - Seismic data")
587616
sth.remove_response(pre_filt=args.pre_filt, output=args.units)
588617

589-
# Extract traces - Z
590-
trZ = sth.select(component='Z')[0]
618+
# Extract traces - Z
619+
trZ = sth.select(component=args.zcomp)[0]
591620
trZ = utils.update_stats(
592621
trZ, sta.latitude, sta.longitude, sta.elevation,
593622
sta.channel+'Z')

0 commit comments

Comments
 (0)