GithubHelp home page GithubHelp logo

usgs / slab2 Goto Github PK

View Code? Open in Web Editor NEW
61.0 23.0 40.0 351.8 MB

Slab2.0 is a three-dimensional compilation of global subduction geometries, separated into regional models for each major subduction zone.

License: Other

Python 93.23% Perl 0.27% Shell 0.91% Jupyter Notebook 5.59%

slab2's Introduction

Introduction

Slab2.0 is a three-dimensional (3D) compilation of global subduction zone geometries, separated into regional models for each major subduction zone. Refer to Hayes et al., 2018, Science for more details. This code contains functions for making 3D slab geometries and for updating the input for making such geometries. Please note that this code is still under development. To bypass installing and running the code in this repository, please visit the USGS Slab Model Cloud-based web application at https://earthquake.usgs.gov/slab2/ to generate a Slab2 model. Send all inquiries to Dr. Gavin P. Hayes <[email protected]> and Dr. Kirstie L. Haynie <[email protected]>.

Installation and Dependencies

A Slab2 environment (slab2env) will be created during installation. This will install all the packages and libraries that Slab2 code depends on. You must have the slab2env activated in order to run any Slab2 code that creates the models. The install has been tested only on MacOSX, and not on Windows or Linux. In addition to the slab2env, an environment used for plotting will also be created (pygmt). To run any of the code that creates plots for the Slab2 models, the pygmt environment must be activated.

This package depends on:
  • Python3
  • Anaconda
  • pip
  • numpy, the fundamental package for scientific computing with Python.
  • matplotlib, a Python 2D plotting library which produces publication quality figures.
  • scipy, a Python library which provides many user-friendly and efficient numerical routines such as routines for numerical integration and optimization.
  • mapio, a Python library for reading/writing various spatial data formats (GMT grids, etc.)
  • libcomcat, a Python library for retrieving earthquake data from the ANSS ComCat system
  • pygmt, a Python library which wraps GMT, allowing for easy manipulation of geographic and cartesian datasets.

Follow the steps below to run the Slab2 code.

  1. Clone the Slab2 Repository:

    Use the following, but provide the appropriate link:

    git clone link/to/repository

  2. Create the anaconda environments

    In the terminal within the slab2/slab2code/slab2setup directory, enter:

    bash slab2env.sh both

    Two anaconda environments, slab2env and pygmt, will be created. The slab2env should be active when using code that creates the Slab2 output data, while the pygmt environment should be active when plotting this data.

    To only create the Slab2 environment, use:

    bash slab2env.sh slab

    To only create the PyGMT environment, use:

    bash slab2env.sh gmt

  3. Create an input file

    The slab2env environment must be active, and the active directory should be slab2/slab2code

    In the terminal, enter:

    conda activate slab2env

    python sd2.py -p [slab] -d [Slab2_location]/[input date]database -f [input file csv]

  4. To create a Slab2 model

    The slab2env environment must be active, and the active directory should be slab2/slab2code

    In the terminal, enter:

    conda activate slab2env

    python slab2.py -p [path to parameter file]

    This will create the model with the most recent input file

    By appending "-c 3" to the end of the command, three cores will be used.

    To change input parameters, please refer to number 5 of Creating a Slab Model within Slab2Instructions.pdf.

    Regions mue, sul, phi, and ryu depend on depths from other slabs. Please see number 3 of Creating a Slab Model within Slab2Instructions.pdf for further details.

  5. To plot the Slab2 modeling results

    Navigate to slab2/slab2code/plotting.

    The pygmt environment must be active when using code in this directory

    To make an overview map, use map.py

    In the terminal, enter:

    conda activate pygmt

    python map.py [slab] [output date]

    To make cross sections, use xsec.py

    In the terminal, enter:

    conda activate pygmt

    python map.py [slab] [output date] [input date] all

For more complete examples and instructions, please see Slab2Instructions.pdf.

slab2's People

Contributors

ghayes-usgs avatar khaynie-usgs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

slab2's Issues

KeyError: "['D1', 'mlon', 'time', 'R1', 'D2', 'mlat', 'S1', 'S2', 'mdep', 'mag', 'R2'] not in index" in slab2.py main line 413 resulting from incomplete input file

This error occurs while creating a slab model for Cascadia. The following is the process to recreate the issue.

Copy all CSVs from the /slab2_master/MasterDB directories beginning with 'cas' to a new /slab2_master/0521database directory

cd to /slab2_master/slab2code
Replace occurrences of vincenty with geodesic from geodis.distance

