Skip to content

Commit

Permalink
Merge pull request #243 from rmodrak/master
Browse files Browse the repository at this point in the history
Updated installation instructions
  • Loading branch information
rmodrak authored Jan 19, 2024
2 parents d7d53e3 + 0b26033 commit 3730282
Show file tree
Hide file tree
Showing 16 changed files with 86 additions and 63 deletions.
20 changes: 15 additions & 5 deletions docs/install/arm64.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@

Installation on ARM64 systems
=============================
.. warning::

With newer versions of MTUQ, the same installation procedure works for Macs
as for other computers. Thus, the following modified procedure may no longer
be necessary (though it should still continue to work).



Modified installation procedure for Apple M1 and Apple M2 Macs
==============================================================

Newer Mac computers use proprietary Apple processors based on the ARM64 architecture.

To install MTUQ on ARM64 systems, create a conda virtual environment:

Expand Down Expand Up @@ -37,16 +47,16 @@ Finally, install PyGMT:

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

Users may receive the following Instaseis warning message:
Users may receive the following Instaseis warning:

`UserWarning: Please don't install from a tarball. Use the proper pypi release or install from git.`

Now that Instaseis PyPI releases are no longer maintained, the above message can be ignored.
In fact, env_arm64.yaml does install Instaseis from git, and the above message can be ignored.


.. note::
Expand Down
6 changes: 3 additions & 3 deletions docs/install/index.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Installation
============

We recommend installing MTUQ under Anaconda or Miniconda, which if not already present can be obtained following `these instructions <https://conda.io/projects/conda/en/latest/user-guide/install/index.html>`_.
We recommend installing MTUQ under Miniconda, which can be obtained following `these instructions <https://conda.io/projects/conda/en/latest/user-guide/install/index.html>`_.


To install MTUQ, create a conda virtual environment:

.. code::
conda create -n mtuq python=3
conda create -n mtuq
Download the MTUQ source code:
Expand Down Expand Up @@ -43,7 +43,7 @@ Finally, install PyGMT:
.. note::

PyGMT installation has been finicky at times, so we include it as a separate step after the main env.yaml-based installation.
PyGMT installation has been finicky at times, so we include it as a separate step after the main env.yaml-based installation. Most MTUQ functions will continue to work without PyGMT. (`See here <https://uafgeotools.github.io/mtuq/install/issues.html#pygmt-installation>`_ for more information.)


**Troubleshooting**
Expand Down
47 changes: 23 additions & 24 deletions docs/install/issues.rst
Original file line number Diff line number Diff line change
@@ -1,51 +1,50 @@

Troubleshooting
===============

Installation on Apple M1 and Apple M2 Macs
------------------------------------------

Newer Mac computers use proprietary Apple processors based on the ARM64 architecture. On these and other ARM64 systems, a modified `conda env` command is necessary
PyGMT installation
------------------

.. code::
MTUQ uses full moment tensor plotting functions from the PyGMT graphics library.

conda env update --file env_arm64.yaml
To avoid a known issue with PyGMT installation under conda, it is necessary to specify a minimum PyGMT version as follows:

.. code::
but otherwise users can follow the normal installation procedure.
conda install 'pygmt>=0.9'
For more information, please see:
`MTUQ installation on ARM64 systems <https://uafgeotools.github.io/mtuq/install/arm64.html>`_
A more conservative approach, which avoids possible issues with PyGMT 0.10 releases, is to specify the more stable PyGMT 0.9 version:

.. code::
Installation under virutalenv
-----------------------------
conda install 'pygmt=0.9'
For most users, we recommend installing MTUQ under conda. However, in rare cases it seems that MTUQ can be more easily installed under virtualenv.
For more information, please see:
If PyGMT installation fails, most MTUQ functions will still work, but some plotting functions will fall back to GMT or ObsPy.

`MTUQ installation under virtualenv <https://uafgeotools.github.io/mtuq/install/virtualenv.html>`_
We note that some versions of GMT and ObsPy do not plot `full moment tensors <https://github.com/obspy/obspy/issues/2388>`_ correctly.


Troubleshooting PyGMT installation
----------------------------------

MTUQ uses full moment tensor plotting functions from the PyGMT graphics library.
Speeding up conda installs
--------------------------

