Skip to content

Commit

Permalink
Merge pull request #233 from rmodrak/master
Browse files Browse the repository at this point in the history
Consistent units in archived waveform data, other miscellaneous fixes
  • Loading branch information
rmodrak authored Oct 30, 2023
2 parents f698c11 + cf746bd commit 0641750
Show file tree
Hide file tree
Showing 26 changed files with 67 additions and 39 deletions.
1 change: 1 addition & 0 deletions .github/workflows/python-app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
python tests/benchmark_cap_vs_mtuq.py --no_figures
python tests/test_grid_search_mt.py --no_figures
python tests/test_grid_search_mt_depth.py --no_figures
python tests/test_greens_SPECFEM3D_SAC.py --no_figures
# unfortunately, these Conda installation tests exceed the resource limits
# for GitHub workflows
Expand Down
Binary file modified data/examples/20090407201255351.tgz
Binary file not shown.
Binary file modified data/examples/SPECFEM3D_SGT.tgz
Binary file not shown.
4 changes: 3 additions & 1 deletion docs/README
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ HOW TO UPDATE DOCS
Modify the sphinx autosummary source code by adding 'jinja2.ext.do' to the jinja
Environment() extensions list

See for example this line of the source code:
See in particular this line of the autosummary source code:

https://github.com/sphinx-doc/sphinx/blob/a6032e852a650c070aed66f0790e612905159f15/sphinx/ext/autosummary/generate.py#L111

See also:

https://stackoverflow.com/questions/39858191/do-statement-not-working-in-jinja


Expand Down
2 changes: 1 addition & 1 deletion docs/install/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Finally, install PyGMT:

.. code::
conda install 'pygmt>=0.9'
conda install 'pygmt=0.9'
.. note::

Expand Down
2 changes: 1 addition & 1 deletion examples/DetailedAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
data = read(path_data, format='sac',
event_id=event_id,
station_id_list=station_id_list,
tags=['units:cm', 'type:velocity'])
tags=['units:m', 'type:velocity'])


data.sort_by_distance()
Expand Down
2 changes: 1 addition & 1 deletion examples/GridSearch.DoubleCouple+Magnitude+Depth.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
data = read(path_data, format='sac',
event_id=event_id,
station_id_list=station_id_list,
tags=['units:cm', 'type:velocity'])
tags=['units:m', 'type:velocity'])


data.sort_by_distance()
Expand Down
2 changes: 1 addition & 1 deletion examples/GridSearch.DoubleCouple+Magnitude+Hypocenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
data = read(path_data, format='sac',
event_id=event_id,
station_id_list=station_id_list,
tags=['units:cm', 'type:velocity'])
tags=['units:m', 'type:velocity'])


data.sort_by_distance()
Expand Down
2 changes: 1 addition & 1 deletion examples/GridSearch.DoubleCouple.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
data = read(path_data, format='sac',
event_id=event_id,
station_id_list=station_id_list,
tags=['units:cm', 'type:velocity'])
tags=['units:m', 'type:velocity'])


data.sort_by_distance()
Expand Down
2 changes: 1 addition & 1 deletion examples/GridSearch.FullMomentTensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
data = read(path_data, format='sac',
event_id=event_id,
station_id_list=station_id_list,
tags=['units:cm', 'type:velocity'])
tags=['units:m', 'type:velocity'])


data.sort_by_distance()
Expand Down
2 changes: 1 addition & 1 deletion examples/SerialGridSearch.DoubleCouple.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
data = read(path_data, format='sac',
event_id=event_id,
station_id_list=station_id_list,
tags=['units:cm', 'type:velocity'])
tags=['units:m', 'type:velocity'])


data.sort_by_distance()
Expand Down
2 changes: 1 addition & 1 deletion examples/Waveforms+Polarities.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
data = read(path_data, format='sac',
event_id=event_id,
station_id_list=station_id_list,
tags=['units:cm', 'type:velocity'])
tags=['units:m', 'type:velocity'])


data.sort_by_distance()
Expand Down
11 changes: 10 additions & 1 deletion mtuq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@
# of numpy, it will be understood as (type, (1,)) / '(1,)type'.

import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)
warnings.simplefilter(action='ignore',
category=FutureWarning)


# Suppress Instaseis warning that gets raised unnecessarily during git+https
# installation

warnings.filterwarnings(action='ignore',
message='.*'+'Use the proper pypi release or install from git.'+'.*')