conda activate slab2env

python s2d.py -p cas -d ../0521database -f cas_05-21_input.csv

mv cas_05-21_input.csv Input/

python slab2.py -p library/parameterfiles/casinput.par

See full output below:

Start Section 1 of 7: Setup
Loading inputs...
.DS_Store
exp_04-18_input.csv
cas_05-21_input.csv
.gitignore
using input file: Input/cas_05-21_input.csv
mkdir: Output/cas_slab2_05.08.21: File exists
/usr/local/anaconda3/envs/slab2env/lib/python3.7/site-packages/numpy/core/_asarray.py:102: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
return array(a, dtype, copy=False, order=order)
slab guide for this model: <GMTGrid Object:
ny: 281
nx: 241
xmin: -130.0000
xmax: -118.0000
ymin: 37.0000
ymax: 51.0000
dx: 0.0500
dy: 0.0500
zmin: -417.520630
zmax: -2.823972>
Traceback (most recent call last):
File "slab2.py", line 1833, in
main(pargs)
File "slab2.py", line 413, in main
eventlist = eventlistALL[kagancols]
File "/usr/local/anaconda3/envs/slab2env/lib/python3.7/site-packages/pandas/core/frame.py", line 3030, in getitem
indexer = self.loc._get_listlike_indexer(key, axis=1, raise_missing=True)[1]
File "/usr/local/anaconda3/envs/slab2env/lib/python3.7/site-packages/pandas/core/indexing.py", line 1266, in _get_listlike_indexer
self._validate_read_indexer(keyarr, indexer, axis, raise_missing=raise_missing)
File "/usr/local/anaconda3/envs/slab2env/lib/python3.7/site-packages/pandas/core/indexing.py", line 1316, in _validate_read_indexer
raise KeyError(f"{not_found} not in index")
KeyError: "['D1', 'mlon', 'time', 'R1', 'D2', 'mlat', 'S1', 'S2', 'mdep', 'mag', 'R2'] not in index"

Explanation:
This error was replicated for the 'alu' region.
Input files made with s2d.py do not contain the columns corresponding to the above key errors, hence they are not indexed. This error does not occur when using the 'cas' input file made by makeallinputs.py (I have not checked other regions).

trouble installing slab2

Hi,

So I m trying to get slab 2.0 running on my desktop (on which Linux debian is running).

  1. First trying to run 'slab2env.sh' I got an error when running the script because $_CONDA_ROOT was an empty string (within the script).
    I first tried changing source ~/.bash_profile against source ~/.bashrc but it did not help.
    the 2 last lines of my ~/.bashrc are:

. /export/data/ulrich/MyLibs/anaconda3/etc/profile.d/conda.sh
conda activate base

I finally came up a solution for that:
using '. /export/data/ulrich/MyLibs/anaconda3/etc/profile.d/conda.sh' instead of 'source ~/.bash_profile' in your script and the install script then runs.

  1. let's first comment the 3 pip install. I then get this error:

ResolvePackageNotFound:

  • gdal==2.1.3=py35_7
  • bcrypt==3.1.4=py35h7e31480_0
  • qt==5.6.2=h9e3eb04_4
  • appnope==0.1.0=py35_0
  • webencodings==0.5.1=py35_0
  1. getting over this error, if I then uncomment the last 3 pip install, I get the following error:

creating /usr/local/lib/python2.7/dist-packages/impactutils
error: could not create '/usr/local/lib/python2.7/dist-packages/impactutils': Permission denied
Probably because I m not root. This is fixed by adding '--user' to the last pip.

So I m almost done, but 2) is not fixed.

Thx in advance,

Thomas.

ImportError: cannot import name 'vincenty' from 'geopy.distance'

Hello!

I am trying to create an input file but the following error appears while typing
python s2d.py -p alu -d ~/Escritorio/slab2-master/1219database -f alu_12-19_input.csv
in [slab2folder]/slab2code:

Traceback (most recent call last):
File "s2d.py", line 12, in
from s2d_fnctns import *
File "/home/benjamin/Escritorio/slab2-master/slab2code/s2d_fnctns.py", line 11, in
from geopy.distance import vincenty
ImportError: cannot import name 'vincenty' from 'geopy.distance' (/home/benjamin/anaconda3/envs/slab2env/lib/python3.7/site-packages/geopy/distance.py)

Typing python s2d.py -h or python s2d_fnctns.py -h throws a similar error.

Cheers,
Benjamín

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.