To avoid a known issue with PyGMT installation under conda, it is necessary to specify a minimum PyGMT version as follows:
Sometimes the conda package manager can be very slow. To speed it up, older conda installations can be updated, making libmamba the default dependency solver:

.. code::
conda install 'pygmt>=0.9'
conda update -n base conda
A more conservative approach, which avoids suspected problems with PyGMT 0.10 releases, is to specify the more stable PyGMT 0.9 version:
.. code::
conda install 'pygmt=0.9'
MTUQ installation on Apple M1 and Apple M2 Macs
-----------------------------------------------

Installation on Apple M1 and Apple M2 Macs is now possible using the default installation procedure.

If PyGMT installation fails, most MTUQ functions will still work, but some plotting functions will fall back to GMT or ObsPy.
For older versions of MTUQ, a modified installation procedure may stil be necessary. For more information, please see:

We note that some versions of GMT and ObsPy do not plot `full moment tensors <https://github.com/obspy/obspy/issues/2388>`_ correctly.
`MTUQ installation on ARM64 systems <https://uafgeotools.github.io/mtuq/install/arm64.html>`_

4 changes: 2 additions & 2 deletions docs/install/virtualenv.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Installation under virtualenv
=============================

Install `virtualenv`, if not already present, following these `instructions <https://virtualenv.pypa.io/en/latest/installation.html>`_.
Install virtualenv, if not already present, following these `instructions <https://virtualenv.pypa.io/en/latest/installation.html>`_.

Create a virtual environment:

Expand All @@ -28,7 +28,7 @@ Install MTUQ:
pip install -e .
If `instaseis` installation fails, try:
If Instaseis installation fails, try:

.. code::
Expand Down
2 changes: 1 addition & 1 deletion docs/user_guide/03.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ To open an AxiSEM database client in MTUQ:
db = open_db(path_to_NetCDF_file, format="AxiSEM")
`FK <https://www.eas.slu.edu/People/LZhu/home.html>`_ simulates wave propagation in horizontally-layered elastic media using a frequency-wavenumber method. FK simulations create SAC files in a directory tree organized by model, event depth, and event distance. Each SAC file represents a vertical, radial, or transverse velocity time series in units of 10^-20*cm*(dyne-cm)^-1 s^-1.
`FK <https://www.eas.slu.edu/People/LZhu/home.html>`_ simulates wave propagation in horizontally-layered elastic media using a frequency-wavenumber integration method. FK simulations create SAC files in a directory tree organized by model, event depth, and event distance. Each SAC file represents a vertical, radial, or transverse velocity time series in units of 10^-20*cm*(dyne-cm)^-1 s^-1.


