Skip to content

Commit

Permalink
Merge pull request #39 from nfsi-canada/v014
Browse files Browse the repository at this point in the history
V014
  • Loading branch information
paudetseis authored Jan 30, 2025
2 parents 7a08e26 + 9dca351 commit bc7c881
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
Expand Down
2 changes: 1 addition & 1 deletion obstools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"""

__version__ = '0.1.3'
__version__ = '0.1.4'

__author__ = 'Pascal Audet & Helen Janiszewski'

Expand Down
2 changes: 1 addition & 1 deletion obstools/atacr/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ def QC_daily_spectra(self, pd=[0.004, 0.2], tol=1.5, alpha=0.05,

# Save or show figure
if save:
fname = self.key + '.' + self.tkey + '.' + 'QC' + form
fname = self.key + '.' + self.tkey + '.' + 'QC.' + form
if isinstance(save, Path):
fname = save / fname
plot.savefig(
Expand Down
71 changes: 51 additions & 20 deletions obstools/atacr/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,22 +436,41 @@ def fig_comply(f, day_comps, day_list, sta_comps, sta_list, skey=None,
ax.yaxis.get_offset_text().set_fontsize(8)

if day_list[key]:
compliance_list = []
coherence_list = []
for i in range(len(day_comps)):
compliance = np.abs(day_comps[i][key][0])
coherence = np.abs(day_comps[i][key][1])
if not np.isnan(compliance).any():
compliance_list.append(compliance)
coherence_list.append(coherence)
compliance_mean = np.mean(np.array(compliance_list), axis=0)
compliance_std = np.std(np.array(compliance_list), axis=0)
coherence_mean = np.mean(np.array(coherence_list), axis=0)
coherence_std = np.std(np.array(coherence_list), axis=0)

ax.fill_between(
f[faxis],
compliance_mean[faxis]-compliance_std[faxis],
compliance_mean[faxis]+compliance_std[faxis],
fc='royalblue', alpha=0.3, label=r'$\pm$ Std daily'
)
ax.plot(
f[faxis], compliance_mean[faxis], c='royalblue',
lw=0.5, label='Mean daily')
ax.set_xlim(f_0, f_c)
ytop = 1.2*np.max(compliance_mean[(f > f_0) & (f < f_c)])
ybot = 0/8*np.min(compliance_mean[(f > f_0) & (f < f_c)])
ax.set_ylim(ybot, ytop)

if sta_list[key]:
for i in range(len(sta_comps)):
compliance = np.abs(sta_comps[i][key][0])
ax.plot(
f[faxis],
compliance[faxis],
'gray', alpha=0.3, lw=0.5)
ax.set_xlim(f_0, f_c)
ytop = np.max(compliance[(f > f_0) & (f < f_c)])
ybot = np.min(compliance[(f > f_0) & (f < f_c)])
ax.set_ylim(ybot, ytop)

if sta_list[key]:
ax.plot(
f[faxis],
np.abs(sta_comps[key][0][faxis]),
'k', lw=0.5)
'red', lw=0.5, alpha=0.5,
label='Sta average')

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

handles, labels = ax.get_legend_handles_labels()
by_label = dict(zip(labels, handles))
ax.legend(by_label.values(), by_label.keys(), fontsize=6)

ax = fig.add_subplot(ncomps, 2, j*2+2)
ax.tick_params(labelsize=8)

if day_list[key]:
for i in range(len(day_comps)):
ax.semilogx(
f[faxis],
np.abs(day_comps[i][key][1][faxis]),
'gray', alpha=0.3, lw=0.5)
# for i in range(len(day_comps)):
ax.fill_between(
f[faxis],
coherence_mean[faxis]-coherence_std[faxis],
coherence_mean[faxis]+coherence_std[faxis],
fc='royalblue', alpha=0.3
)
ax.plot(
f[faxis],
coherence_mean[faxis],
c='royalblue', lw=0.75)
if sta_list[key]:
ax.semilogx(
f[faxis],
np.abs(sta_comps[key][1][faxis]),
'k', lw=0.5)
for i in range(len(sta_comps)):
ax.plot(
f[faxis],
np.abs(sta_comps[i][key][1][faxis]),
'red', lw=0.5, alpha=0.5)
ax.set_xscale('log')

if key == 'ZP':
ax.set_title(skey+' Coherence: ZP',
Expand Down
2 changes: 1 addition & 1 deletion obstools/scripts/atacr_correct_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def main(args=None):
evla = trZ.stats.sac.evla

if args.fig_event_raw:
fname = stkey + '.' + eventstream.tstamp + 'raw'
fname = stkey + '.' + eventstream.tstamp + '.raw'
plot = plotting.fig_event_raw(
eventstream,
fmin=args.fmin, fmax=args.fmax)
Expand Down
2 changes: 2 additions & 0 deletions obstools/scripts/atacr_download_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,8 @@ def main(args=None):
# Check streams
is_ok, st = utils.QC_streams(t1, t2, st)
if not is_ok:
t1 += dt
t2 += dt
continue

sth = st.select(component='1') + st.select(component='2') + \
Expand Down
8 changes: 8 additions & 0 deletions obstools/scripts/atacr_transfer_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,10 @@ def main(args=None):
# Save daily transfer functions to file
daytransfer.save(filename)

# Create empty daynoise if not loaded
# else:
# XXX

if not args.skip_clean:

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

# Create empty stanoise if not loaded
# else:
# XXX

if args.fig_TF:
fname = stkey + '.' + 'transfer_functions'
plot = plotting.fig_TF(
Expand Down
6 changes: 4 additions & 2 deletions obstools/scripts/comply_calculate.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,8 @@ def main(args=None):

if not args.skip_clean:

sta_comply_functions = []

# Cycle through available files
for fileavst in average_files:

Expand All @@ -411,7 +413,7 @@ def main(args=None):
# Load Comply object and append to list
stacomply = pickle.load(open(filepkl, 'rb'))
f = stacomply.f
sta_comply_functions = stacomply.complyfunc
sta_comply_functions.append(stacomply.complyfunc)
continue

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

# Extract the transfer functions - for plotting
sta_comply_functions = stacomply.complyfunc
sta_comply_functions.append(stacomply.complyfunc)

# Save average transfer functions to file
stacomply.save(filename, form=args.saveformat)
Expand Down
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os.path
from os import listdir
import re
from numpy.distutils.core import setup
from setuptools import setup
from pathlib import Path


Expand All @@ -26,15 +26,15 @@ def find_version(*paths):
author_email='pascal.audet@uottawa.ca',
maintainer='Pascal Audet, Helen Janiszewski',
maintainer_email='pascal.audet@uottawa.ca, hajanisz@hawaii.edu',
url='https://github.com/nfsi-canada/OBStools/archive/OBStools-0.1.2.tar.gz',
url='https://github.com/nfsi-canada/OBStools/archive/OBStools-0.1.4.tar.gz',
classifiers=[
'Development Status :: 3 - Alpha',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9'],
install_requires=['numpy', 'obspy', 'stdb', 'pandas'],
install_requires=['numpy', 'obspy', 'stdb', 'scipy', 'pandas'],
python_requires='>=3.6',
packages=setuptools.find_packages(),
include_package_data=True,
Expand All @@ -44,6 +44,7 @@ def find_version(*paths):
entry_points={
'console_scripts':
['atacr_download_data=obstools.scripts.atacr_download_data:main',
# 'atacr_download_data_xml=obstools.scripts.atacr_download_data_xml:main',
'atacr_download_event=obstools.scripts.atacr_download_event:main',
'atacr_daily_spectra=obstools.scripts.atacr_daily_spectra:main',
'atacr_clean_spectra=obstools.scripts.atacr_clean_spectra:main',
Expand Down

0 comments on commit bc7c881

Please sign in to comment.