Skip to content

Commit bc7c881

Browse files
authored
Merge pull request #39 from nfsi-canada/v014
V014
2 parents 7a08e26 + 9dca351 commit bc7c881

9 files changed

+73
-29
lines changed

.github/workflows/deploy.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727

2828
steps:
2929
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
30-
- uses: actions/checkout@v2
30+
- uses: actions/checkout@v3
3131
- uses: conda-incubator/setup-miniconda@v2
3232
with:
3333
auto-update-conda: true

obstools/__init__.py

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

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

114114
__author__ = 'Pascal Audet & Helen Janiszewski'
115115

obstools/atacr/classes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ def QC_daily_spectra(self, pd=[0.004, 0.2], tol=1.5, alpha=0.05,
606606

607607
# Save or show figure
608608
if save:
609-
fname = self.key + '.' + self.tkey + '.' + 'QC' + form
609+
fname = self.key + '.' + self.tkey + '.' + 'QC.' + form
610610
if isinstance(save, Path):
611611
fname = save / fname
612612
plot.savefig(

obstools/atacr/plotting.py

+51-20
Original file line numberDiff line numberDiff line change
@@ -436,22 +436,41 @@ def fig_comply(f, day_comps, day_list, sta_comps, sta_list, skey=None,
436436
ax.yaxis.get_offset_text().set_fontsize(8)
437437

438438
if day_list[key]:
439+
compliance_list = []
440+
coherence_list = []
439441
for i in range(len(day_comps)):
440442
compliance = np.abs(day_comps[i][key][0])
443+
coherence = np.abs(day_comps[i][key][1])
444+
if not np.isnan(compliance).any():
445+
compliance_list.append(compliance)
446+
coherence_list.append(coherence)
447+
compliance_mean = np.mean(np.array(compliance_list), axis=0)
448+
compliance_std = np.std(np.array(compliance_list), axis=0)
449+
coherence_mean = np.mean(np.array(coherence_list), axis=0)
450+
coherence_std = np.std(np.array(coherence_list), axis=0)
451+
452+
ax.fill_between(
453+
f[faxis],
454+
compliance_mean[faxis]-compliance_std[faxis],
455+
compliance_mean[faxis]+compliance_std[faxis],
456+
fc='royalblue', alpha=0.3, label=r'$\pm$ Std daily'
457+
)
458+
ax.plot(
459+
f[faxis], compliance_mean[faxis], c='royalblue',
460+
lw=0.5, label='Mean daily')
461+
ax.set_xlim(f_0, f_c)
462+
ytop = 1.2*np.max(compliance_mean[(f > f_0) & (f < f_c)])
463+
ybot = 0/8*np.min(compliance_mean[(f > f_0) & (f < f_c)])
464+
ax.set_ylim(ybot, ytop)
465+
466+
if sta_list[key]:
467+
for i in range(len(sta_comps)):
468+
compliance = np.abs(sta_comps[i][key][0])
441469
ax.plot(
442470
f[faxis],
443471
compliance[faxis],
444-
'gray', alpha=0.3, lw=0.5)
445-
ax.set_xlim(f_0, f_c)
446-
ytop = np.max(compliance[(f > f_0) & (f < f_c)])
447-
ybot = np.min(compliance[(f > f_0) & (f < f_c)])
448-
ax.set_ylim(ybot, ytop)
449-
450-
if sta_list[key]:
451-
ax.plot(
452-
f[faxis],
453-
np.abs(sta_comps[key][0][faxis]),
454-
'k', lw=0.5)
472+
'red', lw=0.5, alpha=0.5,
473+
label='Sta average')
455474

456475
if key == 'ZP':
457476
ax.set_title(skey+' Compliance: ZP',
@@ -467,20 +486,32 @@ def fig_comply(f, day_comps, day_list, sta_comps, sta_list, skey=None,
467486
ax.axvline(f_0, ls='--', c='k', lw=0.75)
468487
ax.axvline(f_c, ls='--', c='k', lw=0.75)
469488

489+
handles, labels = ax.get_legend_handles_labels()
490+
by_label = dict(zip(labels, handles))
491+
ax.legend(by_label.values(), by_label.keys(), fontsize=6)
492+
470493
ax = fig.add_subplot(ncomps, 2, j*2+2)
471494
ax.tick_params(labelsize=8)
472495

473496
if day_list[key]:
474-
for i in range(len(day_comps)):
475-
ax.semilogx(
476-
f[faxis],
477-
np.abs(day_comps[i][key][1][faxis]),
478-
'gray', alpha=0.3, lw=0.5)
497+
# for i in range(len(day_comps)):
498+
ax.fill_between(
499+
f[faxis],
500+
coherence_mean[faxis]-coherence_std[faxis],
501+
coherence_mean[faxis]+coherence_std[faxis],
502+
fc='royalblue', alpha=0.3
503+
)
504+
ax.plot(
505+
f[faxis],
506+
coherence_mean[faxis],
507+
c='royalblue', lw=0.75)
479508
if sta_list[key]:
480-
ax.semilogx(
481-
f[faxis],
482-
np.abs(sta_comps[key][1][faxis]),
483-
'k', lw=0.5)
509+
for i in range(len(sta_comps)):
510+
ax.plot(
511+
f[faxis],
512+
np.abs(sta_comps[i][key][1][faxis]),
513+
'red', lw=0.5, alpha=0.5)
514+
ax.set_xscale('log')
484515

485516
if key == 'ZP':
486517
ax.set_title(skey+' Coherence: ZP',

obstools/scripts/atacr_correct_event.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ def main(args=None):
352352
evla = trZ.stats.sac.evla
353353

354354
if args.fig_event_raw:
355-
fname = stkey + '.' + eventstream.tstamp + 'raw'
355+
fname = stkey + '.' + eventstream.tstamp + '.raw'
356356
plot = plotting.fig_event_raw(
357357
eventstream,
358358
fmin=args.fmin, fmax=args.fmax)

obstools/scripts/atacr_download_data.py

+2
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,8 @@ def main(args=None):
575575
# Check streams
576576
is_ok, st = utils.QC_streams(t1, t2, st)
577577
if not is_ok:
578+
t1 += dt
579+
t2 += dt
578580
continue
579581

580582
sth = st.select(component='1') + st.select(component='2') + \

obstools/scripts/atacr_transfer_functions.py

+8
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,10 @@ def main(args=None):
361361
# Save daily transfer functions to file
362362
daytransfer.save(filename)
363363

364+
# Create empty daynoise if not loaded
365+
# else:
366+
# XXX
367+
364368
if not args.skip_clean:
365369

366370
# Cycle through available files
@@ -395,6 +399,10 @@ def main(args=None):
395399
# Save average transfer functions to file
396400
statransfer.save(filename)
397401

402+
# Create empty stanoise if not loaded
403+
# else:
404+
# XXX
405+
398406
if args.fig_TF:
399407
fname = stkey + '.' + 'transfer_functions'
400408
plot = plotting.fig_TF(

obstools/scripts/comply_calculate.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,8 @@ def main(args=None):
395395

396396
if not args.skip_clean:
397397

398+
sta_comply_functions = []
399+
398400
# Cycle through available files
399401
for fileavst in average_files:
400402

@@ -411,7 +413,7 @@ def main(args=None):
411413
# Load Comply object and append to list
412414
stacomply = pickle.load(open(filepkl, 'rb'))
413415
f = stacomply.f
414-
sta_comply_functions = stacomply.complyfunc
416+
sta_comply_functions.append(stacomply.complyfunc)
415417
continue
416418

417419
print("\n"+"*"*60)
@@ -434,7 +436,7 @@ def main(args=None):
434436
f = stacomply.f
435437

436438
# Extract the transfer functions - for plotting
437-
sta_comply_functions = stacomply.complyfunc
439+
sta_comply_functions.append(stacomply.complyfunc)
438440

439441
# Save average transfer functions to file
440442
stacomply.save(filename, form=args.saveformat)

setup.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os.path
33
from os import listdir
44
import re
5-
from numpy.distutils.core import setup
5+
from setuptools import setup
66
from pathlib import Path
77

88

@@ -26,15 +26,15 @@ def find_version(*paths):
2626
author_email='[email protected]',
2727
maintainer='Pascal Audet, Helen Janiszewski',
2828
29-
url='https://github.com/nfsi-canada/OBStools/archive/OBStools-0.1.2.tar.gz',
29+
url='https://github.com/nfsi-canada/OBStools/archive/OBStools-0.1.4.tar.gz',
3030
classifiers=[
3131
'Development Status :: 3 - Alpha',
3232
'License :: OSI Approved :: MIT License',
3333
'Programming Language :: Python :: 3.6',
3434
'Programming Language :: Python :: 3.7',
3535
'Programming Language :: Python :: 3.8',
3636
'Programming Language :: Python :: 3.9'],
37-
install_requires=['numpy', 'obspy', 'stdb', 'pandas'],
37+
install_requires=['numpy', 'obspy', 'stdb', 'scipy', 'pandas'],
3838
python_requires='>=3.6',
3939
packages=setuptools.find_packages(),
4040
include_package_data=True,
@@ -44,6 +44,7 @@ def find_version(*paths):
4444
entry_points={
4545
'console_scripts':
4646
['atacr_download_data=obstools.scripts.atacr_download_data:main',
47+
# 'atacr_download_data_xml=obstools.scripts.atacr_download_data_xml:main',
4748
'atacr_download_event=obstools.scripts.atacr_download_event:main',
4849
'atacr_daily_spectra=obstools.scripts.atacr_daily_spectra:main',
4950
'atacr_clean_spectra=obstools.scripts.atacr_clean_spectra:main',

0 commit comments

Comments
 (0)