#
Expand Down
2 changes: 1 addition & 1 deletion mtuq/graphics/waveforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def plot_waveforms1(filename,
continue

_plot_ZRT(axes[ir], 1, dat, syn, component,
normalize, trace_labels, max_amplitude, total_misfit)
normalize, trace_label_writer, max_amplitude, total_misfit)

ir += 1

Expand Down
6 changes: 3 additions & 3 deletions mtuq/greens_tensor/SPECFEM3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ class GreensTensor(GreensTensorBase):
SPECFEM3D Green's functions describe the impulse response of a general
inhomogeneous medium. Time series represent vertical, radial, and
transverse velocity in units of m*(N-m)^-1 s^-1
transverse displacement in units of m*(N-m)^-1
"""
def __init__(self, *args, **kwargs):
super(GreensTensor, self).__init__(*args, **kwargs)

if 'type:greens' not in self.tags:
self.tags += ['type:greens']

if 'type:velocity' not in self.tags:
self.tags += ['type:velocity']
if 'type:velocity' not in self.tags or 'type:displacement' not in self.tags:
self.tags += ['type:displacement']

if 'units:m' not in self.tags:
self.tags += ['units:m']
Expand Down
2 changes: 1 addition & 1 deletion mtuq/util/gallery.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
data = read(path_data, format='sac',
event_id=event_id,
station_id_list=station_id_list,
tags=['units:cm', 'type:velocity'])
tags=['units:m', 'type:velocity'])


data.sort_by_distance()
Expand Down
23 changes: 14 additions & 9 deletions setup/code_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,14 @@
#
# Grid search integration test
#
# This script is similar to examples/SerialGridSearch.DoubleCouple.py,
# except here we included mangitude and depth and use a coarser grid
# For speed, the script tests the iterative machinery for depth
# searches in a somewhat degenerate case, using only a length one
# container
#
# For a depth search in the more usual sense, see
# examples/GridSearch.DoubleCouple+Magnitude+Depth.py
#
"""


Expand Down Expand Up @@ -748,7 +753,7 @@
data = read(path_data, format='sac',
event_id=event_id,
station_id_list=station_id_list,
tags=['units:cm', 'type:velocity'])
tags=['units:m', 'type:velocity'])
data.sort_by_distance()
Expand Down Expand Up @@ -812,7 +817,7 @@
data = read(path_data, format='sac',
event_id=event_id,
station_id_list=station_id_list,
tags=['units:cm', 'type:velocity'])
tags=['units:m', 'type:velocity'])
data.sort_by_distance()
Expand Down Expand Up @@ -859,7 +864,7 @@
data = read(path_data, format='sac',
event_id=event_id,
station_id_list=station_id_list,
tags=['units:cm', 'type:velocity'])
tags=['units:m', 'type:velocity'])
data.sort_by_distance()
stations = data.get_stations()
Expand Down Expand Up @@ -905,7 +910,7 @@
data = read(path_data, format='sac',
event_id=event_id,
station_id_list=station_id_list,
tags=['units:cm', 'type:velocity'])
tags=['units:m', 'type:velocity'])
data.sort_by_distance()
Expand Down Expand Up @@ -1631,7 +1636,7 @@ def isclose(a, b, atol=1.e6, rtol=1.e-6):
print('Reading data...\\n')
data = read(path_data, format='sac',
event_id=event_id,
tags=['units:cm', 'type:velocity'])
tags=['units:m', 'type:velocity'])
data.sort_by_distance()
Expand Down Expand Up @@ -1671,7 +1676,7 @@ def isclose(a, b, atol=1.e6, rtol=1.e-6):
if run_figures:
plot_waveforms2('cap_vs_mtuq_'+str(_i)+'.png',
cap_bw, cap_sw, mtuq_bw, mtuq_sw,
stations, origin, trace_labels=False)
stations, origin, trace_label_writer=None)
if run_checks:
compare_cap_mtuq(
Expand All @@ -1687,7 +1692,7 @@ def isclose(a, b, atol=1.e6, rtol=1.e-6):
plot_waveforms2('cap_vs_mtuq_data.png',
cap_bw, cap_sw, mtuq_bw, mtuq_sw,
stations, origin, trace_labels=False, normalize=False)
stations, origin, trace_label_writer=None, normalize=False)
print('\\nSUCCESS\\n')
Expand Down
6 changes: 3 additions & 3 deletions tests/benchmark_cap_vs_mtuq.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
print('Reading data...\n')
data = read(path_data, format='sac',
event_id=event_id,
tags=['units:cm', 'type:velocity'])
tags=['units:m', 'type:velocity'])

