Skip to content

Fix missing gcmt convention keys in pygmt.meca #1611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion pygmt/src/meca.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,16 @@ def update_pointers(data_pointers):

param_conventions = {
"AKI": ["strike", "dip", "rake", "magnitude"],
"GCMT": ["strike1", "dip1", "dip2", "rake2", "mantissa", "exponent"],
"GCMT": [
"strike1",
"dip1",
"rake1",
"strike2",
"dip2",
"rake2",
"mantissa",
"exponent",
],
"MT": ["mrr", "mtt", "mff", "mrt", "mrf", "mtf", "exponent"],
"PARTIAL": ["strike1", "dip1", "strike2", "fault_type", "magnitude"],
"PRINCIPAL_AXIS": [
Expand Down
4 changes: 4 additions & 0 deletions pygmt/tests/baseline/test_meca_gcmt_convention.png.dvc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
outs:
- md5: a44dc0f1af50958aeff2d359ea8b03a7
size: 8732
path: test_meca_gcmt_convention.png
35 changes: 31 additions & 4 deletions pygmt/tests/test_meca.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
"""
Tests for meca.
"""
import os

import numpy as np
import pandas as pd
import pytest
from pygmt import Figure
from pygmt.helpers import GMTTempFile

TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), "data")


@pytest.mark.mpl_image_compare
def test_meca_spec_dictionary():
Expand Down Expand Up @@ -210,3 +206,34 @@ def test_meca_loc_array():
projection="M14c",
)
return fig


@pytest.mark.mpl_image_compare
def test_meca_gcmt_convention():
"""
Test plotting beachballs using the global CMT convention.
"""
fig = Figure()
# specify focal mechanisms
focal_mechanisms = dict(
strike1=180,
dip1=18,
rake1=-88,
strike2=0,
dip2=72,
rake2=-90,
mantissa=5.5,
exponent=0,
)
fig.meca(
spec=focal_mechanisms,
scale="1c",
longitude=239.384,
latitude=34.556,
depth=12,
convention="gcmt",
region=[239, 240, 34, 35.2],
projection="m2.5c",
frame=True,
)
return fig