To open an FK database client in MTUQ:
Expand Down
2 changes: 1 addition & 1 deletion docs/user_guide/06/custom_backends.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Note that the backend function contains hardcoded settings that improve the appe
fig.basemap(
region=gmt_region,
projection=gmt_projection,
frame=["xa5", "ya2"],
frame=gmt_frame,
)
fig.coast(
Expand Down
6 changes: 2 additions & 4 deletions env_arm64.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# for installation on ARM64 systems, including Apple M1 and Apple M2

channels:
- defaults
- conda-forge
- defaults

dependencies:
- conda-build
Expand All @@ -21,9 +20,8 @@ dependencies:
- pytest
- pip
- pip:
- git+https://github.com/sstaehler/instaseis.git
- git+https://github.com/rmodrak/instaseis.git
- tables
- seisgen
- seishmc
- -e .

4 changes: 2 additions & 2 deletions env_default.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@

channels:
- defaults
- conda-forge
- defaults

dependencies:
- conda-build
- python=3
- numpy
- scipy
- obspy
- instaseis
- pandas
- xarray
- netCDF4
Expand All @@ -21,6 +20,7 @@ dependencies:
- pytest
- pip
- pip:
- git+https://github.com/rmodrak/instaseis.git
- tables
- seisgen
- seishmc
Expand Down
8 changes: 4 additions & 4 deletions examples/DetailedAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,11 +497,11 @@
# save processed waveforms as binary files
os.makedirs(event_id+'FMT_waveforms', exist_ok=True)

data_bw.write(event_id+'FMT_waveforms/dat_bw.p')
data_sw.write(event_id+'FMT_waveforms/dat_sw.p')
data_bw.write(event_id+'FMT_waveforms/dat_bw')
data_sw.write(event_id+'FMT_waveforms/dat_sw')

synthetics_bw.write(event_id+'FMT_waveforms/syn_bw.p')
synthetics_sw.write(event_id+'FMT_waveforms/syn_sw.p')
synthetics_bw.write(event_id+'FMT_waveforms/syn_bw')
synthetics_sw.write(event_id+'FMT_waveforms/syn_sw')


# save misfit surfaces as netCDF files
Expand Down
23 changes: 20 additions & 3 deletions mtuq/dataset.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import obspy
import os
import numpy as np
import pickle

Expand Down Expand Up @@ -268,9 +269,25 @@ def __copy__(self):
return new_ds


def write(self, filename):
def write(self, path, format='sac'):
""" Writes a Python pickle of current dataset
"""
with open(filename, "wb") as file:
pickle.dump(self, file)
if format.lower() == 'pickle':

with open(filename, "wb") as file:
pickle.dump(self, path)

elif format.lower() == 'sac':

os.makedirs(path, exist_ok=True)
for stream in self:
for trace in stream:

keys = ('network','station','location','channel')
filename = '.'.join([trace.stats[key] for key in keys])

fullpath = '%s/%s.%s' % (path,filename,'sac')
trace.write(fullpath, format='sac')



2 changes: 1 addition & 1 deletion mtuq/graphics/uq/_gmt/plot_depth
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#


# add mtuq/graphics/_gmt to the path
# add mtuq/graphics/uq/_gmt to the path
export PATH=${PATH:+${PATH}:}$(dirname ${BASH_SOURCE[0]})
source _gmt_functions

Expand Down
2 changes: 1 addition & 1 deletion mtuq/graphics/uq/_gmt/plot_force
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# PLOT_FORCE
#

# add mtuq/graphics/_gmt to the path
# add mtuq/graphics/uq/_gmt to the path
export PATH=${PATH:+${PATH}:}$(dirname ${BASH_SOURCE[0]})
source _gmt_functions

Expand Down
7 changes: 3 additions & 4 deletions mtuq/graphics/uq/_gmt/plot_latlon
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#!/bin/bash -e


# USAGE
# plot_mt_xy out filetype mt_file mw_file xmin xmax ymin ymax xlabel ylabel [title] [subtitle]
#
# PLOT_LATLON
#


# add mtuq/graphics/_gmt to the path
# add mtuq/graphics/uq/_gmt to the path
export PATH=${PATH:+${PATH}:}$(dirname ${BASH_SOURCE[0]})
source _gmt_functions

Expand Down
2 changes: 1 addition & 1 deletion mtuq/graphics/uq/_gmt/plot_lune
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#


# add mtuq/graphics/_gmt to the path
# add mtuq/graphics/uq/_gmt to the path
export PATH=${PATH:+${PATH}:}$(dirname ${BASH_SOURCE[0]})
source _gmt_functions

Expand Down
6 changes: 3 additions & 3 deletions mtuq/graphics/uq/_gmt/plot_vw
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/bash -e

#
# PLOT_LUNE
# plots values from ASCII file on eigenvalue lune
# PLOT_VW
# plots values from ASCII file on vw rectangle
#


# add mtuq/graphics/_gmt to the path
# add mtuq/graphics/uq/_gmt to the path
export PATH=${PATH:+${PATH}:}$(dirname ${BASH_SOURCE[0]})
source _gmt_functions

Expand Down
8 changes: 4 additions & 4 deletions setup/code_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1299,11 +1299,11 @@
# save processed waveforms as binary files
os.makedirs(event_id+'FMT_waveforms', exist_ok=True)
data_bw.write(event_id+'FMT_waveforms/dat_bw.p')
data_sw.write(event_id+'FMT_waveforms/dat_sw.p')
data_bw.write(event_id+'FMT_waveforms/dat_bw')
data_sw.write(event_id+'FMT_waveforms/dat_sw')
synthetics_bw.write(event_id+'FMT_waveforms/syn_bw.p')
synthetics_sw.write(event_id+'FMT_waveforms/syn_sw.p')
synthetics_bw.write(event_id+'FMT_waveforms/syn_bw')
synthetics_sw.write(event_id+'FMT_waveforms/syn_sw')
# save misfit surfaces as netCDF files
Expand Down

0 comments on commit 3730282

Please sign in to comment.