Skip to content

Commit

Permalink
Merge pull request #227 from rmodrak/master
Browse files Browse the repository at this point in the history
Graphics fixes
  • Loading branch information
rmodrak authored Oct 5, 2023
2 parents 69a68a0 + d7c303e commit 895a438
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 72 deletions.
40 changes: 0 additions & 40 deletions docs/install/env_conda.rst

This file was deleted.

9 changes: 7 additions & 2 deletions docs/install/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,16 @@ Finally, install PyGMT:

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

PyGMT is only used for generating figures. If `conda install pygmt` fails, MTUQ will attempt to fall back to GMT or ObsPy. We note that some versions of GMT and ObsPy do not plot full moment tensors `correctly <https://github.com/obspy/obspy/issues/2388>`_.
PyGMT installation has been finicky at times, so we include it as a separate step after the main env.yaml-based installation.


.. note::

If PyGMT installation fails, most MTUQ functions will still work, but some plotting functions will fall back to GMT or ObsPy. We note that some versions of GMT and ObsPy do not plot `full moment tensors <https://github.com/obspy/obspy/issues/2388>`_ correctly.



Expand Down
1 change: 1 addition & 0 deletions mtuq/graphics/uq/_gmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def _plot_depth_gmt(filename, depths, values,

data = np.column_stack((depths, values))
minval, maxval, exp = _parse_limits(data[:,-1])
data[:,-1] /= 10.**exp

# write values to be plotted as ASCII table
_savetxt(ascii_file_1, data)
Expand Down
30 changes: 9 additions & 21 deletions mtuq/graphics/waveforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def plot_waveforms1(filename,

ir += 1

pyplot.savefig(filename)
_save(filename)
pyplot.close()


Expand Down Expand Up @@ -221,7 +221,7 @@ def plot_waveforms2(filename,

ir += 1

pyplot.savefig(filename)
_save(filename)
pyplot.close()


Expand Down Expand Up @@ -418,22 +418,7 @@ def _plot_ZR(axes, ic, dat, syn, component,

_plot(axis, dat, syn)

# THIS PART WAS COMMENTED OUT BEFORE THE WORKSHOP FOR A QUICK WORKAROUND
# WE NEED A PROPER WAY OF DEALING WITH CUSTOM AMPLITUDE BY ADDING AN OPTION
# # normalize amplitudes
# if normalize=='trace_amplitude':
# max_trace = _max(dat, syn)
# ylim = [-3*max_trace, +3*max_trace]
# axis.set_ylim(*ylim)
# elif normalize=='station_amplitude':
# max_stream = _max(stream_dat, stream_syn)
# ylim = [-3*max_stream, +3*max_stream]
# axis.set_ylim(*ylim)
# elif normalize=='maximum_amplitude':
# ylim = [-2*max_amplitude, +2*max_amplitude]
# axis.set_ylim(*ylim)

# normalize amplitude - using same scaling parameters as surface waves
# normalize amplitude
if normalize=='trace_amplitude':
max_trace = _max(dat, syn)
ylim = [-1.5*max_trace, +1.5*max_trace]
Expand All @@ -446,6 +431,7 @@ def _plot_ZR(axes, ic, dat, syn, component,
ylim = [-0.75*max_amplitude, +0.75*max_amplitude]
axis.set_ylim(*ylim)


if trace_label_writer is not None:
trace_label_writer(axis, dat, syn, total_misfit)

Expand All @@ -467,9 +453,6 @@ def _plot(axis, dat, syn, label=None):
axis.plot(t, s[start:stop], 'r', linewidth=1.25,
clip_on=False, zorder=10)

# prevents traces from getting clipped
axis.patch.set_alpha(0.)


def _add_component_labels1(axes, body_wave_labels=True, surface_wave_labels=True):
""" Displays component name above each column
Expand Down Expand Up @@ -580,6 +563,7 @@ def _hide_axes(axes):
col.spines['left'].set_visible(False)
col.get_xaxis().set_ticks([])
col.get_yaxis().set_ticks([])
col.patch.set_visible(False)


def _prepare_header(model, solver, source, source_dict, origin, *args):
Expand All @@ -600,6 +584,10 @@ def _prepare_header(model, solver, source, source_dict, origin, *args):
raise TypeError


def _save(filename):
pyplot.savefig(filename)


def _get_tag(tags, pattern):
for tag in tags:
parts = tag.split(':')
Expand Down
18 changes: 9 additions & 9 deletions mtuq/process_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,20 @@ class ProcessData(object):
``pick_type`` (`str`)
- ``'taup'``
calculates P, S arrival times from Tau-P model
calculates P, S travel times from Tau-P model
(uses `obspy.taup.TauPyModel.get_arrival_times`)
- ``'FK_metadata'``
reads P, S arrival times from FK metadata
reads P, S travel times from FK metadata
- ``'SAC_metadata'``
reads P, S arrival times from SAC metadata fields `t5`, `t6`
reads P, S travel times from SAC metadata fields `t5`, `t6`
- ``'user_supplied'``
reads P, S arrival times from columns 8, 10 of `capuaf_file`
reads P, S travel times from columns 8, 10 of `capuaf_file`
- ``None``
no phase picks will be calculated
no P,S travel times will be calculated
``window_type`` (`str`)
Expand Down Expand Up @@ -121,6 +121,9 @@ class ProcessData(object):
``freq`` (`float`)
Required for `filter_type=lowpass` or `filter_type=highpass`
``window_length`` (`float`)
Window length in seconds
``group_velocity`` (`float`)
Group velocity in m/s, required for `window_type=group_velocity`
Expand All @@ -134,11 +137,8 @@ class ProcessData(object):
``v_max`` (`float`)
Maximum velocity in m/s, required for `window_type=min_max`
``window_length`` (`float`)
window length in seconds
``padding`` (`list`)
amount by which Green's functions will be padded relative to data
Amount by which Green's functions will be padded relative to data
``taup_model`` (`str`)
Name of built-in ObsPy TauP model or path to custom ObsPy TauP model,
Expand Down

0 comments on commit 895a438

Please sign in to comment.