data.sort_by_distance()

Expand Down Expand Up @@ -213,7 +213,7 @@
if run_figures:
plot_waveforms2('cap_vs_mtuq_'+str(_i)+'.png',
cap_bw, cap_sw, mtuq_bw, mtuq_sw,
stations, origin, trace_labels=False)
stations, origin, trace_label_writer=None)

if run_checks:
compare_cap_mtuq(
Expand All @@ -229,7 +229,7 @@

plot_waveforms2('cap_vs_mtuq_data.png',
cap_bw, cap_sw, mtuq_bw, mtuq_sw,
stations, origin, trace_labels=False, normalize=False)
stations, origin, trace_label_writer=None, normalize=False)

print('\nSUCCESS\n')

7 changes: 5 additions & 2 deletions tests/test_HMC_DoubleCouple.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@


if __name__=='__main__':

print('WARNING: need to update Greens functions from velocity to displacement?')

#
# Carries out Hamiltonian Monte Carlo (HMC) sampling over double couple moment tensors
#
# USAGE
# mpirun -n <NPROC> python HMC.DoubleCouple.py
# mpirun -n <NPROC> python test_HMC_DoubleCouple.py
#
#

Expand Down Expand Up @@ -128,7 +131,7 @@
data = read(path_data, format='sac',
event_id=event_id,
station_id_list=station_id_list,
tags=['units:cm', 'type:velocity'])
tags=['units:m', 'type:velocity'])


data.sort_by_distance()
Expand Down
7 changes: 5 additions & 2 deletions tests/test_HMC_FullMomentTensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@


if __name__=='__main__':

print('WARNING: need to update Greens functions from velocity to displacement?')

#
# Carries out Hamiltonian Monte Carlo (HMC) sampling over full moment tensors
#
# USAGE
# mpirun -n <NPROC> python HMC.FullMomentTensor.py
# mpirun -n <NPROC> python test_HMC_FullMomentTensor.py
#
#

Expand Down Expand Up @@ -129,7 +132,7 @@
data = read(path_data, format='sac',
event_id=event_id,
station_id_list=station_id_list,
tags=['units:cm', 'type:velocity'])
tags=['units:m', 'type:velocity'])


data.sort_by_distance()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
data = read(path_data, format='sac',
event_id=event_id,
station_id_list=station_id_list,
tags=['units:cm', 'type:velocity'])
tags=['units:m', 'type:velocity'])


data.sort_by_distance()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_greens_SPECFEM3D_SAC.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
data = read(path_data, format='sac',
event_id=event_id,
station_id_list=station_id_list,
tags=['units:cm', 'type:velocity'])
tags=['units:m', 'type:velocity'])


data.sort_by_distance()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_greens_SPECFEM3D_SGT.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
data = read(path_data, format='sac',
event_id=event_id,
station_id_list=station_id_list,
tags=['units:cm', 'type:velocity'])
tags=['units:m', 'type:velocity'])


data.sort_by_distance()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_grid_search_mt.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
data = read(path_data, format='sac',
event_id=event_id,
station_id_list=station_id_list,
tags=['units:cm', 'type:velocity'])
tags=['units:m', 'type:velocity'])


data.sort_by_distance()
Expand Down
11 changes: 8 additions & 3 deletions tests/test_grid_search_mt_depth.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@
#
# Grid search integration test
#
# This script is similar to examples/SerialGridSearch.DoubleCouple.py,
# except here we included mangitude and depth and use a coarser grid
# For speed, the script tests the iterative machinery for depth
# searches in a somewhat degenerate case, using only a length one
# container
#
# For a depth search in the more usual sense, see
# examples/GridSearch.DoubleCouple+Magnitude+Depth.py
#


# by default, the script runs with figure generation and error checking
# turned on
Expand Down Expand Up @@ -118,7 +123,7 @@
data = read(path_data, format='sac',
event_id=event_id,
station_id_list=station_id_list,
tags=['units:cm', 'type:velocity'])
tags=['units:m', 'type:velocity'])

data.sort_by_distance()
stations = data.get_stations()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_misfit.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
data = read(path_data, format='sac',
event_id=event_id,
station_id_list=station_id_list,
tags=['units:cm', 'type:velocity'])
tags=['units:m', 'type:velocity'])


data.sort_by_distance()
Expand Down

0 comments on commit 0641750

Please sign in to comment.