From 9a031b20eb53a4d1c13370054304329f18db8baa Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 29 May 2023 20:43:09 +0200 Subject: [PATCH 001/105] Add basic structur and code examples for meca tutorial --- .../tutorials/advanced/focal_mechanisms.py | 411 ++++++++++++++++++ 1 file changed, 411 insertions(+) create mode 100755 examples/tutorials/advanced/focal_mechanisms.py diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py new file mode 100755 index 00000000000..92e7f5e7c7f --- /dev/null +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -0,0 +1,411 @@ +""" +Plotting focal mechanisms +========================= +Focal mechanisms can be plotted with the :meth:`pygmt.Figure.meca` method. + +Beside an external file containing the input data, PyGMT allows for different +input types: + +- 1-D and 2-D array +- dictionary +- pandas DataFrame + +Different convention are supported: +TODO add required variables + +- ``"aki"``: Aki & Richards - +- ``"gcmt"``: Global CMT - +- ``"mt"``: Seismic moment tensor - +- ``"partial"``: Partial focal mechanism - +- ``"principal_axis"``: Principal axis - + +Please refer also the documentation on how to set the input data in respect to +the chosen convention. + +This tutorial shows how to adjust the display of the beachballs: + +- Adjust outline +- Fill quadrants with colors or patterns +- Highlight nodal plane +- Offset beachball form event location +- Size- and color-coding by magnitude or hypocentral depth +- Add label +""" + +# sphinx_gallery_thumbnail_number = 6 + + +# Import the required packages +import pygmt + +############################################################################### +# Set up input data +# ----------------- +# Define study area: lon_min, lon_max, lat_min, lat_max +# in degrees Eath or North +study_area = [-84, -76, -4, 4] + +# Store focal mechanism parameters in a dictionary based on the Aki & Richards +# convention +fm_single = dict(strike=166, dip=80, rake=74, magnitude=5.8) + +# TODO +# Set up list of four earthquakes: +# - Haiti on 2010/01/12 +# - Esmeraldas on 2022/03/27 +# - Afghanistan on 2022/06/21 +# - Syria / Turkey on 2023/02/06 +fm_collection = dict( + strike=[116, 116, 166, 166], + dip=[80, 80, 80, 80], + rake=[74, 74, 74, 74], + magnitude=[7.0, 5.8, 6.0, 7.8], + longitude=[-72.53, -79.611, 69.46, 37.032], + latitude=[18.46, 0.904, 33.02, 37.166], + depth=[13, 26.52, 4, 10], +) + + +############################################################################### +# Plot a single beachball +# ----------------------- +# Required parameters are ``spec``, ``scale``, ``longitude`` and ``latitude`` +# (event location) + +fig = pygmt.Figure() + +# Create basic map of study area +fig.coast( + region=study_area, + projection="M10c", + land="lightgray", + water="lightblue", + shorelines="1/0.5p,darkgray", + borders="1/0.5p,darkred", + frame=True, +) + +# Pass the focal mechanism data through the spec parameter +# Addionally scale and event location are required +fig.meca( + spec=fm_single, + scale="1c", # in centimeters + longitude=-79.611, + latitude=0.904, +) + +fig.show() + + +############################################################################### +# Adjust outline +# -------------- +# parameters ``pen`` and **L** -> ``outline`` + +# Create new figure instance +fig = pygmt.Figure() + +# Create basic map of study area +fig.coast( + region=study_area, + projection="M10c", # Mercator projection with width 10 centimeters + land="lightgray", + water="lightblue", + shorelines="1/0.5p,darkgray", + borders="1/0.5p,darkred", + frame=["af", "WSne"], +) + +# Plot focal mechanism +fig.meca( + spec=fm_single, + scale="1c", # in centimeters + longitude=-79.611, # event longitude + latitude=0.904, # event latitude + pen="1p,blue,solid", +) + +# Shift plot origin 11 centimeters to the right +fig.shift_origin(xshift="11c") + +# Create basic map of study area +fig.coast( + region=study_area, + projection="M10c", + land="lightgray", + water="lightblue", + shorelines="1/0.5p,darkgray", + borders="1/0.5p,darkred", + frame=["af", "wSnE"], +) + +# Plot focal mechanism +fig.meca( + spec=fm_single, + scale="1c", # in centimeters + longitude=-79.611, + latitude=0.904, + L="1p,red,solid", +) + +fig.show() + + +############################################################################### +# Fill quadrants with colors and patterns +# --------------------------------------- +# parameters ``compressionfill`` and ``extensionfill`` + +# Create new figure instance +fig = pygmt.Figure() + +# Create basic map of study area +fig.coast( + region=study_area, + projection="M10c", + land="lightgray", + water="lightblue", + shorelines="1/0.5p,darkgray", + borders="1/0.5p,darkred", + frame=["af", "WSne"], +) + +# Plot focal mechanism +fig.meca( + spec=fm_single, + scale="1c", # in centimeters + longitude=-79.611, + latitude=0.904, + compressionfill="lightred", + extensionfill="cornsilk", +) + +# Shift plot origin 11 centimeters to the right +fig.shift_origin(xshift="11c") + +# Create basic map of study area +fig.coast( + region=study_area, + projection="M10c", + land="lightgray", + water="lightblue", + shorelines="1/0.5p,darkgray", + borders="1/0.5p,darkred", + frame=["af", "wSnE"], +) + +# Plot focal mechanism +fig.meca( + spec=fm_single, + scale="1c", + longitude=-79.611, + latitude=0.904, + compressionfill="p8", + extensionfill="p31", + L=True, +) + +fig.show() + + +############################################################################### +# Highlight nodal planes +# ---------------------- +# parameter **T** -> ``nodalplanes`` +# Use stacking concept of GMT - plot on top of each other + +# Create new figure instance +fig = pygmt.Figure() + +# Create basic map of study area +fig.coast( + region=study_area, + projection="M10c", + land="lightgray", + water="lightblue", + shorelines="1/0.5p,darkgray", + borders="1/0.5p,darkred", + frame=["af", "WSne"], +) + +# Plot focal mechanism +fig.meca( + spec=fm_single, + scale="1c", # in centimeters + longitude=-79.611, + latitude=0.904, + T="0/1p,black,solid", +) + +# Shift plot origin 11 centimeters to the right +fig.shift_origin(xshift="11c") + +# Create basic map of study area +fig.coast( + region=study_area, + projection="M10c", + land="lightgray", + water="lightblue", + shorelines="1/0.5p,darkgray", + borders="1/0.5p,darkred", + frame=["af", "wSnE"], +) + +# Plot focal mechanism +fig.meca( + spec=fm_single, + scale="1c", + longitude=-79.611, + latitude=0.904, + compressionfill="darkgray", + L="1p,red,solid", +) + +fig.meca( + spec=fm_single, + scale="1c", + longitude=-79.611, + latitude=0.904, + T="1/1p,black,solid", +) + +fig.show() + + +############################################################################### +# Offset beachball from event location +# ------------------------------------ +# Prameters ``plot_longitude`` and ``plot_latitude`` as well as ``offset`` + +# Create new figure instance +fig = pygmt.Figure() + +# Create basic map of study area +fig.coast( + region=study_area, + projection="M10c", + land="lightgray", + water="lightblue", + shorelines="1/0.5p,darkgray", + borders="1/0.5p,darkred", + frame=["af", "WSne"], +) + +# Plot focal mechanism +fig.meca( + spec=fm_single, + scale="1c", # in centimeters + longitude=-79.611, + latitude=0.904, + plot_longitude=-78, + plot_latitude=0, + offset=True, +) + +# Shift plot origin 11 centimeters to the right +fig.shift_origin(xshift="11c") + +# Create basic map of study area +fig.coast( + region=study_area, + projection="M10c", + land="lightgray", + water="lightblue", + shorelines="1/0.5p,darkgray", + borders="1/0.5p,darkred", + frame=["af", "wSnE"], +) + +# Plot focal mechanism +fig.meca( + spec=fm_single, + scale="1c", + longitude=-79.611, + latitude=0.904, + plot_longitude=-78, + plot_latitude=0, + offset="+p1p,red+s0.25c", + compressionfill="lightred", +) + +fig.show() + + +############################################################################### +# Size- and color-coding by magnitude and hypocentral depth +# --------------------------------------------------------- +# Set up colormap and use parameter ``cmap`` +# e.g. by magnitude and hypocentral depth + +# Create new figure instance +fig = pygmt.Figure() + +# Create basic map of study area +fig.coast( + region="d", + projection="N10c", + land="lightgray", + water="lightblue", + shorelines="1/0.5p,darkgray", + frame=["af", "WsNE"], +) + +# Set up colormap for hypocentral depth +pygmt.makecpt( + cmap="lajolla", + series=[0, 30, 1], +) + +# Plot focal mechanism +fig.meca( + spec=fm_collection, + scale="0.3c", + cmap=True, + L=True, +) + +# Add colorbar +fig.colorbar(frame="x+lhpyocentral depth / km") + +fig.show() + + +############################################################################### +# Add label +# --------- +# ``event_name`` as parameter or as column +# **Fr** -> ``box`` +# e.g., event date or time +# +# TODO figure out how to change font size of trailing text + +# Create new figure instance +fig = pygmt.Figure() + +# Create basic map of study area +fig.coast( + region="d", + projection="N10c", + land="lightgray", + water="lightblue", + shorelines="1/0.5p,darkgray", + frame=["af", "WSnE"], +) + +# Set up colormap for hypocentral depth +pygmt.makecpt( + cmap="lajolla", + series=[0, 30, 1], +) + +# Plot focal mechanism +fig.meca( + spec=fm_collection, + scale="0.3c", # in centimeters + # TODO double check dates + cmap=True, + event_name=["2010/01/12", "2022/03/27", "2022/06/21", "2023/02/06"], + Fr="white@30", +) + +fig.show() From 24802bbec7e1d58bf52d5600cee6ac4393d3d4c1 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 29 May 2023 22:15:43 +0200 Subject: [PATCH 002/105] Fix typos --- examples/tutorials/advanced/focal_mechanisms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 92e7f5e7c7f..918a7f6fdd2 100755 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -10,7 +10,7 @@ - dictionary - pandas DataFrame -Different convention are supported: +Different conventions are supported: TODO add required variables - ``"aki"``: Aki & Richards - @@ -86,7 +86,7 @@ ) # Pass the focal mechanism data through the spec parameter -# Addionally scale and event location are required +# additionally scale and event location are required fig.meca( spec=fm_single, scale="1c", # in centimeters From 686bf923c0c52c37ed740c7ce7d9c99a5f7231ff Mon Sep 17 00:00:00 2001 From: actions-bot <58130806+actions-bot@users.noreply.github.com> Date: Mon, 29 May 2023 20:17:28 +0000 Subject: [PATCH 003/105] [format-command] fixes --- examples/tutorials/advanced/focal_mechanisms.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/tutorials/advanced/focal_mechanisms.py diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py old mode 100755 new mode 100644 From 744cf3f2d43eebe89024de30a6bfcd6071804c21 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Tue, 30 May 2023 15:03:02 +0200 Subject: [PATCH 004/105] Use 'nodal', Adjust front size of 'event_name' label --- examples/tutorials/advanced/focal_mechanisms.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 918a7f6fdd2..f9194c76efb 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -211,7 +211,7 @@ ############################################################################### # Highlight nodal planes # ---------------------- -# parameter **T** -> ``nodalplanes`` +# parameter **T** -> ``nodal`` # Use stacking concept of GMT - plot on top of each other # Create new figure instance @@ -377,7 +377,7 @@ # **Fr** -> ``box`` # e.g., event date or time # -# TODO figure out how to change font size of trailing text +# TODO figure out how to change font size of trailing text -> ``scale`` **+f** # Create new figure instance fig = pygmt.Figure() @@ -401,7 +401,7 @@ # Plot focal mechanism fig.meca( spec=fm_collection, - scale="0.3c", # in centimeters + scale="0.3c+f5p", # in centimeters # TODO double check dates cmap=True, event_name=["2010/01/12", "2022/03/27", "2022/06/21", "2023/02/06"], From f3f0bd3d6e0fb01211a99dfc80cc69a431fe94e5 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Tue, 30 May 2023 18:28:19 +0200 Subject: [PATCH 005/105] Remove color-coding from section 'Add label' --- examples/tutorials/advanced/focal_mechanisms.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index f9194c76efb..8b7cb589723 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -392,18 +392,11 @@ frame=["af", "WSnE"], ) -# Set up colormap for hypocentral depth -pygmt.makecpt( - cmap="lajolla", - series=[0, 30, 1], -) - # Plot focal mechanism fig.meca( spec=fm_collection, scale="0.3c+f5p", # in centimeters # TODO double check dates - cmap=True, event_name=["2010/01/12", "2022/03/27", "2022/06/21", "2023/02/06"], Fr="white@30", ) From 9d19715a2c9fcbeb6344fe713f997e5c27c1d1a7 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Tue, 30 May 2023 18:42:48 +0200 Subject: [PATCH 006/105] Add section 'Plot several beachballs' --- .../tutorials/advanced/focal_mechanisms.py | 67 +++++++++++++------ 1 file changed, 47 insertions(+), 20 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 8b7cb589723..8a1645b3089 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -28,7 +28,7 @@ - Fill quadrants with colors or patterns - Highlight nodal plane - Offset beachball form event location -- Size- and color-coding by magnitude or hypocentral depth +- Size-coding and color-coding - Add label """ @@ -49,22 +49,6 @@ # convention fm_single = dict(strike=166, dip=80, rake=74, magnitude=5.8) -# TODO -# Set up list of four earthquakes: -# - Haiti on 2010/01/12 -# - Esmeraldas on 2022/03/27 -# - Afghanistan on 2022/06/21 -# - Syria / Turkey on 2023/02/06 -fm_collection = dict( - strike=[116, 116, 166, 166], - dip=[80, 80, 80, 80], - rake=[74, 74, 74, 74], - magnitude=[7.0, 5.8, 6.0, 7.8], - longitude=[-72.53, -79.611, 69.46, 37.032], - latitude=[18.46, 0.904, 33.02, 37.166], - depth=[13, 26.52, 4, 10], -) - ############################################################################### # Plot a single beachball @@ -332,10 +316,53 @@ ############################################################################### -# Size- and color-coding by magnitude and hypocentral depth -# --------------------------------------------------------- +# Plot several beachballs +# ----------------------- +# TODO +# Set up list of four earthquakes: +# - Haiti on 2010/01/12 +# - Esmeraldas on 2022/03/27 +# - Afghanistan on 2022/06/21 +# - Syria / Turkey on 2023/02/06 +fm_collection = dict( + strike=[116, 116, 166, 166], + dip=[80, 80, 80, 80], + rake=[74, 74, 74, 74], + magnitude=[7.0, 5.8, 6.0, 7.8], + longitude=[-72.53, -79.611, 69.46, 37.032], + latitude=[18.46, 0.904, 33.02, 37.166], + depth=[13, 26.52, 4, 10], +) + +# fixed size via ``scale`` append **+m** + +# Create new figure instance +fig = pygmt.Figure() + +# Create basic map of study area +fig.coast( + region="d", + projection="N10c", + land="lightgray", + water="lightblue", + shorelines="1/0.5p,darkgray", + frame=["af", "WSnE"], +) + +# Plot focal mechanism +fig.meca( + spec=fm_collection, + scale="0.3c+m", # in centimeters +) + +fig.show() + + +############################################################################### +# Size-coding and color-coding +# ---------------------------- +# e.g., by magnitude or hypocentral depth # Set up colormap and use parameter ``cmap`` -# e.g. by magnitude and hypocentral depth # Create new figure instance fig = pygmt.Figure() From ba9debfb6c47d1a598fe45c5eb864b7ff8f44600 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Tue, 30 May 2023 20:32:55 +0200 Subject: [PATCH 007/105] Expand convention list, Adjust the other lists in the introduction part --- .../tutorials/advanced/focal_mechanisms.py | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 8a1645b3089..b4e97740d42 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -6,28 +6,33 @@ Beside an external file containing the input data, PyGMT allows for different input types: -- 1-D and 2-D array +- 1-D (single event) and 2-D array (multiple events) - dictionary - pandas DataFrame Different conventions are supported: -TODO add required variables -- ``"aki"``: Aki & Richards - -- ``"gcmt"``: Global CMT - -- ``"mt"``: Seismic moment tensor - -- ``"partial"``: Partial focal mechanism - -- ``"principal_axis"``: Principal axis - - -Please refer also the documentation on how to set the input data in respect to -the chosen convention. +- Aki & Richards - ``"aki"``: + *strike*, *dip*, *rake*, *magnitude* +- Global CMT - ``"gcmt"``: + *strike1*, *dip1*, *rake1*, *strike2*, *dip2*, *rake2*, *mantissa*, *exponent* +- Seismic moment tensor - ``"mt"``: + *mrr*, *mtt*, *mff*, *mrt*, *mrf*, *mtf*, *exponent* +- Partial focal mechanism - ``"partial"``: + *strike1*, *dip1*, *strike2*, *fault_type*, *magnitude* +- Principal axis - ``"principal_axis"``: + *t_value*, *t_azimuth*, *t_plunge*, *n_value*, *n_azimuth*, *n_plunge*, + *p_value*, *p_azimuth*, *p_plunge*, *exponent* + +Please refer also the documentation on how to set up the input data in respect +to the chosen input type and convention. This tutorial shows how to adjust the display of the beachballs: - Adjust outline -- Fill quadrants with colors or patterns +- Fill quadrants with colors and patterns - Highlight nodal plane -- Offset beachball form event location +- Offset beachball from event location - Size-coding and color-coding - Add label """ From 5e12f74433680d2ce7fd51424abcb97b7a0ddc53 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Tue, 30 May 2023 20:35:45 +0200 Subject: [PATCH 008/105] Fix line length --- examples/tutorials/advanced/focal_mechanisms.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index b4e97740d42..b57aec0f7e8 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -15,7 +15,8 @@ - Aki & Richards - ``"aki"``: *strike*, *dip*, *rake*, *magnitude* - Global CMT - ``"gcmt"``: - *strike1*, *dip1*, *rake1*, *strike2*, *dip2*, *rake2*, *mantissa*, *exponent* + *strike1*, *dip1*, *rake1*, *strike2*, *dip2*, *rake2*, *mantissa*, + *exponent* - Seismic moment tensor - ``"mt"``: *mrr*, *mtt*, *mff*, *mrt*, *mrf*, *mtf*, *exponent* - Partial focal mechanism - ``"partial"``: From 4a8a24e907fe9d1b872cedd50dce37045e8dd1a2 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Tue, 30 May 2023 21:07:23 +0200 Subject: [PATCH 009/105] Adjust code and comments --- .../tutorials/advanced/focal_mechanisms.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index b57aec0f7e8..68206d76493 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -33,7 +33,7 @@ - Adjust outline - Fill quadrants with colors and patterns - Highlight nodal plane -- Offset beachball from event location +- Offset from event location - Size-coding and color-coding - Add label """ @@ -47,6 +47,7 @@ ############################################################################### # Set up input data # ----------------- +# # Define study area: lon_min, lon_max, lat_min, lat_max # in degrees Eath or North study_area = [-84, -76, -4, 4] @@ -263,8 +264,8 @@ ############################################################################### -# Offset beachball from event location -# ------------------------------------ +# Offset from event location +# -------------------------- # Prameters ``plot_longitude`` and ``plot_latitude`` as well as ``offset`` # Create new figure instance @@ -331,7 +332,7 @@ # - Afghanistan on 2022/06/21 # - Syria / Turkey on 2023/02/06 fm_collection = dict( - strike=[116, 116, 166, 166], + strike=[166, 166, 166, 166], dip=[80, 80, 80, 80], rake=[74, 74, 74, 74], magnitude=[7.0, 5.8, 6.0, 7.8], @@ -351,7 +352,7 @@ projection="N10c", land="lightgray", water="lightblue", - shorelines="1/0.5p,darkgray", + shorelines="1/0.1p,darkgray", frame=["af", "WSnE"], ) @@ -379,7 +380,7 @@ projection="N10c", land="lightgray", water="lightblue", - shorelines="1/0.5p,darkgray", + shorelines="1/0.1p,darkgray", frame=["af", "WsNE"], ) @@ -398,7 +399,7 @@ ) # Add colorbar -fig.colorbar(frame="x+lhpyocentral depth / km") +fig.colorbar(frame=["x+lhpyocentral depth", "y+lkm"]) fig.show() @@ -421,14 +422,14 @@ projection="N10c", land="lightgray", water="lightblue", - shorelines="1/0.5p,darkgray", + shorelines="1/0.1p,darkgray", frame=["af", "WSnE"], ) # Plot focal mechanism fig.meca( spec=fm_collection, - scale="0.3c+f5p", # in centimeters + scale="0.3c+m+f5p", # in centimeters # TODO double check dates event_name=["2010/01/12", "2022/03/27", "2022/06/21", "2023/02/06"], Fr="white@30", From e2d705da946a27372e412cfa0dbfcaedc729da37 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Tue, 30 May 2023 21:35:07 +0200 Subject: [PATCH 010/105] Adjust thumbnail figure --- examples/tutorials/advanced/focal_mechanisms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 68206d76493..06ab65b1256 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -38,7 +38,7 @@ - Add label """ -# sphinx_gallery_thumbnail_number = 6 +# sphinx_gallery_thumbnail_number = 7 # Import the required packages From 725f54d398fd8c91d644d359106d94282c8b1a5a Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Tue, 30 May 2023 22:24:38 +0200 Subject: [PATCH 011/105] Fix code comment --- examples/tutorials/advanced/focal_mechanisms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 06ab65b1256..7dfc879e7c3 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -47,7 +47,7 @@ ############################################################################### # Set up input data # ----------------- -# + # Define study area: lon_min, lon_max, lat_min, lat_max # in degrees Eath or North study_area = [-84, -76, -4, 4] From ec062819802fa1307fdf5fbd7c2772c1e81ae8dc Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Wed, 31 May 2023 08:51:47 +0200 Subject: [PATCH 012/105] Adjust stuff regarding 'input data' --- .../tutorials/advanced/focal_mechanisms.py | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 7dfc879e7c3..4473a29eab6 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -11,20 +11,25 @@ - pandas DataFrame Different conventions are supported: +TODO - input file and arrary, this only is for dictionary and DataFrame -- Aki & Richards - ``"aki"``: +- ``"aki"`` - Aki & Richards: *strike*, *dip*, *rake*, *magnitude* -- Global CMT - ``"gcmt"``: +- ``"gcmt"`` - global CMT: *strike1*, *dip1*, *rake1*, *strike2*, *dip2*, *rake2*, *mantissa*, *exponent* -- Seismic moment tensor - ``"mt"``: +- ``"mt"`` - seismic moment tensor: *mrr*, *mtt*, *mff*, *mrt*, *mrf*, *mtf*, *exponent* -- Partial focal mechanism - ``"partial"``: +- ``"partial"`` - partial focal mechanism: *strike1*, *dip1*, *strike2*, *fault_type*, *magnitude* -- Principal axis - ``"principal_axis"``: +- ``"principal_axis"`` - principal axis: *t_value*, *t_azimuth*, *t_plunge*, *n_value*, *n_azimuth*, *n_plunge*, *p_value*, *p_azimuth*, *p_plunge*, *exponent* +The general structur for the input data is: + +- xxx + Please refer also the documentation on how to set up the input data in respect to the chosen input type and convention. @@ -47,16 +52,20 @@ ############################################################################### # Set up input data # ----------------- +# TODO - consistent with lists in introduction + +# Store focal mechanism parameters +# in a 1-D array +fm_sinlge = "xxx" +# in pandas DataFrame +fm_single = "xxx" +# in a dictionary based on the Aki & Richards convention +fm_single = dict(strike=166, dip=80, rake=74, magnitude=5.8) # Define study area: lon_min, lon_max, lat_min, lat_max -# in degrees Eath or North +# in degrees East or North study_area = [-84, -76, -4, 4] -# Store focal mechanism parameters in a dictionary based on the Aki & Richards -# convention -fm_single = dict(strike=166, dip=80, rake=74, magnitude=5.8) - - ############################################################################### # Plot a single beachball # ----------------------- From e97f1b432f29fec6b98f5d1a6ae9fa2bc97c08b1 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 10 Jun 2023 12:47:05 +0200 Subject: [PATCH 013/105] Use aliases for 'L', 'T', and 'Fr' --- .../tutorials/advanced/focal_mechanisms.py | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 4473a29eab6..8ad003007a4 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -100,7 +100,7 @@ ############################################################################### # Adjust outline # -------------- -# parameters ``pen`` and **L** -> ``outline`` +# parameters ``pen`` and ``outline`` # Create new figure instance fig = pygmt.Figure() @@ -145,7 +145,7 @@ scale="1c", # in centimeters longitude=-79.611, latitude=0.904, - L="1p,red,solid", + outline="1p,red,solid", ) fig.show() @@ -202,7 +202,7 @@ latitude=0.904, compressionfill="p8", extensionfill="p31", - L=True, + outline=True, ) fig.show() @@ -211,7 +211,7 @@ ############################################################################### # Highlight nodal planes # ---------------------- -# parameter **T** -> ``nodal`` +# parameter ``nodal`` # Use stacking concept of GMT - plot on top of each other # Create new figure instance @@ -234,7 +234,7 @@ scale="1c", # in centimeters longitude=-79.611, latitude=0.904, - T="0/1p,black,solid", + nodal="0/1p,black,solid", ) # Shift plot origin 11 centimeters to the right @@ -258,7 +258,7 @@ longitude=-79.611, latitude=0.904, compressionfill="darkgray", - L="1p,red,solid", + outline="1p,red,solid", ) fig.meca( @@ -266,7 +266,7 @@ scale="1c", longitude=-79.611, latitude=0.904, - T="1/1p,black,solid", + nodal="1/1p,black,solid", ) fig.show() @@ -336,10 +336,12 @@ # ----------------------- # TODO # Set up list of four earthquakes: + # - Haiti on 2010/01/12 # - Esmeraldas on 2022/03/27 # - Afghanistan on 2022/06/21 # - Syria / Turkey on 2023/02/06 + fm_collection = dict( strike=[166, 166, 166, 166], dip=[80, 80, 80, 80], @@ -404,7 +406,7 @@ spec=fm_collection, scale="0.3c", cmap=True, - L=True, + outline=True, ) # Add colorbar @@ -417,10 +419,10 @@ # Add label # --------- # ``event_name`` as parameter or as column -# **Fr** -> ``box`` +# ``labelbox`` # e.g., event date or time # -# TODO figure out how to change font size of trailing text -> ``scale`` **+f** +# change font size of trailing text ``scale`` **+f** # Create new figure instance fig = pygmt.Figure() @@ -441,7 +443,7 @@ scale="0.3c+m+f5p", # in centimeters # TODO double check dates event_name=["2010/01/12", "2022/03/27", "2022/06/21", "2023/02/06"], - Fr="white@30", + labelbox="white@30", ) fig.show() From 4a390fc154a7c08675e99276265a3578b9b050ce Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 3 Sep 2023 12:34:38 +0200 Subject: [PATCH 014/105] Add remark regarding GMT issue #7777 and PR #7778 --- examples/tutorials/advanced/focal_mechanisms.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 8ad003007a4..2b3f334e473 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -3,6 +3,8 @@ ========================= Focal mechanisms can be plotted with the :meth:`pygmt.Figure.meca` method. +TODO: Check GMT issue #7777 and PR #7778 + Beside an external file containing the input data, PyGMT allows for different input types: From 96ee76806532af510909ab442e67abdccd7c4af3 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 4 Sep 2023 21:10:20 +0200 Subject: [PATCH 015/105] Add empty line after heading in tutorial 'focal_mechanisms.py' --- examples/tutorials/advanced/focal_mechanisms.py | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 2b3f334e473..1bc50c02457 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -1,6 +1,7 @@ """ Plotting focal mechanisms ========================= + Focal mechanisms can be plotted with the :meth:`pygmt.Figure.meca` method. TODO: Check GMT issue #7777 and PR #7778 From 16fae40de8d611f2e84b2e70c57f76b64cc5bebb Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 4 Sep 2023 21:13:09 +0200 Subject: [PATCH 016/105] Update code separate in tutorial 'focal_mechanisms.py' --- .../tutorials/advanced/focal_mechanisms.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 1bc50c02457..17458461d31 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -52,7 +52,7 @@ # Import the required packages import pygmt -############################################################################### +# %% # Set up input data # ----------------- # TODO - consistent with lists in introduction @@ -69,7 +69,7 @@ # in degrees East or North study_area = [-84, -76, -4, 4] -############################################################################### +# %% # Plot a single beachball # ----------------------- # Required parameters are ``spec``, ``scale``, ``longitude`` and ``latitude`` @@ -100,7 +100,7 @@ fig.show() -############################################################################### +# %% # Adjust outline # -------------- # parameters ``pen`` and ``outline`` @@ -154,7 +154,7 @@ fig.show() -############################################################################### +# %% # Fill quadrants with colors and patterns # --------------------------------------- # parameters ``compressionfill`` and ``extensionfill`` @@ -211,7 +211,7 @@ fig.show() -############################################################################### +# %% # Highlight nodal planes # ---------------------- # parameter ``nodal`` @@ -275,7 +275,7 @@ fig.show() -############################################################################### +# %% # Offset from event location # -------------------------- # Prameters ``plot_longitude`` and ``plot_latitude`` as well as ``offset`` @@ -334,7 +334,7 @@ fig.show() -############################################################################### +# %% # Plot several beachballs # ----------------------- # TODO @@ -379,7 +379,7 @@ fig.show() -############################################################################### +# %% # Size-coding and color-coding # ---------------------------- # e.g., by magnitude or hypocentral depth @@ -418,7 +418,7 @@ fig.show() -############################################################################### +# %% # Add label # --------- # ``event_name`` as parameter or as column From af105a3fc58c450fc063783376b61b92783c42e7 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 4 Sep 2023 21:14:16 +0200 Subject: [PATCH 017/105] Use two empty lines befor sub-sections --- examples/tutorials/advanced/focal_mechanisms.py | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 17458461d31..d1954eee880 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -69,6 +69,7 @@ # in degrees East or North study_area = [-84, -76, -4, 4] + # %% # Plot a single beachball # ----------------------- From a4573311ecec2767a239245d927a26d1ca29904e Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 4 Sep 2023 21:15:44 +0200 Subject: [PATCH 018/105] Use empty line after sub-section --- examples/tutorials/advanced/focal_mechanisms.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index d1954eee880..9502a705985 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -55,6 +55,7 @@ # %% # Set up input data # ----------------- +# # TODO - consistent with lists in introduction # Store focal mechanism parameters @@ -73,6 +74,7 @@ # %% # Plot a single beachball # ----------------------- +# # Required parameters are ``spec``, ``scale``, ``longitude`` and ``latitude`` # (event location) @@ -104,6 +106,7 @@ # %% # Adjust outline # -------------- +# # parameters ``pen`` and ``outline`` # Create new figure instance @@ -158,6 +161,7 @@ # %% # Fill quadrants with colors and patterns # --------------------------------------- +# # parameters ``compressionfill`` and ``extensionfill`` # Create new figure instance @@ -215,6 +219,7 @@ # %% # Highlight nodal planes # ---------------------- +# # parameter ``nodal`` # Use stacking concept of GMT - plot on top of each other @@ -279,6 +284,7 @@ # %% # Offset from event location # -------------------------- +# # Prameters ``plot_longitude`` and ``plot_latitude`` as well as ``offset`` # Create new figure instance @@ -338,6 +344,7 @@ # %% # Plot several beachballs # ----------------------- +# # TODO # Set up list of four earthquakes: @@ -383,6 +390,7 @@ # %% # Size-coding and color-coding # ---------------------------- +# # e.g., by magnitude or hypocentral depth # Set up colormap and use parameter ``cmap`` @@ -422,6 +430,7 @@ # %% # Add label # --------- +# # ``event_name`` as parameter or as column # ``labelbox`` # e.g., event date or time From 2293b38b96b58752049ab291b11066074001d7d3 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 7 Sep 2023 12:50:37 +0200 Subject: [PATCH 019/105] Use correct order of regarding sphinx thumbnail --- examples/tutorials/advanced/focal_mechanisms.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 9502a705985..877de5a9362 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -46,10 +46,10 @@ - Add label """ -# sphinx_gallery_thumbnail_number = 7 - - +# %% # Import the required packages + +# sphinx_gallery_thumbnail_number = 7 import pygmt # %% From 735b314b7a2afc628471f4db2cf2dec82493d21a Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 7 Sep 2023 12:51:34 +0200 Subject: [PATCH 020/105] Fix typos Co-authored-by: Michael Grund <23025878+michaelgrund@users.noreply.github.com> --- examples/tutorials/advanced/focal_mechanisms.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 877de5a9362..44e79e9ee5b 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -14,7 +14,7 @@ - pandas DataFrame Different conventions are supported: -TODO - input file and arrary, this only is for dictionary and DataFrame +TODO - input file and array, this only is for dictionary and DataFrame - ``"aki"`` - Aki & Richards: *strike*, *dip*, *rake*, *magnitude* @@ -29,7 +29,7 @@ *t_value*, *t_azimuth*, *t_plunge*, *n_value*, *n_azimuth*, *n_plunge*, *p_value*, *p_azimuth*, *p_plunge*, *exponent* -The general structur for the input data is: +The general structure for the input data is: - xxx @@ -285,7 +285,7 @@ # Offset from event location # -------------------------- # -# Prameters ``plot_longitude`` and ``plot_latitude`` as well as ``offset`` +# Parameters ``plot_longitude`` and ``plot_latitude`` as well as ``offset`` # Create new figure instance fig = pygmt.Figure() @@ -422,7 +422,7 @@ ) # Add colorbar -fig.colorbar(frame=["x+lhpyocentral depth", "y+lkm"]) +fig.colorbar(frame=["x+lhypocentral depth", "y+lkm"]) fig.show() From a78746782660584e51da1a93e0a4b18c3218382f Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 9 Sep 2023 15:12:25 +0200 Subject: [PATCH 021/105] Move 'sphinx_gallery_thumbnail_number' comand line to end of script --- examples/tutorials/advanced/focal_mechanisms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 44e79e9ee5b..a181fe46f5f 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -48,8 +48,6 @@ # %% # Import the required packages - -# sphinx_gallery_thumbnail_number = 7 import pygmt # %% @@ -460,3 +458,5 @@ ) fig.show() + +# sphinx_gallery_thumbnail_number = 7 From eff5567275eb7da69b4ce2f75fc960d3de8d5382 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 23 Nov 2023 07:46:28 +0100 Subject: [PATCH 022/105] Shorten code and docs --- .../tutorials/advanced/focal_mechanisms.py | 184 ++++-------------- 1 file changed, 40 insertions(+), 144 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index a181fe46f5f..f4c21cf4299 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -4,7 +4,10 @@ Focal mechanisms can be plotted with the :meth:`pygmt.Figure.meca` method. -TODO: Check GMT issue #7777 and PR #7778 +TODO: Check GMT +- issue #7777 and PR #7778 +- issue #8053 +- PR #8059 -> T pen Beside an external file containing the input data, PyGMT allows for different input types: @@ -59,12 +62,12 @@ # Store focal mechanism parameters # in a 1-D array fm_sinlge = "xxx" -# in pandas DataFrame +# in a pandas DataFrame fm_single = "xxx" # in a dictionary based on the Aki & Richards convention fm_single = dict(strike=166, dip=80, rake=74, magnitude=5.8) -# Define study area: lon_min, lon_max, lat_min, lat_max +# Define the study area: lon_min, lon_max, lat_min, lat_max # in degrees East or North study_area = [-84, -76, -4, 4] @@ -76,26 +79,17 @@ # Required parameters are ``spec``, ``scale``, ``longitude`` and ``latitude`` # (event location) +# Create a new Figure instance fig = pygmt.Figure() -# Create basic map of study area -fig.coast( - region=study_area, - projection="M10c", - land="lightgray", - water="lightblue", - shorelines="1/0.5p,darkgray", - borders="1/0.5p,darkred", - frame=True, -) +fig.coast(region=study_area, projection="M10c", land="tan", water="steelblue", frame=True) -# Pass the focal mechanism data through the spec parameter -# additionally scale and event location are required +# Plot a single focal mechanism as beachball fig.meca( spec=fm_single, scale="1c", # in centimeters - longitude=-79.611, - latitude=0.904, + longitude=-79.611, # event longitude + latitude=0.904, # event latitude ) fig.show() @@ -107,50 +101,33 @@ # # parameters ``pen`` and ``outline`` -# Create new figure instance +# Create a new Figure instance fig = pygmt.Figure() -# Create basic map of study area -fig.coast( - region=study_area, - projection="M10c", # Mercator projection with width 10 centimeters - land="lightgray", - water="lightblue", - shorelines="1/0.5p,darkgray", - borders="1/0.5p,darkred", - frame=["af", "WSne"], -) +fig.coast(region=study_area, projection="M10c", land="tan", water="steelblue", frame=["af", "WSne"]) # Plot focal mechanism fig.meca( spec=fm_single, - scale="1c", # in centimeters - longitude=-79.611, # event longitude - latitude=0.904, # event latitude - pen="1p,blue,solid", + scale="1c", + longitude=-79.611, + latitude=0.904, + # Use a 1.5-point thick, blue and solid outline + pen="1.5p,magenta,solid", ) # Shift plot origin 11 centimeters to the right fig.shift_origin(xshift="11c") -# Create basic map of study area -fig.coast( - region=study_area, - projection="M10c", - land="lightgray", - water="lightblue", - shorelines="1/0.5p,darkgray", - borders="1/0.5p,darkred", - frame=["af", "wSnE"], -) +fig.coast(region=study_area, projection="M10c", land="tan", water="steelblue", frame=["af", "wSnE"]) # Plot focal mechanism fig.meca( spec=fm_single, - scale="1c", # in centimeters + scale="1c", longitude=-79.611, latitude=0.904, - outline="1p,red,solid", + outline="1.5p,red,solid", ) fig.show() @@ -162,19 +139,10 @@ # # parameters ``compressionfill`` and ``extensionfill`` -# Create new figure instance +# Create a new Figure instance fig = pygmt.Figure() -# Create basic map of study area -fig.coast( - region=study_area, - projection="M10c", - land="lightgray", - water="lightblue", - shorelines="1/0.5p,darkgray", - borders="1/0.5p,darkred", - frame=["af", "WSne"], -) +fig.coast(region=study_area, projection="M10c", land="tan", water="steelblue", frame=["af", "WSne"]) # Plot focal mechanism fig.meca( @@ -182,23 +150,14 @@ scale="1c", # in centimeters longitude=-79.611, latitude=0.904, - compressionfill="lightred", - extensionfill="cornsilk", + compressionfill="darkred", + extensionfill="gold", ) # Shift plot origin 11 centimeters to the right fig.shift_origin(xshift="11c") -# Create basic map of study area -fig.coast( - region=study_area, - projection="M10c", - land="lightgray", - water="lightblue", - shorelines="1/0.5p,darkgray", - borders="1/0.5p,darkred", - frame=["af", "wSnE"], -) +fig.coast(region=study_area, projection="M10c", land="tan", water="steelblue", frame=["af", "wSnE"]) # Plot focal mechanism fig.meca( @@ -221,19 +180,10 @@ # parameter ``nodal`` # Use stacking concept of GMT - plot on top of each other -# Create new figure instance +# Create a new Figure instance fig = pygmt.Figure() -# Create basic map of study area -fig.coast( - region=study_area, - projection="M10c", - land="lightgray", - water="lightblue", - shorelines="1/0.5p,darkgray", - borders="1/0.5p,darkred", - frame=["af", "WSne"], -) +fig.coast(region=study_area, projection="M10c", land="tan", water="steelblue", frame=["af", "WSne"]) # Plot focal mechanism fig.meca( @@ -247,16 +197,7 @@ # Shift plot origin 11 centimeters to the right fig.shift_origin(xshift="11c") -# Create basic map of study area -fig.coast( - region=study_area, - projection="M10c", - land="lightgray", - water="lightblue", - shorelines="1/0.5p,darkgray", - borders="1/0.5p,darkred", - frame=["af", "wSnE"], -) +fig.coast(region=study_area, projection="M10c", land="tan", water="steelblue", frame=["af", "wSnE"]) # Plot focal mechanism fig.meca( @@ -285,19 +226,10 @@ # # Parameters ``plot_longitude`` and ``plot_latitude`` as well as ``offset`` -# Create new figure instance +# Create a new Figure instance fig = pygmt.Figure() -# Create basic map of study area -fig.coast( - region=study_area, - projection="M10c", - land="lightgray", - water="lightblue", - shorelines="1/0.5p,darkgray", - borders="1/0.5p,darkred", - frame=["af", "WSne"], -) +fig.coast(region=study_area, projection="M10c", land="tan", water="steelblue", frame=["af", "WSne"]) # Plot focal mechanism fig.meca( @@ -313,16 +245,7 @@ # Shift plot origin 11 centimeters to the right fig.shift_origin(xshift="11c") -# Create basic map of study area -fig.coast( - region=study_area, - projection="M10c", - land="lightgray", - water="lightblue", - shorelines="1/0.5p,darkgray", - borders="1/0.5p,darkred", - frame=["af", "wSnE"], -) +fig.coast(region=study_area, projection="M10c", land="tan", water="steelblue", frame=["af", "wSnE"]) # Plot focal mechanism fig.meca( @@ -363,18 +286,10 @@ # fixed size via ``scale`` append **+m** -# Create new figure instance +# Create a new Figure instance fig = pygmt.Figure() -# Create basic map of study area -fig.coast( - region="d", - projection="N10c", - land="lightgray", - water="lightblue", - shorelines="1/0.1p,darkgray", - frame=["af", "WSnE"], -) +fig.coast(region="d", projection="N10c",land="tan", water="steelblue", frame=["af", "WSnE"]) # Plot focal mechanism fig.meca( @@ -392,24 +307,13 @@ # e.g., by magnitude or hypocentral depth # Set up colormap and use parameter ``cmap`` -# Create new figure instance +# Create a new Figure instance fig = pygmt.Figure() -# Create basic map of study area -fig.coast( - region="d", - projection="N10c", - land="lightgray", - water="lightblue", - shorelines="1/0.1p,darkgray", - frame=["af", "WsNE"], -) +fig.coast(region="d", projection="N10c", land="tan", water="steelblue", frame=["af", "WsNE"]) # Set up colormap for hypocentral depth -pygmt.makecpt( - cmap="lajolla", - series=[0, 30, 1], -) +pygmt.makecpt(cmap="lajolla", series=[0, 30, 1]) # Plot focal mechanism fig.meca( @@ -435,23 +339,15 @@ # # change font size of trailing text ``scale`` **+f** -# Create new figure instance +# Create a new Figure instance fig = pygmt.Figure() -# Create basic map of study area -fig.coast( - region="d", - projection="N10c", - land="lightgray", - water="lightblue", - shorelines="1/0.1p,darkgray", - frame=["af", "WSnE"], -) +fig.coast(region="d", projection="N10c", land="tan", water="steelblue", frame=["af", "WSnE"]) # Plot focal mechanism fig.meca( spec=fm_collection, - scale="0.3c+m+f5p", # in centimeters + scale="0.3c+m+f5p", # TODO double check dates event_name=["2010/01/12", "2022/03/27", "2022/06/21", "2023/02/06"], labelbox="white@30", From 39f055eafa088145eb212b650eea90ed416bf4eb Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 23 Nov 2023 08:15:15 +0100 Subject: [PATCH 023/105] Change study area --- .../tutorials/advanced/focal_mechanisms.py | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index f4c21cf4299..3c1b44c8129 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -65,11 +65,11 @@ # in a pandas DataFrame fm_single = "xxx" # in a dictionary based on the Aki & Richards convention -fm_single = dict(strike=166, dip=80, rake=74, magnitude=5.8) +fm_single = dict(strike=318, dip=89, rake=-179, magnitude=7.75) # Define the study area: lon_min, lon_max, lat_min, lat_max # in degrees East or North -study_area = [-84, -76, -4, 4] +study_area = [30, 40, 30, 40] # %% @@ -88,8 +88,8 @@ fig.meca( spec=fm_single, scale="1c", # in centimeters - longitude=-79.611, # event longitude - latitude=0.904, # event latitude + longitude=37.042, # event longitude + latitude=37.166, # event latitude ) fig.show() @@ -110,10 +110,10 @@ fig.meca( spec=fm_single, scale="1c", - longitude=-79.611, - latitude=0.904, - # Use a 1.5-point thick, blue and solid outline - pen="1.5p,magenta,solid", + longitude=37.042, + latitude=37.166, + # Use a 1.5-point thick, green and solid outline + pen="1.5p,green,solid", ) # Shift plot origin 11 centimeters to the right @@ -125,9 +125,9 @@ fig.meca( spec=fm_single, scale="1c", - longitude=-79.611, - latitude=0.904, - outline="1.5p,red,solid", + longitude=37.042, + latitude=37.166, + outline="1.5p,green,solid", ) fig.show() @@ -148,8 +148,8 @@ fig.meca( spec=fm_single, scale="1c", # in centimeters - longitude=-79.611, - latitude=0.904, + longitude=37.042, + latitude=37.166, compressionfill="darkred", extensionfill="gold", ) @@ -163,8 +163,8 @@ fig.meca( spec=fm_single, scale="1c", - longitude=-79.611, - latitude=0.904, + longitude=37.042, + latitude=37.166, compressionfill="p8", extensionfill="p31", outline=True, @@ -189,8 +189,8 @@ fig.meca( spec=fm_single, scale="1c", # in centimeters - longitude=-79.611, - latitude=0.904, + longitude=37.042, + latitude=37.166, nodal="0/1p,black,solid", ) @@ -203,8 +203,8 @@ fig.meca( spec=fm_single, scale="1c", - longitude=-79.611, - latitude=0.904, + longitude=37.042, + latitude=37.166, compressionfill="darkgray", outline="1p,red,solid", ) @@ -212,8 +212,8 @@ fig.meca( spec=fm_single, scale="1c", - longitude=-79.611, - latitude=0.904, + longitude=37.042, + latitude=37.166, nodal="1/1p,black,solid", ) @@ -235,10 +235,10 @@ fig.meca( spec=fm_single, scale="1c", # in centimeters - longitude=-79.611, - latitude=0.904, - plot_longitude=-78, - plot_latitude=0, + longitude=37.042, + latitude=37.166, + plot_longitude=35, + plot_latitude=38, offset=True, ) @@ -251,10 +251,10 @@ fig.meca( spec=fm_single, scale="1c", - longitude=-79.611, - latitude=0.904, - plot_longitude=-78, - plot_latitude=0, + longitude=37.042, + latitude=37.166, + plot_longitude=35, + plot_latitude=38, offset="+p1p,red+s0.25c", compressionfill="lightred", ) From b41fde29325677d70a437e317a0979a6937d38bd Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 23 Nov 2023 08:18:44 +0100 Subject: [PATCH 024/105] Replace tab by four spaces --- examples/tutorials/advanced/focal_mechanisms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 3c1b44c8129..66cfe0c64fc 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -112,7 +112,7 @@ scale="1c", longitude=37.042, latitude=37.166, - # Use a 1.5-point thick, green and solid outline + # Use a 1.5-point thick, green and solid outline pen="1.5p,green,solid", ) From 1d9f05a98388d8c84f40a100f1a22ed5355b85bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Thu, 23 Nov 2023 08:21:56 +0100 Subject: [PATCH 025/105] Consider maximum line length --- .../tutorials/advanced/focal_mechanisms.py | 80 ++++++++++++++++--- 1 file changed, 68 insertions(+), 12 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 66cfe0c64fc..2aaaddf6402 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -82,7 +82,9 @@ # Create a new Figure instance fig = pygmt.Figure() -fig.coast(region=study_area, projection="M10c", land="tan", water="steelblue", frame=True) +fig.coast( + region=study_area, projection="M10c", land="tan", water="steelblue", frame=True +) # Plot a single focal mechanism as beachball fig.meca( @@ -104,7 +106,13 @@ # Create a new Figure instance fig = pygmt.Figure() -fig.coast(region=study_area, projection="M10c", land="tan", water="steelblue", frame=["af", "WSne"]) +fig.coast( + region=study_area, + projection="M10c", + land="tan", + water="steelblue", + frame=["af", "WSne"], +) # Plot focal mechanism fig.meca( @@ -119,7 +127,13 @@ # Shift plot origin 11 centimeters to the right fig.shift_origin(xshift="11c") -fig.coast(region=study_area, projection="M10c", land="tan", water="steelblue", frame=["af", "wSnE"]) +fig.coast( + region=study_area, + projection="M10c", + land="tan", + water="steelblue", + frame=["af", "wSnE"], +) # Plot focal mechanism fig.meca( @@ -142,7 +156,13 @@ # Create a new Figure instance fig = pygmt.Figure() -fig.coast(region=study_area, projection="M10c", land="tan", water="steelblue", frame=["af", "WSne"]) +fig.coast( + region=study_area, + projection="M10c", + land="tan", + water="steelblue", + frame=["af", "WSne"], +) # Plot focal mechanism fig.meca( @@ -157,7 +177,13 @@ # Shift plot origin 11 centimeters to the right fig.shift_origin(xshift="11c") -fig.coast(region=study_area, projection="M10c", land="tan", water="steelblue", frame=["af", "wSnE"]) +fig.coast( + region=study_area, + projection="M10c", + land="tan", + water="steelblue", + frame=["af", "wSnE"], +) # Plot focal mechanism fig.meca( @@ -183,7 +209,13 @@ # Create a new Figure instance fig = pygmt.Figure() -fig.coast(region=study_area, projection="M10c", land="tan", water="steelblue", frame=["af", "WSne"]) +fig.coast( + region=study_area, + projection="M10c", + land="tan", + water="steelblue", + frame=["af", "WSne"], +) # Plot focal mechanism fig.meca( @@ -197,7 +229,13 @@ # Shift plot origin 11 centimeters to the right fig.shift_origin(xshift="11c") -fig.coast(region=study_area, projection="M10c", land="tan", water="steelblue", frame=["af", "wSnE"]) +fig.coast( + region=study_area, + projection="M10c", + land="tan", + water="steelblue", + frame=["af", "wSnE"], +) # Plot focal mechanism fig.meca( @@ -229,7 +267,13 @@ # Create a new Figure instance fig = pygmt.Figure() -fig.coast(region=study_area, projection="M10c", land="tan", water="steelblue", frame=["af", "WSne"]) +fig.coast( + region=study_area, + projection="M10c", + land="tan", + water="steelblue", + frame=["af", "WSne"], +) # Plot focal mechanism fig.meca( @@ -245,7 +289,13 @@ # Shift plot origin 11 centimeters to the right fig.shift_origin(xshift="11c") -fig.coast(region=study_area, projection="M10c", land="tan", water="steelblue", frame=["af", "wSnE"]) +fig.coast( + region=study_area, + projection="M10c", + land="tan", + water="steelblue", + frame=["af", "wSnE"], +) # Plot focal mechanism fig.meca( @@ -289,7 +339,9 @@ # Create a new Figure instance fig = pygmt.Figure() -fig.coast(region="d", projection="N10c",land="tan", water="steelblue", frame=["af", "WSnE"]) +fig.coast( + region="d", projection="N10c", land="tan", water="steelblue", frame=["af", "WSnE"] +) # Plot focal mechanism fig.meca( @@ -310,7 +362,9 @@ # Create a new Figure instance fig = pygmt.Figure() -fig.coast(region="d", projection="N10c", land="tan", water="steelblue", frame=["af", "WsNE"]) +fig.coast( + region="d", projection="N10c", land="tan", water="steelblue", frame=["af", "WsNE"] +) # Set up colormap for hypocentral depth pygmt.makecpt(cmap="lajolla", series=[0, 30, 1]) @@ -342,7 +396,9 @@ # Create a new Figure instance fig = pygmt.Figure() -fig.coast(region="d", projection="N10c", land="tan", water="steelblue", frame=["af", "WSnE"]) +fig.coast( + region="d", projection="N10c", land="tan", water="steelblue", frame=["af", "WSnE"] +) # Plot focal mechanism fig.meca( From be8be06848dbd73b7ac93b05b83a46ba3dc89508 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 16 Dec 2023 20:51:43 +0100 Subject: [PATCH 026/105] Follow ruff's C4 rules --- .../tutorials/advanced/focal_mechanisms.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 2aaaddf6402..bd194d2521e 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -65,7 +65,7 @@ # in a pandas DataFrame fm_single = "xxx" # in a dictionary based on the Aki & Richards convention -fm_single = dict(strike=318, dip=89, rake=-179, magnitude=7.75) +fm_single = {"strike": 318, "dip": 89, "rake": -179, "magnitude": 7.75} # Define the study area: lon_min, lon_max, lat_min, lat_max # in degrees East or North @@ -324,15 +324,15 @@ # - Afghanistan on 2022/06/21 # - Syria / Turkey on 2023/02/06 -fm_collection = dict( - strike=[166, 166, 166, 166], - dip=[80, 80, 80, 80], - rake=[74, 74, 74, 74], - magnitude=[7.0, 5.8, 6.0, 7.8], - longitude=[-72.53, -79.611, 69.46, 37.032], - latitude=[18.46, 0.904, 33.02, 37.166], - depth=[13, 26.52, 4, 10], -) +fm_collection = { + "strike": [166, 166, 166, 166], + "dip": [80, 80, 80, 80], + "rake": [74, 74, 74, 74], + "magnitude": [7.0, 5.8, 6.0, 7.8], + "longitude": [-72.53, -79.611, 69.46, 37.032], + "latitude": [18.46, 0.904, 33.02, 37.166], + "depth": [13, 26.52, 4, 10], +} # fixed size via ``scale`` append **+m** From 46071890e7bfbeb4286e04e60d094eb86a6fdac9 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 16 Dec 2023 22:30:45 +0100 Subject: [PATCH 027/105] Adjust colors to shorten script length --- .../tutorials/advanced/focal_mechanisms.py | 70 +++++-------------- 1 file changed, 16 insertions(+), 54 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index bd194d2521e..9ddeb7a51d3 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -83,7 +83,7 @@ fig = pygmt.Figure() fig.coast( - region=study_area, projection="M10c", land="tan", water="steelblue", frame=True + region=study_area, projection="M10c", land="lightgray", frame=True ) # Plot a single focal mechanism as beachball @@ -107,11 +107,7 @@ fig = pygmt.Figure() fig.coast( - region=study_area, - projection="M10c", - land="tan", - water="steelblue", - frame=["af", "WSne"], + region=study_area, projection="M10c", land="lightgray", frame=["af", "WSne"] ) # Plot focal mechanism @@ -120,19 +116,15 @@ scale="1c", longitude=37.042, latitude=37.166, - # Use a 1.5-point thick, green and solid outline - pen="1.5p,green,solid", + # Use a 1.5-point thick, red and solid outline + pen="1.5p,red,solid", ) # Shift plot origin 11 centimeters to the right fig.shift_origin(xshift="11c") fig.coast( - region=study_area, - projection="M10c", - land="tan", - water="steelblue", - frame=["af", "wSnE"], + region=study_area, projection="M10c", land="lightgray", frame=["af", "wSnE"] ) # Plot focal mechanism @@ -141,7 +133,7 @@ scale="1c", longitude=37.042, latitude=37.166, - outline="1.5p,green,solid", + outline="1.5p,red,solid", ) fig.show() @@ -157,11 +149,7 @@ fig = pygmt.Figure() fig.coast( - region=study_area, - projection="M10c", - land="tan", - water="steelblue", - frame=["af", "WSne"], + region=study_area, projection="M10c", land="lightgray", frame=["af", "WSne"] ) # Plot focal mechanism @@ -178,11 +166,7 @@ fig.shift_origin(xshift="11c") fig.coast( - region=study_area, - projection="M10c", - land="tan", - water="steelblue", - frame=["af", "wSnE"], + region=study_area, projection="M10c", land="lightgray", frame=["af", "wSnE"] ) # Plot focal mechanism @@ -210,11 +194,7 @@ fig = pygmt.Figure() fig.coast( - region=study_area, - projection="M10c", - land="tan", - water="steelblue", - frame=["af", "WSne"], + region=study_area, projection="M10c", land="lightgray", frame=["af", "WSne"] ) # Plot focal mechanism @@ -230,11 +210,7 @@ fig.shift_origin(xshift="11c") fig.coast( - region=study_area, - projection="M10c", - land="tan", - water="steelblue", - frame=["af", "wSnE"], + region=study_area, projection="M10c", land="lightgray", frame=["af", "wSnE"] ) # Plot focal mechanism @@ -243,7 +219,7 @@ scale="1c", longitude=37.042, latitude=37.166, - compressionfill="darkgray", + compressionfill="lightred", outline="1p,red,solid", ) @@ -268,11 +244,7 @@ fig = pygmt.Figure() fig.coast( - region=study_area, - projection="M10c", - land="tan", - water="steelblue", - frame=["af", "WSne"], + region=study_area, projection="M10c", land="lightgray", frame=["af", "WSne"] ) # Plot focal mechanism @@ -290,11 +262,7 @@ fig.shift_origin(xshift="11c") fig.coast( - region=study_area, - projection="M10c", - land="tan", - water="steelblue", - frame=["af", "wSnE"], + region=study_area, projection="M10c", land="lightgray", frame=["af", "wSnE"] ) # Plot focal mechanism @@ -339,9 +307,7 @@ # Create a new Figure instance fig = pygmt.Figure() -fig.coast( - region="d", projection="N10c", land="tan", water="steelblue", frame=["af", "WSnE"] -) +fig.coast(region="d", projection="N10c", land="lightgray", frame=True) # Plot focal mechanism fig.meca( @@ -362,9 +328,7 @@ # Create a new Figure instance fig = pygmt.Figure() -fig.coast( - region="d", projection="N10c", land="tan", water="steelblue", frame=["af", "WsNE"] -) +fig.coast(region="d", projection="N10c", land="lightgray", frame=True) # Set up colormap for hypocentral depth pygmt.makecpt(cmap="lajolla", series=[0, 30, 1]) @@ -396,9 +360,7 @@ # Create a new Figure instance fig = pygmt.Figure() -fig.coast( - region="d", projection="N10c", land="tan", water="steelblue", frame=["af", "WSnE"] -) +fig.coast(region="d", projection="N10c", land="lightgray", frame=True) # Plot focal mechanism fig.meca( From e4bf3a75ec142f467a19dd58436aee62356fb57d Mon Sep 17 00:00:00 2001 From: actions-bot <58130806+actions-bot@users.noreply.github.com> Date: Sat, 16 Dec 2023 21:52:58 +0000 Subject: [PATCH 028/105] [format-command] fixes --- .../tutorials/advanced/focal_mechanisms.py | 36 +++++-------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 9ddeb7a51d3..07f48075b93 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -82,9 +82,7 @@ # Create a new Figure instance fig = pygmt.Figure() -fig.coast( - region=study_area, projection="M10c", land="lightgray", frame=True -) +fig.coast(region=study_area, projection="M10c", land="lightgray", frame=True) # Plot a single focal mechanism as beachball fig.meca( @@ -106,9 +104,7 @@ # Create a new Figure instance fig = pygmt.Figure() -fig.coast( - region=study_area, projection="M10c", land="lightgray", frame=["af", "WSne"] -) +fig.coast(region=study_area, projection="M10c", land="lightgray", frame=["af", "WSne"]) # Plot focal mechanism fig.meca( @@ -123,9 +119,7 @@ # Shift plot origin 11 centimeters to the right fig.shift_origin(xshift="11c") -fig.coast( - region=study_area, projection="M10c", land="lightgray", frame=["af", "wSnE"] -) +fig.coast(region=study_area, projection="M10c", land="lightgray", frame=["af", "wSnE"]) # Plot focal mechanism fig.meca( @@ -148,9 +142,7 @@ # Create a new Figure instance fig = pygmt.Figure() -fig.coast( - region=study_area, projection="M10c", land="lightgray", frame=["af", "WSne"] -) +fig.coast(region=study_area, projection="M10c", land="lightgray", frame=["af", "WSne"]) # Plot focal mechanism fig.meca( @@ -165,9 +157,7 @@ # Shift plot origin 11 centimeters to the right fig.shift_origin(xshift="11c") -fig.coast( - region=study_area, projection="M10c", land="lightgray", frame=["af", "wSnE"] -) +fig.coast(region=study_area, projection="M10c", land="lightgray", frame=["af", "wSnE"]) # Plot focal mechanism fig.meca( @@ -193,9 +183,7 @@ # Create a new Figure instance fig = pygmt.Figure() -fig.coast( - region=study_area, projection="M10c", land="lightgray", frame=["af", "WSne"] -) +fig.coast(region=study_area, projection="M10c", land="lightgray", frame=["af", "WSne"]) # Plot focal mechanism fig.meca( @@ -209,9 +197,7 @@ # Shift plot origin 11 centimeters to the right fig.shift_origin(xshift="11c") -fig.coast( - region=study_area, projection="M10c", land="lightgray", frame=["af", "wSnE"] -) +fig.coast(region=study_area, projection="M10c", land="lightgray", frame=["af", "wSnE"]) # Plot focal mechanism fig.meca( @@ -243,9 +229,7 @@ # Create a new Figure instance fig = pygmt.Figure() -fig.coast( - region=study_area, projection="M10c", land="lightgray", frame=["af", "WSne"] -) +fig.coast(region=study_area, projection="M10c", land="lightgray", frame=["af", "WSne"]) # Plot focal mechanism fig.meca( @@ -261,9 +245,7 @@ # Shift plot origin 11 centimeters to the right fig.shift_origin(xshift="11c") -fig.coast( - region=study_area, projection="M10c", land="lightgray", frame=["af", "wSnE"] -) +fig.coast(region=study_area, projection="M10c", land="lightgray", frame=["af", "wSnE"]) # Plot focal mechanism fig.meca( From 6d870fca340042222dad3da6387776b22aeda463 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 11 Apr 2024 20:13:42 +0200 Subject: [PATCH 029/105] Improve documetation --- .../tutorials/advanced/focal_mechanisms.py | 36 +++++++++---------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 07f48075b93..4b5af642dfa 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -5,6 +5,7 @@ Focal mechanisms can be plotted with the :meth:`pygmt.Figure.meca` method. TODO: Check GMT + - issue #7777 and PR #7778 - issue #8053 - PR #8059 -> T pen @@ -12,9 +13,9 @@ Beside an external file containing the input data, PyGMT allows for different input types: -- 1-D (single event) and 2-D array (multiple events) -- dictionary -- pandas DataFrame +- a 1-D (single event) and 2-D array (multiple events) +- a dictionary +- a pandas DataFrame Different conventions are supported: TODO - input file and array, this only is for dictionary and DataFrame @@ -41,12 +42,12 @@ This tutorial shows how to adjust the display of the beachballs: -- Adjust outline +- Adjust the outline - Fill quadrants with colors and patterns -- Highlight nodal plane +- Highlight the nodal planes - Offset from event location - Size-coding and color-coding -- Add label +- Add a label """ # %% @@ -96,7 +97,7 @@ # %% -# Adjust outline +# Adjust the outline # -------------- # # parameters ``pen`` and ``outline`` @@ -116,8 +117,8 @@ pen="1.5p,red,solid", ) -# Shift plot origin 11 centimeters to the right -fig.shift_origin(xshift="11c") +# Shift plot origin by the width of the last plot plus 1 centimeter to the right +fig.shift_origin(xshift="+w+1c") fig.coast(region=study_area, projection="M10c", land="lightgray", frame=["af", "wSnE"]) @@ -154,8 +155,7 @@ extensionfill="gold", ) -# Shift plot origin 11 centimeters to the right -fig.shift_origin(xshift="11c") +fig.shift_origin(xshift="+w+1c") fig.coast(region=study_area, projection="M10c", land="lightgray", frame=["af", "wSnE"]) @@ -174,8 +174,8 @@ # %% -# Highlight nodal planes -# ---------------------- +# Highlight the nodal planes +# -------------------------- # # parameter ``nodal`` # Use stacking concept of GMT - plot on top of each other @@ -194,8 +194,7 @@ nodal="0/1p,black,solid", ) -# Shift plot origin 11 centimeters to the right -fig.shift_origin(xshift="11c") +fig.shift_origin(xshift="+w+1c") fig.coast(region=study_area, projection="M10c", land="lightgray", frame=["af", "wSnE"]) @@ -242,8 +241,7 @@ offset=True, ) -# Shift plot origin 11 centimeters to the right -fig.shift_origin(xshift="11c") +fig.shift_origin(xshift="+w+1c") fig.coast(region=study_area, projection="M10c", land="lightgray", frame=["af", "wSnE"]) @@ -330,8 +328,8 @@ # %% -# Add label -# --------- +# Add a label +# ----------- # # ``event_name`` as parameter or as column # ``labelbox`` From 649bf8329dd0b8a914aacfddad96f5527c09343c Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 18 Apr 2024 23:30:24 +0200 Subject: [PATCH 030/105] Fix length of underline --- examples/tutorials/advanced/focal_mechanisms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 4b5af642dfa..834683d5879 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -98,7 +98,7 @@ # %% # Adjust the outline -# -------------- +# ------------------ # # parameters ``pen`` and ``outline`` From 7f8daa3dc0b9885bcaf9330acaa03d4607237b56 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 13 Oct 2024 19:18:59 +0200 Subject: [PATCH 031/105] General update of code --- .../tutorials/advanced/focal_mechanisms.py | 263 ++++++------------ 1 file changed, 91 insertions(+), 172 deletions(-) mode change 100644 => 100755 examples/tutorials/advanced/focal_mechanisms.py diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py old mode 100644 new mode 100755 index 834683d5879..35531a62a5d --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -2,29 +2,21 @@ Plotting focal mechanisms ========================= -Focal mechanisms can be plotted with the :meth:`pygmt.Figure.meca` method. +Focal mechanisms can be plotted as beachballs with the :meth:`pygmt.Figure.meca` +method. The input data can be provided in different ways: -TODO: Check GMT - -- issue #7777 and PR #7778 -- issue #8053 -- PR #8059 -> T pen - -Beside an external file containing the input data, PyGMT allows for different -input types: - -- a 1-D (single event) and 2-D array (multiple events) +- a string containing path and name of an external file +- a 1-D (single event) or 2-D (multiple events) numpy.array` - a dictionary -- a pandas DataFrame +- a `pandas.DataFrame` -Different conventions are supported: -TODO - input file and array, this only is for dictionary and DataFrame +Different conventions to define the focal mechanism are supported. For providing +a dictionary or a `pandas.DataFrame` the listed keys or column names are required: - ``"aki"`` - Aki & Richards: *strike*, *dip*, *rake*, *magnitude* - ``"gcmt"`` - global CMT: - *strike1*, *dip1*, *rake1*, *strike2*, *dip2*, *rake2*, *mantissa*, - *exponent* + *strike1*, *dip1*, *rake1*, *strike2*, *dip2*, *rake2*, *mantissa*, *exponent* - ``"mt"`` - seismic moment tensor: *mrr*, *mtt*, *mff*, *mrt*, *mrf*, *mtf*, *exponent* - ``"partial"`` - partial focal mechanism: @@ -33,43 +25,38 @@ *t_value*, *t_azimuth*, *t_plunge*, *n_value*, *n_azimuth*, *n_plunge*, *p_value*, *p_azimuth*, *p_plunge*, *exponent* -The general structure for the input data is: - -- xxx - -Please refer also the documentation on how to set up the input data in respect -to the chosen input type and convention. +Please also refer also the documentation on how to set up the input data in +respect to the chosen input type and convention. This tutorial shows how to adjust the display of the beachballs: - Adjust the outline - Fill quadrants with colors and patterns -- Highlight the nodal planes -- Offset from event location -- Size-coding and color-coding +- Highlight nodal planes +- Add offset from event location - Add a label +- Use size-coding and color-coding """ # %% -# Import the required packages +import numpy as np import pygmt # %% # Set up input data # ----------------- # -# TODO - consistent with lists in introduction -# Store focal mechanism parameters +# Store focal mechanism parameters for one event # in a 1-D array -fm_sinlge = "xxx" +fm_array_single = np.array([318, 89, -179, 7.75]) # in a pandas DataFrame -fm_single = "xxx" +fm_df_single = "xxx" # in a dictionary based on the Aki & Richards convention -fm_single = {"strike": 318, "dip": 89, "rake": -179, "magnitude": 7.75} +fm_dict_single = {"strike": 318, "dip": 89, "rake": -179, "magnitude": 7.75} -# Define the study area: lon_min, lon_max, lat_min, lat_max -# in degrees East or North +# Define study area: lon_min, lon_max, lat_min, lat_max in degrees East or North +size = 5 study_area = [30, 40, 30, 40] @@ -78,20 +65,13 @@ # ----------------------- # # Required parameters are ``spec``, ``scale``, ``longitude`` and ``latitude`` -# (event location) +# (event location). -# Create a new Figure instance fig = pygmt.Figure() - -fig.coast(region=study_area, projection="M10c", land="lightgray", frame=True) +fig.basemap(region=[-size, size] * 2, projection="X10c", frame=["af", "+ggray80"]) # Plot a single focal mechanism as beachball -fig.meca( - spec=fm_single, - scale="1c", # in centimeters - longitude=37.042, # event longitude - latitude=37.166, # event latitude -) +fig.meca(spec=fm_dict_single, scale="1c", longitude=0, latitude=0) fig.show() @@ -100,35 +80,26 @@ # Adjust the outline # ------------------ # -# parameters ``pen`` and ``outline`` +# Use the parameters ``pen`` and ``outline`` to adjust the outline -# Create a new Figure instance fig = pygmt.Figure() +fig.basemap(region=[-size, size] * 2, projection="X10c", frame=["af", "+ggray80"]) -fig.coast(region=study_area, projection="M10c", land="lightgray", frame=["af", "WSne"]) - -# Plot focal mechanism fig.meca( - spec=fm_single, + spec=fm_dict_single, scale="1c", - longitude=37.042, - latitude=37.166, + longitude=-2, + latitude=0, # Use a 1.5-point thick, red and solid outline - pen="1.5p,red,solid", + pen="1.5p,darkorange,solid", ) -# Shift plot origin by the width of the last plot plus 1 centimeter to the right -fig.shift_origin(xshift="+w+1c") - -fig.coast(region=study_area, projection="M10c", land="lightgray", frame=["af", "wSnE"]) - -# Plot focal mechanism fig.meca( - spec=fm_single, + spec=fm_dict_single, scale="1c", - longitude=37.042, - latitude=37.166, - outline="1.5p,red,solid", + longitude=2, + latitude=0, + outline="1.5p,darkorange,solid", ) fig.show() @@ -138,33 +109,26 @@ # Fill quadrants with colors and patterns # --------------------------------------- # -# parameters ``compressionfill`` and ``extensionfill`` +# Use the parameters ``compressionfill`` and ``extensionfill`` to fill the +# quadrants with colors or patterns. -# Create a new Figure instance fig = pygmt.Figure() +fig.basemap(region=[-size, size] * 2, projection="X10c", frame=["af", "+ggray80"]) -fig.coast(region=study_area, projection="M10c", land="lightgray", frame=["af", "WSne"]) - -# Plot focal mechanism fig.meca( - spec=fm_single, - scale="1c", # in centimeters - longitude=37.042, - latitude=37.166, - compressionfill="darkred", - extensionfill="gold", + spec=fm_dict_single, + scale="1c", + longitude=-2, + latitude=0, + compressionfill="darkorange", + extensionfill="cornsilk", ) -fig.shift_origin(xshift="+w+1c") - -fig.coast(region=study_area, projection="M10c", land="lightgray", frame=["af", "wSnE"]) - -# Plot focal mechanism fig.meca( - spec=fm_single, + spec=fm_dict_single, scale="1c", - longitude=37.042, - latitude=37.166, + longitude=2, + latitude=0, compressionfill="p8", extensionfill="p31", outline=True, @@ -180,39 +144,30 @@ # parameter ``nodal`` # Use stacking concept of GMT - plot on top of each other -# Create a new Figure instance fig = pygmt.Figure() +fig.basemap(region=[-size, size] * 2, projection="X10c", frame=["af", "+ggray80"]) -fig.coast(region=study_area, projection="M10c", land="lightgray", frame=["af", "WSne"]) - -# Plot focal mechanism fig.meca( - spec=fm_single, - scale="1c", # in centimeters - longitude=37.042, - latitude=37.166, + spec=fm_dict_single, + scale="1c", + longitude=-2, + latitude=0, nodal="0/1p,black,solid", ) -fig.shift_origin(xshift="+w+1c") - -fig.coast(region=study_area, projection="M10c", land="lightgray", frame=["af", "wSnE"]) - -# Plot focal mechanism fig.meca( - spec=fm_single, + spec=fm_dict_single, scale="1c", - longitude=37.042, - latitude=37.166, - compressionfill="lightred", - outline="1p,red,solid", + longitude=2, + latitude=0, + compressionfill="lightorange", + outline="1p,darkorange,solid", ) - fig.meca( - spec=fm_single, + spec=fm_dict_single, scale="1c", - longitude=37.042, - latitude=37.166, + longitude=2, + latitude=0, nodal="1/1p,black,solid", ) @@ -225,44 +180,36 @@ # # Parameters ``plot_longitude`` and ``plot_latitude`` as well as ``offset`` -# Create a new Figure instance fig = pygmt.Figure() +fig.basemap(region=[-size, size] * 2, projection="X10c", frame=["af", "+ggray80"]) -fig.coast(region=study_area, projection="M10c", land="lightgray", frame=["af", "WSne"]) - -# Plot focal mechanism fig.meca( - spec=fm_single, - scale="1c", # in centimeters - longitude=37.042, - latitude=37.166, - plot_longitude=35, - plot_latitude=38, + spec=fm_dict_single, + scale="1c", + longitude=-1, + latitude=0, + plot_longitude=-3, + plot_latitude=1, offset=True, ) -fig.shift_origin(xshift="+w+1c") - -fig.coast(region=study_area, projection="M10c", land="lightgray", frame=["af", "wSnE"]) - -# Plot focal mechanism fig.meca( - spec=fm_single, + spec=fm_dict_single, scale="1c", - longitude=37.042, - latitude=37.166, - plot_longitude=35, - plot_latitude=38, - offset="+p1p,red+s0.25c", - compressionfill="lightred", + longitude=3, + latitude=0, + plot_longitude=1, + plot_latitude=1, + offset="+p1p,darkorange+s0.25c", + compressionfill="lightorange", ) fig.show() # %% -# Plot several beachballs -# ----------------------- +# Plot multiple beachballs +# ------------------------ # # TODO # Set up list of four earthquakes: @@ -272,7 +219,7 @@ # - Afghanistan on 2022/06/21 # - Syria / Turkey on 2023/02/06 -fm_collection = { +fm_dict_multiple = { "strike": [166, 166, 166, 166], "dip": [80, 80, 80, 80], "rake": [74, 74, 74, 74], @@ -280,20 +227,23 @@ "longitude": [-72.53, -79.611, 69.46, 37.032], "latitude": [18.46, 0.904, 33.02, 37.166], "depth": [13, 26.52, 4, 10], + "event_name": ["2010/01/12", "2022/03/27", "2022/06/21", "2023/02/06"], } -# fixed size via ``scale`` append **+m** -# Create a new Figure instance -fig = pygmt.Figure() +# %% +# Add a label +# ----------- +# Force a fixed size by appending "+m" to the argument passed to ``scale`` +# +# ``event_name`` as parameter or as column ``labelbox`` +# e.g., event date or time +# change font size of trailing text ``scale`` **+f** +fig = pygmt.Figure() fig.coast(region="d", projection="N10c", land="lightgray", frame=True) -# Plot focal mechanism -fig.meca( - spec=fm_collection, - scale="0.3c+m", # in centimeters -) +fig.meca(spec=fm_dict_multiple, scale="0.3c+m+f5p", labelbox="white@30") fig.show() @@ -305,50 +255,19 @@ # e.g., by magnitude or hypocentral depth # Set up colormap and use parameter ``cmap`` -# Create a new Figure instance fig = pygmt.Figure() - fig.coast(region="d", projection="N10c", land="lightgray", frame=True) -# Set up colormap for hypocentral depth +# Set up colormap and colorbar for hypocentral depth pygmt.makecpt(cmap="lajolla", series=[0, 30, 1]) - -# Plot focal mechanism -fig.meca( - spec=fm_collection, - scale="0.3c", - cmap=True, - outline=True, -) - -# Add colorbar fig.colorbar(frame=["x+lhypocentral depth", "y+lkm"]) -fig.show() - - -# %% -# Add a label -# ----------- -# -# ``event_name`` as parameter or as column -# ``labelbox`` -# e.g., event date or time -# -# change font size of trailing text ``scale`` **+f** - -# Create a new Figure instance -fig = pygmt.Figure() - -fig.coast(region="d", projection="N10c", land="lightgray", frame=True) - -# Plot focal mechanism fig.meca( - spec=fm_collection, - scale="0.3c+m+f5p", - # TODO double check dates - event_name=["2010/01/12", "2022/03/27", "2022/06/21", "2023/02/06"], + spec=fm_dict_multiple, + scale="0.3c+f5p", labelbox="white@30", + cmap=True, + outline=True, ) fig.show() From d018e49b67f37a1e8383994d3720bfcbab7a6a19 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 13 Oct 2024 19:19:54 +0200 Subject: [PATCH 032/105] Remove execution permission --- examples/tutorials/advanced/focal_mechanisms.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/tutorials/advanced/focal_mechanisms.py diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py old mode 100755 new mode 100644 From b033019decf10c0a66f3f225b23f134e292f787e Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 13 Oct 2024 19:54:59 +0200 Subject: [PATCH 033/105] Adjust figure size --- examples/tutorials/advanced/focal_mechanisms.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 35531a62a5d..32ebeb67a57 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -68,7 +68,7 @@ # (event location). fig = pygmt.Figure() -fig.basemap(region=[-size, size] * 2, projection="X10c", frame=["af", "+ggray80"]) +fig.basemap(region=[-size, size] * 2, projection="X10c/5c", frame=["af", "+ggray80"]) # Plot a single focal mechanism as beachball fig.meca(spec=fm_dict_single, scale="1c", longitude=0, latitude=0) @@ -113,7 +113,7 @@ # quadrants with colors or patterns. fig = pygmt.Figure() -fig.basemap(region=[-size, size] * 2, projection="X10c", frame=["af", "+ggray80"]) +fig.basemap(region=[-size, size] * 2, projection="X10c/5c", frame=["af", "+ggray80"]) fig.meca( spec=fm_dict_single, @@ -145,7 +145,7 @@ # Use stacking concept of GMT - plot on top of each other fig = pygmt.Figure() -fig.basemap(region=[-size, size] * 2, projection="X10c", frame=["af", "+ggray80"]) +fig.basemap(region=[-size, size] * 2, projection="X10c/5c", frame=["af", "+ggray80"]) fig.meca( spec=fm_dict_single, @@ -181,7 +181,7 @@ # Parameters ``plot_longitude`` and ``plot_latitude`` as well as ``offset`` fig = pygmt.Figure() -fig.basemap(region=[-size, size] * 2, projection="X10c", frame=["af", "+ggray80"]) +fig.basemap(region=[-size, size] * 2, projection="X10c/5c", frame=["af", "+ggray80"]) fig.meca( spec=fm_dict_single, From ee0c18fe2beda5e5957d4969a90f2083bea77a1c Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 13 Oct 2024 20:12:29 +0200 Subject: [PATCH 034/105] Adjust figure size --- examples/tutorials/advanced/focal_mechanisms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 examples/tutorials/advanced/focal_mechanisms.py diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py old mode 100644 new mode 100755 index 32ebeb67a57..d71e95c2e42 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -83,7 +83,7 @@ # Use the parameters ``pen`` and ``outline`` to adjust the outline fig = pygmt.Figure() -fig.basemap(region=[-size, size] * 2, projection="X10c", frame=["af", "+ggray80"]) +fig.basemap(region=[-size, size] * 2, projection="X10c/5c", frame=["af", "+ggray80"]) fig.meca( spec=fm_dict_single, From 0692453fc66905ce1faa53038c8677afdc0cc305 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 13 Oct 2024 20:36:58 +0200 Subject: [PATCH 035/105] Adjust figure size --- examples/tutorials/advanced/focal_mechanisms.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) mode change 100755 => 100644 examples/tutorials/advanced/focal_mechanisms.py diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py old mode 100755 new mode 100644 index d71e95c2e42..0472da89831 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -68,7 +68,7 @@ # (event location). fig = pygmt.Figure() -fig.basemap(region=[-size, size] * 2, projection="X10c/5c", frame=["af", "+ggray80"]) +fig.basemap(region=[-size, size] * 2, projection="X10c/4c", frame=["af", "+ggray80"]) # Plot a single focal mechanism as beachball fig.meca(spec=fm_dict_single, scale="1c", longitude=0, latitude=0) @@ -83,7 +83,7 @@ # Use the parameters ``pen`` and ``outline`` to adjust the outline fig = pygmt.Figure() -fig.basemap(region=[-size, size] * 2, projection="X10c/5c", frame=["af", "+ggray80"]) +fig.basemap(region=[-size, size] * 2, projection="X10c/4c", frame=["af", "+ggray80"]) fig.meca( spec=fm_dict_single, @@ -113,7 +113,7 @@ # quadrants with colors or patterns. fig = pygmt.Figure() -fig.basemap(region=[-size, size] * 2, projection="X10c/5c", frame=["af", "+ggray80"]) +fig.basemap(region=[-size, size] * 2, projection="X10c/4c", frame=["af", "+ggray80"]) fig.meca( spec=fm_dict_single, @@ -145,7 +145,7 @@ # Use stacking concept of GMT - plot on top of each other fig = pygmt.Figure() -fig.basemap(region=[-size, size] * 2, projection="X10c/5c", frame=["af", "+ggray80"]) +fig.basemap(region=[-size, size] * 2, projection="X10c/4c", frame=["af", "+ggray80"]) fig.meca( spec=fm_dict_single, @@ -181,7 +181,7 @@ # Parameters ``plot_longitude`` and ``plot_latitude`` as well as ``offset`` fig = pygmt.Figure() -fig.basemap(region=[-size, size] * 2, projection="X10c/5c", frame=["af", "+ggray80"]) +fig.basemap(region=[-size, size] * 2, projection="X10c/4c", frame=["af", "+ggray80"]) fig.meca( spec=fm_dict_single, @@ -189,7 +189,7 @@ longitude=-1, latitude=0, plot_longitude=-3, - plot_latitude=1, + plot_latitude=2, offset=True, ) @@ -199,7 +199,7 @@ longitude=3, latitude=0, plot_longitude=1, - plot_latitude=1, + plot_latitude=2, offset="+p1p,darkorange+s0.25c", compressionfill="lightorange", ) From 515c87b83a1ee7dd1a51f395694c76c040064ea8 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 13 Oct 2024 23:47:49 +0200 Subject: [PATCH 036/105] Fix highlighting --- examples/tutorials/advanced/focal_mechanisms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 0472da89831..6506eef3ce9 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -6,12 +6,12 @@ method. The input data can be provided in different ways: - a string containing path and name of an external file -- a 1-D (single event) or 2-D (multiple events) numpy.array` +- a 1-D (single event) or 2-D (multiple events) ``numpy.array`` - a dictionary - a `pandas.DataFrame` Different conventions to define the focal mechanism are supported. For providing -a dictionary or a `pandas.DataFrame` the listed keys or column names are required: +a dictionary or a ``pandas.DataFrame`` the listed keys or column names are required: - ``"aki"`` - Aki & Richards: *strike*, *dip*, *rake*, *magnitude* From e6e57f74a13b1da2be57c09c956cf7a3507bcf02 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 13 Oct 2024 23:59:35 +0200 Subject: [PATCH 037/105] Fix highlighting --- examples/tutorials/advanced/focal_mechanisms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 6506eef3ce9..c10723b6051 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -8,7 +8,7 @@ - a string containing path and name of an external file - a 1-D (single event) or 2-D (multiple events) ``numpy.array`` - a dictionary -- a `pandas.DataFrame` +- a ``pandas.DataFrame`` Different conventions to define the focal mechanism are supported. For providing a dictionary or a ``pandas.DataFrame`` the listed keys or column names are required: From d4a3d56bd2e0dfce05f033378ee839e54547c189 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 14 Oct 2024 11:46:55 +0200 Subject: [PATCH 038/105] Use different input formats and events --- .../tutorials/advanced/focal_mechanisms.py | 107 ++++++++++-------- 1 file changed, 61 insertions(+), 46 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index c10723b6051..14bf0c62001 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -30,8 +30,8 @@ This tutorial shows how to adjust the display of the beachballs: -- Adjust the outline - Fill quadrants with colors and patterns +- Adjust the outline - Highlight nodal planes - Add offset from event location - Add a label @@ -39,7 +39,7 @@ """ # %% -import numpy as np +import pandas as pd import pygmt # %% @@ -47,17 +47,24 @@ # ----------------- # -# Store focal mechanism parameters for one event -# in a 1-D array -fm_array_single = np.array([318, 89, -179, 7.75]) -# in a pandas DataFrame -fm_df_single = "xxx" -# in a dictionary based on the Aki & Richards convention -fm_dict_single = {"strike": 318, "dip": 89, "rake": -179, "magnitude": 7.75} +# Store focal mechanism parameters for one event in a dictionary based on the +# moment tensor convention +mt_dict_single = mt_virginia = { + "mrr": 4.71, + "mtt": 0.0381, + "mff": -4.74, + "mrt": 0.399, + "mrf": -0.805, + "mtf": -1.23, + "exponent": 24, +} +# Aki & Richards convention +aki_dict_single = {"strike": 318, "dip": 89, "rake": -179, "magnitude": 7.75} -# Define study area: lon_min, lon_max, lat_min, lat_max in degrees East or North +# Set up arguments for basemap size = 5 -study_area = [30, 40, 30, 40] +projection = "X10c/4c" +frame = ["af", "+ggray80"] # %% @@ -68,70 +75,71 @@ # (event location). fig = pygmt.Figure() -fig.basemap(region=[-size, size] * 2, projection="X10c/4c", frame=["af", "+ggray80"]) +fig.basemap(region=[-size, size] * 2, projection=projection, frame=frame) # Plot a single focal mechanism as beachball -fig.meca(spec=fm_dict_single, scale="1c", longitude=0, latitude=0) +fig.meca(spec=mt_dict_single, scale="1c", longitude=0, latitude=0) fig.show() # %% -# Adjust the outline -# ------------------ +# Fill quadrants with colors and patterns +# --------------------------------------- # -# Use the parameters ``pen`` and ``outline`` to adjust the outline +# Use the parameters ``compressionfill`` and ``extensionfill`` to fill the +# quadrants with colors or patterns. +# details on pattern gallery example and techenical reference fig = pygmt.Figure() -fig.basemap(region=[-size, size] * 2, projection="X10c/4c", frame=["af", "+ggray80"]) +fig.basemap(region=[-size, size] * 2, projection=projection, frame=frame) fig.meca( - spec=fm_dict_single, + spec=mt_dict_single, scale="1c", longitude=-2, latitude=0, - # Use a 1.5-point thick, red and solid outline - pen="1.5p,darkorange,solid", + compressionfill="darkorange", + extensionfill="cornsilk", ) fig.meca( - spec=fm_dict_single, + spec=mt_dict_single, scale="1c", longitude=2, latitude=0, - outline="1.5p,darkorange,solid", + compressionfill="p8", + extensionfill="p31", + outline=True, ) fig.show() # %% -# Fill quadrants with colors and patterns -# --------------------------------------- +# Adjust the outline +# ------------------ # -# Use the parameters ``compressionfill`` and ``extensionfill`` to fill the -# quadrants with colors or patterns. +# Use the parameters ``pen`` and ``outline`` to adjust the outline fig = pygmt.Figure() -fig.basemap(region=[-size, size] * 2, projection="X10c/4c", frame=["af", "+ggray80"]) +fig.basemap(region=[-size, size] * 2, projection=projection, frame=frame) fig.meca( - spec=fm_dict_single, + spec=mt_dict_single, scale="1c", longitude=-2, latitude=0, - compressionfill="darkorange", - extensionfill="cornsilk", + # Use a 1-point thick, darkorange and solid outline + pen="1p,darkorange,solid", ) fig.meca( - spec=fm_dict_single, + spec=mt_dict_single, scale="1c", longitude=2, latitude=0, - compressionfill="p8", - extensionfill="p31", - outline=True, + outline="1p,darkorange,solid", ) fig.show() @@ -143,12 +151,13 @@ # # parameter ``nodal`` # Use stacking concept of GMT - plot on top of each other +# behaviour somehow strange fig = pygmt.Figure() -fig.basemap(region=[-size, size] * 2, projection="X10c/4c", frame=["af", "+ggray80"]) +fig.basemap(region=[-size, size] * 2, projection=projection, frame=frame) fig.meca( - spec=fm_dict_single, + spec=aki_dict_single, scale="1c", longitude=-2, latitude=0, @@ -156,7 +165,7 @@ ) fig.meca( - spec=fm_dict_single, + spec=aki_dict_single, scale="1c", longitude=2, latitude=0, @@ -164,7 +173,7 @@ outline="1p,darkorange,solid", ) fig.meca( - spec=fm_dict_single, + spec=aki_dict_single, scale="1c", longitude=2, latitude=0, @@ -181,10 +190,10 @@ # Parameters ``plot_longitude`` and ``plot_latitude`` as well as ``offset`` fig = pygmt.Figure() -fig.basemap(region=[-size, size] * 2, projection="X10c/4c", frame=["af", "+ggray80"]) +fig.basemap(region=[-size, size] * 2, projection=projection, frame=frame) fig.meca( - spec=fm_dict_single, + spec=aki_dict_single, scale="1c", longitude=-1, latitude=0, @@ -194,7 +203,7 @@ ) fig.meca( - spec=fm_dict_single, + spec=aki_dict_single, scale="1c", longitude=3, latitude=0, @@ -219,7 +228,8 @@ # - Afghanistan on 2022/06/21 # - Syria / Turkey on 2023/02/06 -fm_dict_multiple = { +# Set up a dictionary +aki_dict_multiple = { "strike": [166, 166, 166, 166], "dip": [80, 80, 80, 80], "rake": [74, 74, 74, 74], @@ -227,8 +237,12 @@ "longitude": [-72.53, -79.611, 69.46, 37.032], "latitude": [18.46, 0.904, 33.02, 37.166], "depth": [13, 26.52, 4, 10], + "plot_longitude": [-90, -110, 70, 15], + "plot_latitude": [40, 15, 50, 60], "event_name": ["2010/01/12", "2022/03/27", "2022/06/21", "2023/02/06"], } +# Convert to a pandas.DataFrame +aki_df_multiple = pd.DataFrame(aki_dict_multiple) # %% @@ -243,7 +257,7 @@ fig = pygmt.Figure() fig.coast(region="d", projection="N10c", land="lightgray", frame=True) -fig.meca(spec=fm_dict_multiple, scale="0.3c+m+f5p", labelbox="white@30") +fig.meca(spec=aki_df_multiple, scale="0.4c+m+f5p", labelbox="white@30", offset=False) fig.show() @@ -263,11 +277,12 @@ fig.colorbar(frame=["x+lhypocentral depth", "y+lkm"]) fig.meca( - spec=fm_dict_multiple, - scale="0.3c+f5p", + spec=aki_df_multiple, + scale="0.4c+f5p", + offset="0.2p,gray30+s0.1c", labelbox="white@30", cmap=True, - outline=True, + outline="0.2p,gray30", ) fig.show() From 257077a7544178c1af6ec4346a0fed793ceabdbf Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 14 Oct 2024 11:53:44 +0200 Subject: [PATCH 039/105] Improve formulation of content list and headings --- .../tutorials/advanced/focal_mechanisms.py | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) mode change 100644 => 100755 examples/tutorials/advanced/focal_mechanisms.py diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py old mode 100644 new mode 100755 index 14bf0c62001..5e32ed18453 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -30,12 +30,12 @@ This tutorial shows how to adjust the display of the beachballs: -- Fill quadrants with colors and patterns -- Adjust the outline -- Highlight nodal planes -- Add offset from event location -- Add a label -- Use size-coding and color-coding +- Filling the quadrants +- Adjusting the outlines +- Highlighting the nodal planes +- Adding offset from the event location +- Adding a label +- Using size-coding and color-coding """ # %% @@ -68,8 +68,8 @@ # %% -# Plot a single beachball -# ----------------------- +# Ploting a single beachball +# -------------------------- # # Required parameters are ``spec``, ``scale``, ``longitude`` and ``latitude`` # (event location). @@ -84,8 +84,8 @@ # %% -# Fill quadrants with colors and patterns -# --------------------------------------- +# Filling the quadrants +# --------------------- # # Use the parameters ``compressionfill`` and ``extensionfill`` to fill the # quadrants with colors or patterns. @@ -117,8 +117,8 @@ # %% -# Adjust the outline -# ------------------ +# Adjusting the outlines +# ---------------------- # # Use the parameters ``pen`` and ``outline`` to adjust the outline @@ -146,8 +146,8 @@ # %% -# Highlight the nodal planes -# -------------------------- +# Highlighting the nodal planes +# ----------------------------- # # parameter ``nodal`` # Use stacking concept of GMT - plot on top of each other @@ -184,8 +184,8 @@ # %% -# Offset from event location -# -------------------------- +# Adding offset from event location +# --------------------------------- # # Parameters ``plot_longitude`` and ``plot_latitude`` as well as ``offset`` @@ -217,8 +217,8 @@ # %% -# Plot multiple beachballs -# ------------------------ +# Plotting multiple beachballs +# ---------------------------- # # TODO # Set up list of four earthquakes: @@ -246,8 +246,8 @@ # %% -# Add a label -# ----------- +# Adding a label +# -------------- # Force a fixed size by appending "+m" to the argument passed to ``scale`` # # ``event_name`` as parameter or as column ``labelbox`` @@ -263,8 +263,8 @@ # %% -# Size-coding and color-coding -# ---------------------------- +# Using Size-coding and color-coding +# ---------------------------------- # # e.g., by magnitude or hypocentral depth # Set up colormap and use parameter ``cmap`` From 2c32da7e3111b24862e626603bf690559e712f2d Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 14 Oct 2024 12:07:19 +0200 Subject: [PATCH 040/105] Invert colormap --- examples/tutorials/advanced/focal_mechanisms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100755 => 100644 examples/tutorials/advanced/focal_mechanisms.py diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py old mode 100755 new mode 100644 index 5e32ed18453..784da5c3b37 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -273,7 +273,7 @@ fig.coast(region="d", projection="N10c", land="lightgray", frame=True) # Set up colormap and colorbar for hypocentral depth -pygmt.makecpt(cmap="lajolla", series=[0, 30, 1]) +pygmt.makecpt(cmap="lajolla", series=[0, 30, 1], reverse=True) fig.colorbar(frame=["x+lhypocentral depth", "y+lkm"]) fig.meca( From 7b47d2d5c3c4bafc579ee722374ae7d0607e6ecb Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 14 Oct 2024 12:35:52 +0200 Subject: [PATCH 041/105] Use a continous colormap --- examples/tutorials/advanced/focal_mechanisms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 784da5c3b37..4e712dee4ca 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -273,7 +273,7 @@ fig.coast(region="d", projection="N10c", land="lightgray", frame=True) # Set up colormap and colorbar for hypocentral depth -pygmt.makecpt(cmap="lajolla", series=[0, 30, 1], reverse=True) +pygmt.makecpt(cmap="lajolla", series=[0, 30]) fig.colorbar(frame=["x+lhypocentral depth", "y+lkm"]) fig.meca( From d898e0bf3bca77d3a041660218730f074002fe18 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 14 Oct 2024 14:41:08 +0200 Subject: [PATCH 042/105] Update earthqauke data --- .../tutorials/advanced/focal_mechanisms.py | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 4e712dee4ca..5ddd06fd54b 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -220,26 +220,24 @@ # Plotting multiple beachballs # ---------------------------- # -# TODO -# Set up list of four earthquakes: - -# - Haiti on 2010/01/12 -# - Esmeraldas on 2022/03/27 -# - Afghanistan on 2022/06/21 -# - Syria / Turkey on 2023/02/06 # Set up a dictionary aki_dict_multiple = { - "strike": [166, 166, 166, 166], - "dip": [80, 80, 80, 80], - "rake": [74, 74, 74, 74], + "strike": [255, 173, 295, 318], + "dip": [70, 68, 79, 89], + "rake": [20, 83, -177, -179], "magnitude": [7.0, 5.8, 6.0, 7.8], - "longitude": [-72.53, -79.611, 69.46, 37.032], - "latitude": [18.46, 0.904, 33.02, 37.166], - "depth": [13, 26.52, 4, 10], - "plot_longitude": [-90, -110, 70, 15], - "plot_latitude": [40, 15, 50, 60], - "event_name": ["2010/01/12", "2022/03/27", "2022/06/21", "2023/02/06"], + "longitude": [-72.53, -79.61, 69.46, 37.01], + "latitude": [18.44, 0.90, 33.02, 37.23], + "depth": [13, 19, 4, 10], + "plot_longitude": [-70, -110, 100, 0], + "plot_latitude": [40, 10, 50, 55], + "event_name": [ + "Haiti - 2010/01/12", + "Esmeraldas - 2022/03/27", + "Afghanistan - 2022/06/21", + "Syria/Turkey - 2023/02/06", + ], } # Convert to a pandas.DataFrame aki_df_multiple = pd.DataFrame(aki_dict_multiple) @@ -257,7 +255,7 @@ fig = pygmt.Figure() fig.coast(region="d", projection="N10c", land="lightgray", frame=True) -fig.meca(spec=aki_df_multiple, scale="0.4c+m+f5p", labelbox="white@30", offset=False) +fig.meca(spec=aki_df_multiple, scale="0.4c+m+f5p", labelbox="white@30", offset="+s0.1c") fig.show() @@ -273,7 +271,7 @@ fig.coast(region="d", projection="N10c", land="lightgray", frame=True) # Set up colormap and colorbar for hypocentral depth -pygmt.makecpt(cmap="lajolla", series=[0, 30]) +pygmt.makecpt(cmap="lajolla", series=[0, 20]) fig.colorbar(frame=["x+lhypocentral depth", "y+lkm"]) fig.meca( From 72e5cc63afaae1e2e3bd0ea0eb42a84ac740e638 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 14 Oct 2024 17:02:24 +0200 Subject: [PATCH 043/105] Update comment | Fix typo --- examples/tutorials/advanced/focal_mechanisms.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 5ddd06fd54b..03935e02cd6 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -68,8 +68,8 @@ # %% -# Ploting a single beachball -# -------------------------- +# Plotting a single beachball +# --------------------------- # # Required parameters are ``spec``, ``scale``, ``longitude`` and ``latitude`` # (event location). @@ -219,7 +219,7 @@ # %% # Plotting multiple beachballs # ---------------------------- -# +# Data of four earthquakes taken from USGS. # Set up a dictionary aki_dict_multiple = { From 96f3240354e661222223388e24ca8593b18a55be Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 14 Oct 2024 18:10:46 +0200 Subject: [PATCH 044/105] Add comments --- .../tutorials/advanced/focal_mechanisms.py | 40 ++++++++++++------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 03935e02cd6..56b7eaa8e16 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -45,9 +45,8 @@ # %% # Set up input data # ----------------- -# - # Store focal mechanism parameters for one event in a dictionary based on the + # moment tensor convention mt_dict_single = mt_virginia = { "mrr": 4.71, @@ -72,12 +71,12 @@ # --------------------------- # # Required parameters are ``spec``, ``scale``, ``longitude`` and ``latitude`` -# (event location). +# (event location). (and ``convention`` depending on the input format, not needed +# for dictionary and ``pandas.Dataframe``.) fig = pygmt.Figure() fig.basemap(region=[-size, size] * 2, projection=projection, frame=frame) -# Plot a single focal mechanism as beachball fig.meca(spec=mt_dict_single, scale="1c", longitude=0, latitude=0) fig.show() @@ -120,7 +119,8 @@ # Adjusting the outlines # ---------------------- # -# Use the parameters ``pen`` and ``outline`` to adjust the outline +# Use the parameters ``pen`` for the outer border of the beachball and ``outline`` +# for all lines (also the borders between the nodal planes) fig = pygmt.Figure() fig.basemap(region=[-size, size] * 2, projection=projection, frame=frame) @@ -149,8 +149,10 @@ # Highlighting the nodal planes # ----------------------------- # -# parameter ``nodal`` -# Use stacking concept of GMT - plot on top of each other +# Use the parameter ``nodal`` +# whereby ``"0"`` both, ``"1"`` first, ``"2"`` second +# only lines not fill i.e. transparent +# Make use of the stacking concept of GMT and plot on top of each other # behaviour somehow strange fig = pygmt.Figure() @@ -187,7 +189,13 @@ # Adding offset from event location # --------------------------------- # -# Parameters ``plot_longitude`` and ``plot_latitude`` as well as ``offset`` +# Specify the optional parameters ``plot_longitude`` and ``plot_latitude``. +# Additional the parameter ``offset`` as to be set. Besides just drawing a line +# between the beachball and the event location, a small circle can be plotted +# at the event location by appending **+s** and the descired circle size. The +# connecting line as well as the outline of the circle are plotted with the +# setting of pen, or can be adjusted separately. The fill of the small circle +# corresponds to the fill for the compressive quadrantes. fig = pygmt.Figure() fig.basemap(region=[-size, size] * 2, projection=projection, frame=frame) @@ -219,6 +227,7 @@ # %% # Plotting multiple beachballs # ---------------------------- +# # Data of four earthquakes taken from USGS. # Set up a dictionary @@ -246,11 +255,11 @@ # %% # Adding a label # -------------- -# Force a fixed size by appending "+m" to the argument passed to ``scale`` # -# ``event_name`` as parameter or as column ``labelbox`` -# e.g., event date or time -# change font size of trailing text ``scale`` **+f** +# Use the optional parameter ``event_name`` to add a label above the beachball, +# e.g., event name or event date and time. Change the font size of trailing text +# ``scale`` **+f**. Add a box behind the label via ``labelbox``. +# Force a fixed size by appending **+m** to the argument passed to ``scale``. fig = pygmt.Figure() fig.coast(region="d", projection="N10c", land="lightgray", frame=True) @@ -261,11 +270,12 @@ # %% -# Using Size-coding and color-coding +# Using size-coding and color-coding # ---------------------------------- # -# e.g., by magnitude or hypocentral depth -# Set up colormap and use parameter ``cmap`` +# The beachball can be sized and colored by a different quantities, e.g., by +# magnitude or hypocentral depth, respectively. Use the parameter ``cmap`` to +# pass the descired colormap. fig = pygmt.Figure() fig.coast(region="d", projection="N10c", land="lightgray", frame=True) From 34fbbd54d87be6b95b322b290e40487445f4352d Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 14 Oct 2024 18:32:45 +0200 Subject: [PATCH 045/105] Add comments --- examples/tutorials/advanced/focal_mechanisms.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) mode change 100644 => 100755 examples/tutorials/advanced/focal_mechanisms.py diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py old mode 100644 new mode 100755 index 56b7eaa8e16..e8a3f5dcaf0 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -229,6 +229,7 @@ # ---------------------------- # # Data of four earthquakes taken from USGS. +# Provide lists. # Set up a dictionary aki_dict_multiple = { @@ -257,9 +258,11 @@ # -------------- # # Use the optional parameter ``event_name`` to add a label above the beachball, -# e.g., event name or event date and time. Change the font size of trailing text -# ``scale`` **+f**. Add a box behind the label via ``labelbox``. -# Force a fixed size by appending **+m** to the argument passed to ``scale``. +# e.g., event name or event date and time. Change the font size of the the label +# text by appending **+f** and the desired font size to the ``scale`` parameter. +# Add a colored box behind the label via the label ``labelbox``. +# Force a fixed size of the beachball by appending **+m** to the argument +# passed to ``scale``. fig = pygmt.Figure() fig.coast(region="d", projection="N10c", land="lightgray", frame=True) From 2347ac7eb756e45ee257ad982010118cb7e5b0d8 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 14 Oct 2024 18:48:39 +0200 Subject: [PATCH 046/105] Update introduction part --- .../tutorials/advanced/focal_mechanisms.py | 36 ++++++------------- 1 file changed, 10 insertions(+), 26 deletions(-) mode change 100755 => 100644 examples/tutorials/advanced/focal_mechanisms.py diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py old mode 100755 new mode 100644 index e8a3f5dcaf0..4038f0b6e14 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -3,32 +3,7 @@ ========================= Focal mechanisms can be plotted as beachballs with the :meth:`pygmt.Figure.meca` -method. The input data can be provided in different ways: - -- a string containing path and name of an external file -- a 1-D (single event) or 2-D (multiple events) ``numpy.array`` -- a dictionary -- a ``pandas.DataFrame`` - -Different conventions to define the focal mechanism are supported. For providing -a dictionary or a ``pandas.DataFrame`` the listed keys or column names are required: - -- ``"aki"`` - Aki & Richards: - *strike*, *dip*, *rake*, *magnitude* -- ``"gcmt"`` - global CMT: - *strike1*, *dip1*, *rake1*, *strike2*, *dip2*, *rake2*, *mantissa*, *exponent* -- ``"mt"`` - seismic moment tensor: - *mrr*, *mtt*, *mff*, *mrt*, *mrf*, *mtf*, *exponent* -- ``"partial"`` - partial focal mechanism: - *strike1*, *dip1*, *strike2*, *fault_type*, *magnitude* -- ``"principal_axis"`` - principal axis: - *t_value*, *t_azimuth*, *t_plunge*, *n_value*, *n_azimuth*, *n_plunge*, - *p_value*, *p_azimuth*, *p_plunge*, *exponent* - -Please also refer also the documentation on how to set up the input data in -respect to the chosen input type and convention. - -This tutorial shows how to adjust the display of the beachballs: +method. This tutorial shows how to adjust the display of the beachballs: - Filling the quadrants - Adjusting the outlines @@ -36,6 +11,15 @@ - Adding offset from the event location - Adding a label - Using size-coding and color-coding + +The focal mechanism data can be provided in different ways (external file, 1-D or 2-D +``numpy.array``, dictionary, or ``pandas.Dataframe``). Different conventions to define +the focal mechanism are supported: "Aki & Richards" (``"aki"``), "global CMT" +(``"gcmt"``), "seismic moment tensor" (``"mt"``), "partial focal mechanism" +(``"partial"``), "principal axis" (``"principal_axis"``). The details on how to set +up the input data in respect to the chosen input type and convention can be found in +the documentation of ``. For providing a dictionary or a ``pandas.DataFrame`` please +note the listed required keys or column names. """ # %% From 6228447174817051fe29da24767f1fcef6b3e83a Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 14 Oct 2024 21:01:56 +0200 Subject: [PATCH 047/105] Add links to pattern resources --- .../tutorials/advanced/focal_mechanisms.py | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 4038f0b6e14..0e9cf8f0f39 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -12,14 +12,15 @@ - Adding a label - Using size-coding and color-coding -The focal mechanism data can be provided in different ways (external file, 1-D or 2-D -``numpy.array``, dictionary, or ``pandas.Dataframe``). Different conventions to define -the focal mechanism are supported: "Aki & Richards" (``"aki"``), "global CMT" +The focal mechanism data or parameters can be provided in different input types: +external file, 1-D or 2-D ``numpy.array``, dictionary, or ``pandas.Dataframe``. +Different conventions are supported: "Aki & Richards" (``"aki"``), "global CMT" (``"gcmt"``), "seismic moment tensor" (``"mt"``), "partial focal mechanism" -(``"partial"``), "principal axis" (``"principal_axis"``). The details on how to set -up the input data in respect to the chosen input type and convention can be found in -the documentation of ``. For providing a dictionary or a ``pandas.DataFrame`` please -note the listed required keys or column names. +(``"partial"``), "principal axis" (``"principal_axis"``). The details on how to +set up the input data in respect to the chosen input type and convention can be +found in the documentation of :meth:`pygmt.Figure.meca`. When providing a +dictionary or a ``pandas.DataFrame``, please note the listed required keys or +column names, respectively. """ # %% @@ -71,8 +72,9 @@ # --------------------- # # Use the parameters ``compressionfill`` and ``extensionfill`` to fill the -# quadrants with colors or patterns. -# details on pattern gallery example and techenical reference +# quadrants with different colors or patterns. Regarding pattern see the +# gallery example :doc:`Bit and hachure patterns ` +# and the Technical Reference :doc:`Bit and hachure patterns `. fig = pygmt.Figure() fig.basemap(region=[-size, size] * 2, projection=projection, frame=frame) From e3e069634e83b40dc01dc469c6e3e9c378e90ee3 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 14 Oct 2024 21:33:02 +0200 Subject: [PATCH 048/105] Update comments --- examples/tutorials/advanced/focal_mechanisms.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 0e9cf8f0f39..bd06f3fb44f 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -27,9 +27,11 @@ import pandas as pd import pygmt + # %% # Set up input data # ----------------- +# # Store focal mechanism parameters for one event in a dictionary based on the # moment tensor convention @@ -56,8 +58,8 @@ # --------------------------- # # Required parameters are ``spec``, ``scale``, ``longitude`` and ``latitude`` -# (event location). (and ``convention`` depending on the input format, not needed -# for dictionary and ``pandas.Dataframe``.) +# (event location) as well as ``convention``. For the input types dictionary and +# ``pandas.Dataframe``, ``convention`` is not required. fig = pygmt.Figure() fig.basemap(region=[-size, size] * 2, projection=projection, frame=frame) From 4a675b19d023373835cfdb075df7df3dfe4a580f Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 14 Oct 2024 21:37:41 +0200 Subject: [PATCH 049/105] Update comments --- examples/tutorials/advanced/focal_mechanisms.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index bd06f3fb44f..4261bed88ba 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -107,8 +107,8 @@ # Adjusting the outlines # ---------------------- # -# Use the parameters ``pen`` for the outer border of the beachball and ``outline`` -# for all lines (also the borders between the nodal planes) +# Use the parameters ``pen`` and ``outline`` for adjusting the outer border of +# the beachball or for all lines (borders of beachball and nodal planes). fig = pygmt.Figure() fig.basemap(region=[-size, size] * 2, projection=projection, frame=frame) @@ -118,7 +118,7 @@ scale="1c", longitude=-2, latitude=0, - # Use a 1-point thick, darkorange and solid outline + # Use a 1-point thick, darkorange and solid line pen="1p,darkorange,solid", ) From 48bcdf8680da56afe1d1db471c91b0a00b484130 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 14 Oct 2024 22:27:04 +0200 Subject: [PATCH 050/105] Update comments --- .../tutorials/advanced/focal_mechanisms.py | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) mode change 100644 => 100755 examples/tutorials/advanced/focal_mechanisms.py diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py old mode 100644 new mode 100755 index 4261bed88ba..440eec3bdc3 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -27,7 +27,6 @@ import pandas as pd import pygmt - # %% # Set up input data # ----------------- @@ -107,8 +106,8 @@ # Adjusting the outlines # ---------------------- # -# Use the parameters ``pen`` and ``outline`` for adjusting the outer border of -# the beachball or for all lines (borders of beachball and nodal planes). +# Use the parameters ``pen`` and ``outline`` for adjusting the circumference of +# the beachball or all lines (circumference of the beachball and both nodal planes). fig = pygmt.Figure() fig.basemap(region=[-size, size] * 2, projection=projection, frame=frame) @@ -137,11 +136,11 @@ # Highlighting the nodal planes # ----------------------------- # -# Use the parameter ``nodal`` -# whereby ``"0"`` both, ``"1"`` first, ``"2"`` second -# only lines not fill i.e. transparent -# Make use of the stacking concept of GMT and plot on top of each other -# behaviour somehow strange +# Use the parameter ``nodal``, whereby ``"0"`` refers to both, ``"1"`` to the +# first, and ``"2"`` to the second nodal plane(s). Only the circumference and the +# specified nodal plane(s) are plotted, i.e. the quadrants remain unfilled +# (transparent). If needed, make usage of the stacking concept of (Py)GMT and use +# ``nodal`` with the ``outline`` or / and ``pen`` parameters in combination. fig = pygmt.Figure() fig.basemap(region=[-size, size] * 2, projection=projection, frame=frame) @@ -160,16 +159,24 @@ longitude=2, latitude=0, compressionfill="lightorange", - outline="1p,darkorange,solid", + outline="0.5p,black,solid", ) fig.meca( spec=aki_dict_single, scale="1c", longitude=2, latitude=0, - nodal="1/1p,black,solid", + nodal="1/1p,darkorange,solid", +) +fig.meca( + spec=aki_dict_single, + scale="1c", + longitude=2, + latitude=0, + compressionfill="white@100", + extensionfill="white@100", + pen="1p,gray30,solid", ) - fig.show() From 7718e7b3b5cc80e905958dabce57f3aab3e1c3f6 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 14 Oct 2024 22:44:40 +0200 Subject: [PATCH 051/105] Remove exectuion permission --- examples/tutorials/advanced/focal_mechanisms.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/tutorials/advanced/focal_mechanisms.py diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py old mode 100755 new mode 100644 From 998e42d58571b8cded011a02b39a8032d2b42996 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 14 Oct 2024 22:54:01 +0200 Subject: [PATCH 052/105] Update introduction part --- .../tutorials/advanced/focal_mechanisms.py | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 440eec3bdc3..6de49456172 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -3,7 +3,28 @@ ========================= Focal mechanisms can be plotted as beachballs with the :meth:`pygmt.Figure.meca` -method. This tutorial shows how to adjust the display of the beachballs: +method. + +The focal mechanism data or parameters can be provided as different input types: + +- external file, +- 1-D or 2-D ``numpy.array``, +- dictionary +- ``pandas.Dataframe`` + +Different conventions are supported: + +- "Aki & Richards" (``"aki"``) +- "global CMT" (``"gcmt"``) +- "seismic moment tensor" (``"mt"``) +- "partial focal mechanism" (``"partial"``) +- "principal axis" (``"principal_axis"``). + +The details on how to set up the input data in respect to the chosen input type and +convention can be found in the documentation of :meth:`pygmt.Figure.meca`. When +providing a dictionary or a ``pandas.DataFrame``, please note the listed required +keys or column names, respectively. This tutorial focus on how to adjust the display +of the beachballs: - Filling the quadrants - Adjusting the outlines @@ -11,16 +32,6 @@ - Adding offset from the event location - Adding a label - Using size-coding and color-coding - -The focal mechanism data or parameters can be provided in different input types: -external file, 1-D or 2-D ``numpy.array``, dictionary, or ``pandas.Dataframe``. -Different conventions are supported: "Aki & Richards" (``"aki"``), "global CMT" -(``"gcmt"``), "seismic moment tensor" (``"mt"``), "partial focal mechanism" -(``"partial"``), "principal axis" (``"principal_axis"``). The details on how to -set up the input data in respect to the chosen input type and convention can be -found in the documentation of :meth:`pygmt.Figure.meca`. When providing a -dictionary or a ``pandas.DataFrame``, please note the listed required keys or -column names, respectively. """ # %% @@ -33,7 +44,7 @@ # # Store focal mechanism parameters for one event in a dictionary based on the -# moment tensor convention +# seismic moment tensor convention mt_dict_single = mt_virginia = { "mrr": 4.71, "mtt": 0.0381, From 13e600badf6eaefd5b026130f3800291224d591b Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 14 Oct 2024 23:28:04 +0200 Subject: [PATCH 053/105] Expand comments --- .../tutorials/advanced/focal_mechanisms.py | 60 ++++++++++--------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 6de49456172..2a9507f2697 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -7,24 +7,24 @@ The focal mechanism data or parameters can be provided as different input types: -- external file, -- 1-D or 2-D ``numpy.array``, -- dictionary -- ``pandas.Dataframe`` +- external file (note expected column order) +- 1-D or 2-D ``numpy.array`` (note expected column order) +- dictionary (note the expected keys) +- ``pandas.Dataframe`` (note the expected column names) -Different conventions are supported: +Different conventions used to define the focal mechanism are supported: -- "Aki & Richards" (``"aki"``) +- "Aki and Richards" (``"aki"``) - "global CMT" (``"gcmt"``) -- "seismic moment tensor" (``"mt"``) +- "moment tensor" (``"mt"``) - "partial focal mechanism" (``"partial"``) -- "principal axis" (``"principal_axis"``). +- "principal axis" (``"principal_axis"``) The details on how to set up the input data in respect to the chosen input type and -convention can be found in the documentation of :meth:`pygmt.Figure.meca`. When -providing a dictionary or a ``pandas.DataFrame``, please note the listed required -keys or column names, respectively. This tutorial focus on how to adjust the display -of the beachballs: +convention (i.e the expected column order, keys, or column names) can be found in +the documentation of :meth:`pygmt.Figure.meca`. + +This tutorial focus on how to adjust the display of the beachballs: - Filling the quadrants - Adjusting the outlines @@ -44,7 +44,7 @@ # # Store focal mechanism parameters for one event in a dictionary based on the -# seismic moment tensor convention +# moment tensor convention mt_dict_single = mt_virginia = { "mrr": 4.71, "mtt": 0.0381, @@ -54,7 +54,7 @@ "mtf": -1.23, "exponent": 24, } -# Aki & Richards convention +# Aki and Richards convention aki_dict_single = {"strike": 318, "dip": 89, "rake": -179, "magnitude": 7.75} # Set up arguments for basemap @@ -196,12 +196,12 @@ # --------------------------------- # # Specify the optional parameters ``plot_longitude`` and ``plot_latitude``. -# Additional the parameter ``offset`` as to be set. Besides just drawing a line -# between the beachball and the event location, a small circle can be plotted -# at the event location by appending **+s** and the descired circle size. The -# connecting line as well as the outline of the circle are plotted with the -# setting of pen, or can be adjusted separately. The fill of the small circle -# corresponds to the fill for the compressive quadrantes. +# Additionally the parameter ``offset`` has to be set. Besides just drawing a +# line between the beachball and the event location, a small circle can be +# plotted at the event location by appending **+s** and the descired circle +# diameter. The connecting line as well as the outline of the circle are +# plotted with the setting of pen, or can be adjusted separately. The fill of +# the small circle corresponds to the fill of the compressive quadrantes. fig = pygmt.Figure() fig.basemap(region=[-size, size] * 2, projection=projection, frame=frame) @@ -263,12 +263,14 @@ # Adding a label # -------------- # -# Use the optional parameter ``event_name`` to add a label above the beachball, -# e.g., event name or event date and time. Change the font size of the the label -# text by appending **+f** and the desired font size to the ``scale`` parameter. -# Add a colored box behind the label via the label ``labelbox``. -# Force a fixed size of the beachball by appending **+m** to the argument -# passed to ``scale``. +# Use the optional parameter ``event_name`` to add a label near the beachball, +# e.g., event name or event date and time. Change the font of the the label text +# by appending **+f** and the desired font (size,name,color) to the argument passed +# to the ``scale`` parameter. Additionally, the location of the label relative to the +# beachball [Default is ``"TC"``, i.e., Top Center]; can be changed by appending +# **+j** and an offset can be applied by appending **+o** with values for *dx*\ /*dy*. +# Add a colored box behind the label via the label ``labelbox``. Force a fixed +# size of the beachball by appending **+m** to the argument passed to ``scale``. fig = pygmt.Figure() fig.coast(region="d", projection="N10c", land="lightgray", frame=True) @@ -282,9 +284,9 @@ # Using size-coding and color-coding # ---------------------------------- # -# The beachball can be sized and colored by a different quantities, e.g., by -# magnitude or hypocentral depth, respectively. Use the parameter ``cmap`` to -# pass the descired colormap. +# The beachball can be sized and colored by the quantities given as ``magnitude`` and +# ``depth``, e.g., by moment magnitude or hypocentral depth, respectively. Use the +# parameter ``cmap`` to pass the descired colormap. fig = pygmt.Figure() fig.coast(region="d", projection="N10c", land="lightgray", frame=True) From f146079d5294f4c5d13369c7fcf3076d575a9055 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 14 Oct 2024 23:56:59 +0200 Subject: [PATCH 054/105] Add example for 'component' parameter --- .../tutorials/advanced/focal_mechanisms.py | 58 +++++++++++++++---- 1 file changed, 46 insertions(+), 12 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 2a9507f2697..385b58f37dc 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -7,18 +7,18 @@ The focal mechanism data or parameters can be provided as different input types: -- external file (note expected column order) -- 1-D or 2-D ``numpy.array`` (note expected column order) -- dictionary (note the expected keys) -- ``pandas.Dataframe`` (note the expected column names) +- external file (note the expected column order) +- 1-D or 2-D ``numpy.array`` (note the expected column order) +- dictionary (note the expected keys) +- ``pandas.Dataframe`` (note the expected column names) Different conventions used to define the focal mechanism are supported: -- "Aki and Richards" (``"aki"``) -- "global CMT" (``"gcmt"``) -- "moment tensor" (``"mt"``) -- "partial focal mechanism" (``"partial"``) -- "principal axis" (``"principal_axis"``) +- Aki and Richards (``"aki"``) +- global CMT (``"gcmt"``) +- moment tensor (``"mt"``) +- partial focal mechanism (``"partial"``) +- principal axis (``"principal_axis"``) The details on how to set up the input data in respect to the chosen input type and convention (i.e the expected column order, keys, or column names) can be found in @@ -27,6 +27,7 @@ This tutorial focus on how to adjust the display of the beachballs: - Filling the quadrants +- Plotting the components of a seismic moment tensor - Adjusting the outlines - Highlighting the nodal planes - Adding offset from the event location @@ -113,6 +114,39 @@ fig.show() +# %% Plotting the components of a seismic moment tensor +# ----------------------------------------------------- +# +# Use the ``component`` parameter to plot the components of a seismic moment tensor. + +fig = pygmt.Figure() +fig.basemap(region=[-size, size] * 2, projection=projection, frame=frame) + +fig.meca( + spec=mt_dict_single, + scale="1c", + longitude=-3, + latitude=0, + component="full", # full seismic moment tensor +) +fig.meca( + spec=mt_dict_single, + scale="1c", + longitude=0, + latitude=0, + component="dc", # closest double couple +) +fig.meca( + spec=mt_dict_single, + scale="1c", + longitude=2, + latitude=0, + component="deviatoric", # deviatoric part +) + +fig.show() + + # %% # Adjusting the outlines # ---------------------- @@ -124,7 +158,7 @@ fig.basemap(region=[-size, size] * 2, projection=projection, frame=frame) fig.meca( - spec=mt_dict_single, + spec=aki_dict_single, scale="1c", longitude=-2, latitude=0, @@ -133,7 +167,7 @@ ) fig.meca( - spec=mt_dict_single, + spec=aki_dict_single, scale="1c", longitude=2, latitude=0, @@ -306,4 +340,4 @@ fig.show() -# sphinx_gallery_thumbnail_number = 7 +# sphinx_gallery_thumbnail_number = 9 From 2260e6c0fcbf7d765ccd1dfb0af0ff1cee17ed60 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Tue, 15 Oct 2024 00:04:42 +0200 Subject: [PATCH 055/105] Update headings --- .../tutorials/advanced/focal_mechanisms.py | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 385b58f37dc..1122869cd6d 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -39,11 +39,17 @@ import pandas as pd import pygmt +# Set up arguments for basemap +size = 5 +projection = "X10c/4c" +frame = ["af", "+ggray80"] + + # %% -# Set up input data -# ----------------- +# Set up the focal mechanism data +# ------------------------------- # -# Store focal mechanism parameters for one event in a dictionary based on the +# Store focal mechanism parameters for one event in a dictionary following the # moment tensor convention mt_dict_single = mt_virginia = { @@ -58,11 +64,6 @@ # Aki and Richards convention aki_dict_single = {"strike": 318, "dip": 89, "rake": -179, "magnitude": 7.75} -# Set up arguments for basemap -size = 5 -projection = "X10c/4c" -frame = ["af", "+ggray80"] - # %% # Plotting a single beachball @@ -114,8 +115,9 @@ fig.show() -# %% Plotting the components of a seismic moment tensor -# ----------------------------------------------------- +# %% +# Plotting the components of a seismic moment tensor +# -------------------------------------------------- # # Use the ``component`` parameter to plot the components of a seismic moment tensor. From 65b09b608f283beb22e5f08cd9b6bd07be693db7 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Tue, 15 Oct 2024 10:13:07 +0200 Subject: [PATCH 056/105] Convert from list to text --- .../tutorials/advanced/focal_mechanisms.py | 27 ++++++------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 1122869cd6d..a4e0f251f52 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -6,25 +6,14 @@ method. The focal mechanism data or parameters can be provided as different input types: - -- external file (note the expected column order) -- 1-D or 2-D ``numpy.array`` (note the expected column order) -- dictionary (note the expected keys) -- ``pandas.Dataframe`` (note the expected column names) - -Different conventions used to define the focal mechanism are supported: - -- Aki and Richards (``"aki"``) -- global CMT (``"gcmt"``) -- moment tensor (``"mt"``) -- partial focal mechanism (``"partial"``) -- principal axis (``"principal_axis"``) - -The details on how to set up the input data in respect to the chosen input type and -convention (i.e the expected column order, keys, or column names) can be found in -the documentation of :meth:`pygmt.Figure.meca`. - -This tutorial focus on how to adjust the display of the beachballs: +external file, 1-D or 2-D ``numpy.array``, dictionary, ``pandas.Dataframe``. +Different conventions to define the focal mechanism are supported: Aki and +Richards (``"aki"``), global CMT (``"gcmt"``), moment tensor (``"mt"``), partial +focal mechanism (``"partial"``), principal axis (``"principal_axis"``). Please +refer to the documentation of :meth:`pygmt.Figure.meca` regarding how to set up +the input data in respect to the chosen input type and convention (i.e the +expected column order, keys, or column names). This tutorial focus on how to +adjust the display of the beachballs: - Filling the quadrants - Plotting the components of a seismic moment tensor From 649def2d100892832c5376f28ff5e1ff86898bbd Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Tue, 15 Oct 2024 14:25:59 +0200 Subject: [PATCH 057/105] Expand docs --- examples/tutorials/advanced/focal_mechanisms.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index a4e0f251f52..8232e23a0f0 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -294,8 +294,9 @@ # to the ``scale`` parameter. Additionally, the location of the label relative to the # beachball [Default is ``"TC"``, i.e., Top Center]; can be changed by appending # **+j** and an offset can be applied by appending **+o** with values for *dx*\ /*dy*. -# Add a colored box behind the label via the label ``labelbox``. Force a fixed -# size of the beachball by appending **+m** to the argument passed to ``scale``. +# Add a colored [Default is white] box behind the label via the label ``labelbox``. +# Force a fixed size of the beachball by appending **+m** to the argument passed to +# the ``scale`` parameter. fig = pygmt.Figure() fig.coast(region="d", projection="N10c", land="lightgray", frame=True) @@ -311,7 +312,8 @@ # # The beachball can be sized and colored by the quantities given as ``magnitude`` and # ``depth``, e.g., by moment magnitude or hypocentral depth, respectively. Use the -# parameter ``cmap`` to pass the descired colormap. +# parameter ``cmap`` to pass the descired colormap. Now, the fills of the small circles +# indicating the event locations are given by the colormap. fig = pygmt.Figure() fig.coast(region="d", projection="N10c", land="lightgray", frame=True) From 091c898ca792bef564d8629e549c5511298cde93 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Tue, 15 Oct 2024 14:39:52 +0200 Subject: [PATCH 058/105] Format introduction part --- examples/tutorials/advanced/focal_mechanisms.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 8232e23a0f0..a8ac5974bc2 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -3,17 +3,16 @@ ========================= Focal mechanisms can be plotted as beachballs with the :meth:`pygmt.Figure.meca` -method. - -The focal mechanism data or parameters can be provided as different input types: -external file, 1-D or 2-D ``numpy.array``, dictionary, ``pandas.Dataframe``. +method. The focal mechanism data or parameters can be provided as different input +types: external file, 1-D or 2-D ``numpy.array``, dictionary, ``pandas.Dataframe``. Different conventions to define the focal mechanism are supported: Aki and Richards (``"aki"``), global CMT (``"gcmt"``), moment tensor (``"mt"``), partial focal mechanism (``"partial"``), principal axis (``"principal_axis"``). Please refer to the documentation of :meth:`pygmt.Figure.meca` regarding how to set up the input data in respect to the chosen input type and convention (i.e the -expected column order, keys, or column names). This tutorial focus on how to -adjust the display of the beachballs: +expected column order, keys, or column names). + +This tutorial focus on how to adjust the display of the beachballs: - Filling the quadrants - Plotting the components of a seismic moment tensor From f759a40c6d3eb2de82ca2ab37619dc52d381050c Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Tue, 15 Oct 2024 15:01:47 +0200 Subject: [PATCH 059/105] Add blank line --- examples/tutorials/advanced/focal_mechanisms.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index a8ac5974bc2..585ea732ca1 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -3,7 +3,9 @@ ========================= Focal mechanisms can be plotted as beachballs with the :meth:`pygmt.Figure.meca` -method. The focal mechanism data or parameters can be provided as different input +method. + +The focal mechanism data or parameters can be provided as different input types: external file, 1-D or 2-D ``numpy.array``, dictionary, ``pandas.Dataframe``. Different conventions to define the focal mechanism are supported: Aki and Richards (``"aki"``), global CMT (``"gcmt"``), moment tensor (``"mt"``), partial From 02de7fffee5f7bede3b9d8406196653e3508acfa Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 17 Oct 2024 19:22:53 +0200 Subject: [PATCH 060/105] Add section for plotting P and T axes --- .../tutorials/advanced/focal_mechanisms.py | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) mode change 100644 => 100755 examples/tutorials/advanced/focal_mechanisms.py diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py old mode 100644 new mode 100755 index 585ea732ca1..d528bd98ff9 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -17,6 +17,7 @@ This tutorial focus on how to adjust the display of the beachballs: - Filling the quadrants +- Plotting the P and T axes - Plotting the components of a seismic moment tensor - Adjusting the outlines - Highlighting the nodal planes @@ -32,7 +33,7 @@ # Set up arguments for basemap size = 5 projection = "X10c/4c" -frame = ["af", "+ggray80"] +frame = ["af", "+ggray90"] # %% @@ -105,6 +106,38 @@ fig.show() +# %% +# Plotting the P and T axes +# ------------------------- +# +# Wait for PR #3526 + +fig = pygmt.Figure() +fig.basemap(region=[-size, size] * 2, projection=projection, frame=frame) + +fig.meca( + spec=mt_dict_single, + scale="1c", + longitude=-2, + latitude=0, + Fa=True, +) + +fig.meca( + spec=mt_dict_single, + scale="1c", + longitude=2, + latitude=0, + Fa="0.2c/cd", # Compute and plot P and T axes with symbols, Adjust size and symbols + Fe="darkorange", # Adjust fill of T axis symbol + Fg="gray30", # Adjust fill of P axis symbol + Ft="0.8p,cornsilk", # Adjust outline of T axis symbol + Fp="0.8p,gray60", # Adjust outline of P axis symbol +) + +fig.show() + + # %% # Plotting the components of a seismic moment tensor # -------------------------------------------------- From e7ec741ba0be2f02193927e06d95cb61f01f5224 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 17 Oct 2024 19:32:16 +0200 Subject: [PATCH 061/105] Remove execution permission --- examples/tutorials/advanced/focal_mechanisms.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/tutorials/advanced/focal_mechanisms.py diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py old mode 100755 new mode 100644 From 3d235dd146d5c5a94c9f3ac238b3cc08e3048897 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 16 Feb 2025 15:06:24 +0100 Subject: [PATCH 062/105] Rewrap line length --- .../tutorials/advanced/focal_mechanisms.py | 71 +++++++++---------- 1 file changed, 35 insertions(+), 36 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index d528bd98ff9..b7f3663949d 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -5,14 +5,14 @@ Focal mechanisms can be plotted as beachballs with the :meth:`pygmt.Figure.meca` method. -The focal mechanism data or parameters can be provided as different input -types: external file, 1-D or 2-D ``numpy.array``, dictionary, ``pandas.Dataframe``. -Different conventions to define the focal mechanism are supported: Aki and -Richards (``"aki"``), global CMT (``"gcmt"``), moment tensor (``"mt"``), partial -focal mechanism (``"partial"``), principal axis (``"principal_axis"``). Please -refer to the documentation of :meth:`pygmt.Figure.meca` regarding how to set up -the input data in respect to the chosen input type and convention (i.e the -expected column order, keys, or column names). +The focal mechanism data or parameters can be provided as different input types: +external file, 1-D or 2-D ``numpy.array``, dictionary, ``pandas.Dataframe``. +Different conventions to define the focal mechanism are supported: Aki and Richards +(``"aki"``), global CMT (``"gcmt"``), moment tensor (``"mt"``), partial focal +mechanism (``"partial"``), principal axis (``"principal_axis"``). Please refer to +the documentation of :meth:`pygmt.Figure.meca` regarding how to set up the input +data in respect to the chosen input type and convention (i.e the expected column +order, keys, or column names). This tutorial focus on how to adjust the display of the beachballs: @@ -60,8 +60,8 @@ # Plotting a single beachball # --------------------------- # -# Required parameters are ``spec``, ``scale``, ``longitude`` and ``latitude`` -# (event location) as well as ``convention``. For the input types dictionary and +# Required parameters are ``spec``, ``scale``, ``longitude`` and ``latitude`` (event +# location) as well as ``convention``. For the input types dictionary and # ``pandas.Dataframe``, ``convention`` is not required. fig = pygmt.Figure() @@ -76,10 +76,10 @@ # Filling the quadrants # --------------------- # -# Use the parameters ``compressionfill`` and ``extensionfill`` to fill the -# quadrants with different colors or patterns. Regarding pattern see the -# gallery example :doc:`Bit and hachure patterns ` -# and the Technical Reference :doc:`Bit and hachure patterns `. +# Use the parameters ``compressionfill`` and ``extensionfill`` to fill the quadrants +# with different colors or patterns. Regarding pattern see the gallery example +# :doc:`Bit and hachure patterns ` and the Technical +# Reference :doc:`Bit and hachure patterns `. fig = pygmt.Figure() fig.basemap(region=[-size, size] * 2, projection=projection, frame=frame) @@ -176,8 +176,8 @@ # Adjusting the outlines # ---------------------- # -# Use the parameters ``pen`` and ``outline`` for adjusting the circumference of -# the beachball or all lines (circumference of the beachball and both nodal planes). +# Use the parameters ``pen`` and ``outline`` for adjusting the circumference of the +# beachball or all lines (circumference of the beachball and both nodal planes). fig = pygmt.Figure() fig.basemap(region=[-size, size] * 2, projection=projection, frame=frame) @@ -206,11 +206,11 @@ # Highlighting the nodal planes # ----------------------------- # -# Use the parameter ``nodal``, whereby ``"0"`` refers to both, ``"1"`` to the -# first, and ``"2"`` to the second nodal plane(s). Only the circumference and the -# specified nodal plane(s) are plotted, i.e. the quadrants remain unfilled -# (transparent). If needed, make usage of the stacking concept of (Py)GMT and use -# ``nodal`` with the ``outline`` or / and ``pen`` parameters in combination. +# Use the parameter ``nodal``, whereby ``"0"`` refers to both, ``"1"`` to the first, +# and ``"2"`` to the second nodal plane(s). Only the circumference and the specified +# nodal plane(s) are plotted, i.e. the quadrants remain unfilled (transparent). If +# needed, make usage of the stacking concept of (Py)GMT and use ``nodal`` with the +# ``outline`` or / and ``pen`` parameters in combination. fig = pygmt.Figure() fig.basemap(region=[-size, size] * 2, projection=projection, frame=frame) @@ -255,12 +255,12 @@ # --------------------------------- # # Specify the optional parameters ``plot_longitude`` and ``plot_latitude``. -# Additionally the parameter ``offset`` has to be set. Besides just drawing a -# line between the beachball and the event location, a small circle can be -# plotted at the event location by appending **+s** and the descired circle -# diameter. The connecting line as well as the outline of the circle are -# plotted with the setting of pen, or can be adjusted separately. The fill of -# the small circle corresponds to the fill of the compressive quadrantes. +# Additionally the parameter ``offset`` has to be set. Besides just drawing a line +# between the beachball and the event location, a small circle can be plotted at the +# event location by appending **+s** and the descired circle diameter. The connecting +# line as well as the outline of the circle are plotted with the setting of pen, or +# can be adjusted separately. The fill of the small circle corresponds to the fill +# of the compressive quadrantes. fig = pygmt.Figure() fig.basemap(region=[-size, size] * 2, projection=projection, frame=frame) @@ -322,15 +322,14 @@ # Adding a label # -------------- # -# Use the optional parameter ``event_name`` to add a label near the beachball, -# e.g., event name or event date and time. Change the font of the the label text -# by appending **+f** and the desired font (size,name,color) to the argument passed -# to the ``scale`` parameter. Additionally, the location of the label relative to the -# beachball [Default is ``"TC"``, i.e., Top Center]; can be changed by appending -# **+j** and an offset can be applied by appending **+o** with values for *dx*\ /*dy*. -# Add a colored [Default is white] box behind the label via the label ``labelbox``. -# Force a fixed size of the beachball by appending **+m** to the argument passed to -# the ``scale`` parameter. +# Use the optional parameter ``event_name`` to add a label near the beachball, e.g., +# event name or event date and time. Change the font of the the label text by appending +# **+f** and the desired font (size,name,color) to the argument passed to the ``scale`` +# parameter. Additionally, the location of the label relative to the beachball [Default +# is ``"TC"``, i.e., Top Center]; can be changed by appending **+j** and an offset can +# be applied by appending **+o** with values for *dx*\ /*dy*. Add a colored [Default +# is white] box behind the label via the label ``labelbox``. Force a fixed size of the +# beachball by appending **+m** to the argument passed to the ``scale`` parameter. fig = pygmt.Figure() fig.coast(region="d", projection="N10c", land="lightgray", frame=True) From e5151ffba05db6471258279d6bb995c261ffeba1 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 7 Mar 2025 14:36:41 +0100 Subject: [PATCH 063/105] Remove code examples for T and P axes --- .../tutorials/advanced/focal_mechanisms.py | 33 ------------------- 1 file changed, 33 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index b7f3663949d..c2d2fbe3513 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -17,7 +17,6 @@ This tutorial focus on how to adjust the display of the beachballs: - Filling the quadrants -- Plotting the P and T axes - Plotting the components of a seismic moment tensor - Adjusting the outlines - Highlighting the nodal planes @@ -106,38 +105,6 @@ fig.show() -# %% -# Plotting the P and T axes -# ------------------------- -# -# Wait for PR #3526 - -fig = pygmt.Figure() -fig.basemap(region=[-size, size] * 2, projection=projection, frame=frame) - -fig.meca( - spec=mt_dict_single, - scale="1c", - longitude=-2, - latitude=0, - Fa=True, -) - -fig.meca( - spec=mt_dict_single, - scale="1c", - longitude=2, - latitude=0, - Fa="0.2c/cd", # Compute and plot P and T axes with symbols, Adjust size and symbols - Fe="darkorange", # Adjust fill of T axis symbol - Fg="gray30", # Adjust fill of P axis symbol - Ft="0.8p,cornsilk", # Adjust outline of T axis symbol - Fp="0.8p,gray60", # Adjust outline of P axis symbol -) - -fig.show() - - # %% # Plotting the components of a seismic moment tensor # -------------------------------------------------- From f1b3c14f0563ebe319c46a912583a7ceb0ff9caf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Mon, 10 Mar 2025 20:38:55 +0100 Subject: [PATCH 064/105] Fix highlighting, formulations, interpuncation Co-authored-by: Dongdong Tian --- examples/tutorials/advanced/focal_mechanisms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index c2d2fbe3513..2f2d1778764 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -9,9 +9,9 @@ external file, 1-D or 2-D ``numpy.array``, dictionary, ``pandas.Dataframe``. Different conventions to define the focal mechanism are supported: Aki and Richards (``"aki"``), global CMT (``"gcmt"``), moment tensor (``"mt"``), partial focal -mechanism (``"partial"``), principal axis (``"principal_axis"``). Please refer to +mechanism (``"partial"``), and, principal axis (``"principal_axis"``). Please refer to the documentation of :meth:`pygmt.Figure.meca` regarding how to set up the input -data in respect to the chosen input type and convention (i.e the expected column +data in respect to the chosen input type and convention (i.e., the expected column order, keys, or column names). This tutorial focus on how to adjust the display of the beachballs: From 34c392c74552451e2c96a43cb1641c36aaed9b7d Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 10 Mar 2025 20:51:23 +0100 Subject: [PATCH 065/105] Define region directly --- examples/tutorials/advanced/focal_mechanisms.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 2f2d1778764..48d92f4b9f7 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -30,7 +30,7 @@ import pygmt # Set up arguments for basemap -size = 5 +region = [-5, 5, -5, 5] projection = "X10c/4c" frame = ["af", "+ggray90"] @@ -64,7 +64,7 @@ # ``pandas.Dataframe``, ``convention`` is not required. fig = pygmt.Figure() -fig.basemap(region=[-size, size] * 2, projection=projection, frame=frame) +fig.basemap(region=region, projection=projection, frame=frame) fig.meca(spec=mt_dict_single, scale="1c", longitude=0, latitude=0) @@ -81,7 +81,7 @@ # Reference :doc:`Bit and hachure patterns `. fig = pygmt.Figure() -fig.basemap(region=[-size, size] * 2, projection=projection, frame=frame) +fig.basemap(region=region, projection=projection, frame=frame) fig.meca( spec=mt_dict_single, @@ -112,7 +112,7 @@ # Use the ``component`` parameter to plot the components of a seismic moment tensor. fig = pygmt.Figure() -fig.basemap(region=[-size, size] * 2, projection=projection, frame=frame) +fig.basemap(region=region, projection=projection, frame=frame) fig.meca( spec=mt_dict_single, @@ -147,7 +147,7 @@ # beachball or all lines (circumference of the beachball and both nodal planes). fig = pygmt.Figure() -fig.basemap(region=[-size, size] * 2, projection=projection, frame=frame) +fig.basemap(region=region, projection=projection, frame=frame) fig.meca( spec=aki_dict_single, @@ -180,7 +180,7 @@ # ``outline`` or / and ``pen`` parameters in combination. fig = pygmt.Figure() -fig.basemap(region=[-size, size] * 2, projection=projection, frame=frame) +fig.basemap(region=region, projection=projection, frame=frame) fig.meca( spec=aki_dict_single, @@ -230,7 +230,7 @@ # of the compressive quadrantes. fig = pygmt.Figure() -fig.basemap(region=[-size, size] * 2, projection=projection, frame=frame) +fig.basemap(region=region, projection=projection, frame=frame) fig.meca( spec=aki_dict_single, From 5815c98820a23f5707d72005d74f012b1fcee62f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Mon, 10 Mar 2025 21:03:06 +0100 Subject: [PATCH 066/105] Remove mixed up variable name Co-authored-by: Dongdong Tian --- examples/tutorials/advanced/focal_mechanisms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 48d92f4b9f7..523502fa860 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -42,7 +42,7 @@ # Store focal mechanism parameters for one event in a dictionary following the # moment tensor convention -mt_dict_single = mt_virginia = { +mt_dict_single = { "mrr": 4.71, "mtt": 0.0381, "mff": -4.74, From 8716f0a9eb92e6868aa073d672c28fcc8a69eb1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Mon, 10 Mar 2025 21:32:49 +0100 Subject: [PATCH 067/105] Fix highlighting Co-authored-by: Dongdong Tian --- examples/tutorials/advanced/focal_mechanisms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 523502fa860..ee867ba572f 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -6,7 +6,7 @@ method. The focal mechanism data or parameters can be provided as different input types: -external file, 1-D or 2-D ``numpy.array``, dictionary, ``pandas.Dataframe``. +an ASCII file, 1-D or 2-D :class:`numpy.array`, dictionary, :class:`pandas.Dataframe`. Different conventions to define the focal mechanism are supported: Aki and Richards (``"aki"``), global CMT (``"gcmt"``), moment tensor (``"mt"``), partial focal mechanism (``"partial"``), and, principal axis (``"principal_axis"``). Please refer to From 96bbe1bf576b4bf51c94d856273d21ec5a3fe68f Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 10 Mar 2025 22:20:56 +0100 Subject: [PATCH 068/105] Add depth --- examples/tutorials/advanced/focal_mechanisms.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index ee867ba572f..ec051a7a368 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -66,7 +66,7 @@ fig = pygmt.Figure() fig.basemap(region=region, projection=projection, frame=frame) -fig.meca(spec=mt_dict_single, scale="1c", longitude=0, latitude=0) +fig.meca(spec=mt_dict_single, scale="1c", longitude=0, latitude=0, depth=0) fig.show() @@ -88,6 +88,7 @@ scale="1c", longitude=-2, latitude=0, + depth=0, compressionfill="darkorange", extensionfill="cornsilk", ) @@ -97,6 +98,7 @@ scale="1c", longitude=2, latitude=0, + depth=0, compressionfill="p8", extensionfill="p31", outline=True, @@ -119,6 +121,7 @@ scale="1c", longitude=-3, latitude=0, + depth=0, component="full", # full seismic moment tensor ) fig.meca( @@ -126,6 +129,7 @@ scale="1c", longitude=0, latitude=0, + depth=0, component="dc", # closest double couple ) fig.meca( @@ -133,6 +137,7 @@ scale="1c", longitude=2, latitude=0, + depth=0, component="deviatoric", # deviatoric part ) @@ -154,6 +159,7 @@ scale="1c", longitude=-2, latitude=0, + depth=0, # Use a 1-point thick, darkorange and solid line pen="1p,darkorange,solid", ) @@ -163,6 +169,7 @@ scale="1c", longitude=2, latitude=0, + depth=0, outline="1p,darkorange,solid", ) @@ -187,6 +194,7 @@ scale="1c", longitude=-2, latitude=0, + depth=0, nodal="0/1p,black,solid", ) @@ -195,6 +203,7 @@ scale="1c", longitude=2, latitude=0, + depth=0, compressionfill="lightorange", outline="0.5p,black,solid", ) @@ -203,6 +212,7 @@ scale="1c", longitude=2, latitude=0, + depth=0, nodal="1/1p,darkorange,solid", ) fig.meca( @@ -210,6 +220,7 @@ scale="1c", longitude=2, latitude=0, + depth=0, compressionfill="white@100", extensionfill="white@100", pen="1p,gray30,solid", @@ -237,6 +248,7 @@ scale="1c", longitude=-1, latitude=0, + depth=0, plot_longitude=-3, plot_latitude=2, offset=True, @@ -247,6 +259,7 @@ scale="1c", longitude=3, latitude=0, + depth=0, plot_longitude=1, plot_latitude=2, offset="+p1p,darkorange+s0.25c", From 5bc00254a74b2cb0a48c69a15159aa3ff7e5899a Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 10 Mar 2025 22:29:40 +0100 Subject: [PATCH 069/105] Fix comment --- examples/tutorials/advanced/focal_mechanisms.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index ec051a7a368..03397397009 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -59,9 +59,11 @@ # Plotting a single beachball # --------------------------- # -# Required parameters are ``spec``, ``scale``, ``longitude`` and ``latitude`` (event -# location) as well as ``convention``. For the input types dictionary and -# ``pandas.Dataframe``, ``convention`` is not required. +# Required parameters are ``spec` and ``scale`` as well as ``longitude``, ``latitude`` +# (event location), and depth (if these values are not included in the argument passed +# to ``spec``). Addionally the ``convention`` parameter is required if ``spec`` is an +# 1-D or 2-D numpy array; for the input types dictionary and ``pandas.Dataframe``, +# ``convention`` is not needed. fig = pygmt.Figure() fig.basemap(region=region, projection=projection, frame=frame) From e7ad5fe299b73c85b4488e224465039d486db08d Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 10 Mar 2025 22:35:08 +0100 Subject: [PATCH 070/105] Fix typo --- examples/tutorials/advanced/focal_mechanisms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 03397397009..a82362247bb 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -61,8 +61,8 @@ # # Required parameters are ``spec` and ``scale`` as well as ``longitude``, ``latitude`` # (event location), and depth (if these values are not included in the argument passed -# to ``spec``). Addionally the ``convention`` parameter is required if ``spec`` is an -# 1-D or 2-D numpy array; for the input types dictionary and ``pandas.Dataframe``, +# to ``spec``). Additionally the ``convention`` parameter is required if ``spec`` is +# an 1-D or 2-D numpy array; for the input types dictionary and ``pandas.Dataframe``, # ``convention`` is not needed. fig = pygmt.Figure() From 000d38b4315928a742b187512849780f63408312 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Tue, 11 Mar 2025 03:02:51 +0100 Subject: [PATCH 071/105] Fix thumbnail image --- examples/tutorials/advanced/focal_mechanisms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index a82362247bb..f6b16fa8d96 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -348,4 +348,4 @@ fig.show() -# sphinx_gallery_thumbnail_number = 9 +# sphinx_gallery_thumbnail_number = 8 From e699445d075a9ba5c9d228aad6612c3948af3af8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 11 Mar 2025 12:56:19 +0100 Subject: [PATCH 072/105] Fix highlighting Co-authored-by: Dongdong Tian --- examples/tutorials/advanced/focal_mechanisms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index f6b16fa8d96..8f1e11d6ea8 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -59,7 +59,7 @@ # Plotting a single beachball # --------------------------- # -# Required parameters are ``spec` and ``scale`` as well as ``longitude``, ``latitude`` +# Required parameters are ``spec`` and ``scale`` as well as ``longitude``, ``latitude`` # (event location), and depth (if these values are not included in the argument passed # to ``spec``). Additionally the ``convention`` parameter is required if ``spec`` is # an 1-D or 2-D numpy array; for the input types dictionary and ``pandas.Dataframe``, From 5f6dc3bf0a421e0c5577931d1793bb1c12519225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 11 Mar 2025 12:56:51 +0100 Subject: [PATCH 073/105] Make formulation sound nicer Co-authored-by: Dongdong Tian --- examples/tutorials/advanced/focal_mechanisms.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 8f1e11d6ea8..8dea83e4c65 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -63,7 +63,8 @@ # (event location), and depth (if these values are not included in the argument passed # to ``spec``). Additionally the ``convention`` parameter is required if ``spec`` is # an 1-D or 2-D numpy array; for the input types dictionary and ``pandas.Dataframe``, -# ``convention`` is not needed. +# the focal mechanism convention is automatically determined from dictionary keys or +:class:`pandas.DataFrame` column names. fig = pygmt.Figure() fig.basemap(region=region, projection=projection, frame=frame) From a02a7257d307ac1b2f6e2a1bf679c67c34485941 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 11 Mar 2025 12:57:47 +0100 Subject: [PATCH 074/105] Make formulation seismically for descriptive Co-authored-by: Dongdong Tian --- examples/tutorials/advanced/focal_mechanisms.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 8dea83e4c65..bd37382b8a7 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -114,7 +114,9 @@ # Plotting the components of a seismic moment tensor # -------------------------------------------------- # -# Use the ``component`` parameter to plot the components of a seismic moment tensor. +# A moment tensor can be decomposed into isotropic and deviatoric parts, and deviatoric +# part can be further decomposed into multiple parts (e.g., a double couple and A compensated linear vector dipole (CLVD)). +# Use the ``component`` parameter to specify the component to plot. fig = pygmt.Figure() fig.basemap(region=region, projection=projection, frame=frame) From 4375ae9ca01589b12808255f8e78111c68c1257b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 11 Mar 2025 12:58:57 +0100 Subject: [PATCH 075/105] Make formulation more related to the user Co-authored-by: Dongdong Tian --- examples/tutorials/advanced/focal_mechanisms.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index bd37382b8a7..cd40d8e10fd 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -39,7 +39,8 @@ # Set up the focal mechanism data # ------------------------------- # -# Store focal mechanism parameters for one event in a dictionary following the +# Here we store focal mechanism parameters (in moment tensor and Aki & Richards convention) +for one event in a dictionary: # moment tensor convention mt_dict_single = { From c9d07babae8536e7443eb6c4324fe6b0f64715d4 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Tue, 11 Mar 2025 13:10:26 +0100 Subject: [PATCH 076/105] Fix code to comment --- examples/tutorials/advanced/focal_mechanisms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index cd40d8e10fd..81c8b46dca7 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -39,8 +39,8 @@ # Set up the focal mechanism data # ------------------------------- # -# Here we store focal mechanism parameters (in moment tensor and Aki & Richards convention) -for one event in a dictionary: +# Here we store focal mechanism parameters (in moment tensor and Aki & Richards conventions) +# for one event in a dictionary: # moment tensor convention mt_dict_single = { From f6afebfbf72a566db74a9b683bd8fe3534b0ca8b Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Tue, 11 Mar 2025 13:11:19 +0100 Subject: [PATCH 077/105] Remove training white spaces --- examples/tutorials/advanced/focal_mechanisms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 81c8b46dca7..eeb9202012a 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -64,7 +64,7 @@ # (event location), and depth (if these values are not included in the argument passed # to ``spec``). Additionally the ``convention`` parameter is required if ``spec`` is # an 1-D or 2-D numpy array; for the input types dictionary and ``pandas.Dataframe``, -# the focal mechanism convention is automatically determined from dictionary keys or +# the focal mechanism convention is automatically determined from dictionary keys or :class:`pandas.DataFrame` column names. fig = pygmt.Figure() @@ -115,7 +115,7 @@ # Plotting the components of a seismic moment tensor # -------------------------------------------------- # -# A moment tensor can be decomposed into isotropic and deviatoric parts, and deviatoric +# A moment tensor can be decomposed into isotropic and deviatoric parts, and deviatoric # part can be further decomposed into multiple parts (e.g., a double couple and A compensated linear vector dipole (CLVD)). # Use the ``component`` parameter to specify the component to plot. From 4055d02707fee4cd0d0d14241fa3ecc94a2b5943 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Tue, 11 Mar 2025 13:15:01 +0100 Subject: [PATCH 078/105] Fix code to comment --- examples/tutorials/advanced/focal_mechanisms.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index eeb9202012a..75c50d28c43 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -39,8 +39,8 @@ # Set up the focal mechanism data # ------------------------------- # -# Here we store focal mechanism parameters (in moment tensor and Aki & Richards conventions) -# for one event in a dictionary: +# Here we store focal mechanism parameters (in moment tensor and Aki & Richards +# conventions) for one event in a dictionary: # moment tensor convention mt_dict_single = { @@ -65,7 +65,7 @@ # to ``spec``). Additionally the ``convention`` parameter is required if ``spec`` is # an 1-D or 2-D numpy array; for the input types dictionary and ``pandas.Dataframe``, # the focal mechanism convention is automatically determined from dictionary keys or -:class:`pandas.DataFrame` column names. +# :class:`pandas.DataFrame` column names. fig = pygmt.Figure() fig.basemap(region=region, projection=projection, frame=frame) @@ -116,8 +116,9 @@ # -------------------------------------------------- # # A moment tensor can be decomposed into isotropic and deviatoric parts, and deviatoric -# part can be further decomposed into multiple parts (e.g., a double couple and A compensated linear vector dipole (CLVD)). -# Use the ``component`` parameter to specify the component to plot. +# part can be further decomposed into multiple parts (e.g., a double couple and a +# compensated linear vector dipole (CLVD)). Use the ``component`` parameter to specify +# the component to plot. fig = pygmt.Figure() fig.basemap(region=region, projection=projection, frame=frame) From 57121bfe702b4f1237317878b8278b454ad9653d Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Tue, 11 Mar 2025 14:27:59 +0100 Subject: [PATCH 079/105] Move section for *fill up --- .../tutorials/advanced/focal_mechanisms.py | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 75c50d28c43..1fac7f64989 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -76,13 +76,13 @@ # %% -# Filling the quadrants -# --------------------- +# Plotting the components of a seismic moment tensor +# -------------------------------------------------- # -# Use the parameters ``compressionfill`` and ``extensionfill`` to fill the quadrants -# with different colors or patterns. Regarding pattern see the gallery example -# :doc:`Bit and hachure patterns ` and the Technical -# Reference :doc:`Bit and hachure patterns `. +# A moment tensor can be decomposed into isotropic and deviatoric parts, and deviatoric +# part can be further decomposed into multiple parts (e.g., a double couple and a +# compensated linear vector dipole (CLVD)). Use the ``component`` parameter to specify +# the component you want to plot. fig = pygmt.Figure() fig.basemap(region=region, projection=projection, frame=frame) @@ -90,35 +90,39 @@ fig.meca( spec=mt_dict_single, scale="1c", - longitude=-2, + longitude=-3, latitude=0, depth=0, - compressionfill="darkorange", - extensionfill="cornsilk", + component="full", # full seismic moment tensor +) +fig.meca( + spec=mt_dict_single, + scale="1c", + longitude=0, + latitude=0, + depth=0, + component="dc", # closest double couple ) - fig.meca( spec=mt_dict_single, scale="1c", longitude=2, latitude=0, depth=0, - compressionfill="p8", - extensionfill="p31", - outline=True, + component="deviatoric", # deviatoric part ) fig.show() # %% -# Plotting the components of a seismic moment tensor -# -------------------------------------------------- +# Filling the quadrants +# --------------------- # -# A moment tensor can be decomposed into isotropic and deviatoric parts, and deviatoric -# part can be further decomposed into multiple parts (e.g., a double couple and a -# compensated linear vector dipole (CLVD)). Use the ``component`` parameter to specify -# the component to plot. +# Use the parameters ``compressionfill`` and ``extensionfill`` to fill the quadrants +# with different colors or patterns. Regarding patterns see the gallery example +# :doc:`Bit and hachure patterns ` and the Technical +# Reference :doc:`Bit and hachure patterns `. fig = pygmt.Figure() fig.basemap(region=region, projection=projection, frame=frame) @@ -126,26 +130,22 @@ fig.meca( spec=mt_dict_single, scale="1c", - longitude=-3, - latitude=0, - depth=0, - component="full", # full seismic moment tensor -) -fig.meca( - spec=mt_dict_single, - scale="1c", - longitude=0, + longitude=-2, latitude=0, depth=0, - component="dc", # closest double couple + compressionfill="darkorange", + extensionfill="cornsilk", ) + fig.meca( spec=mt_dict_single, scale="1c", longitude=2, latitude=0, depth=0, - component="deviatoric", # deviatoric part + compressionfill="p8", + extensionfill="p31", + outline=True, ) fig.show() From 350d01d2cf2066d79d7f7651a99252099df515ff Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Tue, 11 Mar 2025 14:50:03 +0100 Subject: [PATCH 080/105] Explain scale parameter regarding size --- examples/tutorials/advanced/focal_mechanisms.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 1fac7f64989..fec9d07a0d0 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -16,8 +16,8 @@ This tutorial focus on how to adjust the display of the beachballs: -- Filling the quadrants - Plotting the components of a seismic moment tensor +- Filling the quadrants - Adjusting the outlines - Highlighting the nodal planes - Adding offset from the event location @@ -65,7 +65,10 @@ # to ``spec``). Additionally the ``convention`` parameter is required if ``spec`` is # an 1-D or 2-D numpy array; for the input types dictionary and ``pandas.Dataframe``, # the focal mechanism convention is automatically determined from dictionary keys or -# :class:`pandas.DataFrame` column names. +# :class:`pandas.DataFrame` column names. The ``scale`` parameter controlls the radius +# of the beachball. By default, the value defines the size for a magnitude of 5 (i.e., +# a scalar seismic moment of M0 = 4.0E23 dyn cm). Appand ``"+l"`` to force the radius +# to be proportional to the seismic moment. fig = pygmt.Figure() fig.basemap(region=region, projection=projection, frame=frame) From abb7ae7699e6193d5682af25e32629fde2557270 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Tue, 11 Mar 2025 21:14:41 +0100 Subject: [PATCH 081/105] Fix typo --- examples/tutorials/advanced/focal_mechanisms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index fec9d07a0d0..815003e500e 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -65,7 +65,7 @@ # to ``spec``). Additionally the ``convention`` parameter is required if ``spec`` is # an 1-D or 2-D numpy array; for the input types dictionary and ``pandas.Dataframe``, # the focal mechanism convention is automatically determined from dictionary keys or -# :class:`pandas.DataFrame` column names. The ``scale`` parameter controlls the radius +# :class:`pandas.DataFrame` column names. The ``scale`` parameter controls the radius # of the beachball. By default, the value defines the size for a magnitude of 5 (i.e., # a scalar seismic moment of M0 = 4.0E23 dyn cm). Appand ``"+l"`` to force the radius # to be proportional to the seismic moment. From 40a330df4c6c8ebeda77aea5700b1d4338cfe9f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Wed, 12 Mar 2025 11:02:34 +0100 Subject: [PATCH 082/105] Combine setting up dictionary and converting to dataframe Co-authored-by: Dongdong Tian --- .../tutorials/advanced/focal_mechanisms.py | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 815003e500e..4754ab4c44d 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -286,26 +286,26 @@ # Data of four earthquakes taken from USGS. # Provide lists. -# Set up a dictionary -aki_dict_multiple = { - "strike": [255, 173, 295, 318], - "dip": [70, 68, 79, 89], - "rake": [20, 83, -177, -179], - "magnitude": [7.0, 5.8, 6.0, 7.8], - "longitude": [-72.53, -79.61, 69.46, 37.01], - "latitude": [18.44, 0.90, 33.02, 37.23], - "depth": [13, 19, 4, 10], - "plot_longitude": [-70, -110, 100, 0], - "plot_latitude": [40, 10, 50, 55], - "event_name": [ - "Haiti - 2010/01/12", - "Esmeraldas - 2022/03/27", - "Afghanistan - 2022/06/21", - "Syria/Turkey - 2023/02/06", - ], -} -# Convert to a pandas.DataFrame -aki_df_multiple = pd.DataFrame(aki_dict_multiple) +# Set up a pandas.DataFrame with multiple focal mechanism parameters. +aki_df_multiple = pd.DataFrame( + { + "strike": [255, 173, 295, 318], + "dip": [70, 68, 79, 89], + "rake": [20, 83, -177, -179], + "magnitude": [7.0, 5.8, 6.0, 7.8], + "longitude": [-72.53, -79.61, 69.46, 37.01], + "latitude": [18.44, 0.90, 33.02, 37.23], + "depth": [13, 19, 4, 10], + "plot_longitude": [-70, -110, 100, 0], + "plot_latitude": [40, 10, 50, 55], + "event_name": [ + "Haiti - 2010/01/12", + "Esmeraldas - 2022/03/27", + "Afghanistan - 2022/06/21", + "Syria/Turkey - 2023/02/06", + ], + } +) # %% From b0c775292d60a9646640611592b0400e6b579ec2 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Wed, 12 Mar 2025 19:37:43 +0100 Subject: [PATCH 083/105] Remove datatype from variable name --- .../tutorials/advanced/focal_mechanisms.py | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 4754ab4c44d..09f7d3a3819 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -43,7 +43,7 @@ # conventions) for one event in a dictionary: # moment tensor convention -mt_dict_single = { +mt_single = { "mrr": 4.71, "mtt": 0.0381, "mff": -4.74, @@ -53,7 +53,7 @@ "exponent": 24, } # Aki and Richards convention -aki_dict_single = {"strike": 318, "dip": 89, "rake": -179, "magnitude": 7.75} +aki_single = {"strike": 318, "dip": 89, "rake": -179, "magnitude": 7.75} # %% @@ -73,7 +73,7 @@ fig = pygmt.Figure() fig.basemap(region=region, projection=projection, frame=frame) -fig.meca(spec=mt_dict_single, scale="1c", longitude=0, latitude=0, depth=0) +fig.meca(spec=mt_single, scale="1c", longitude=0, latitude=0, depth=0) fig.show() @@ -91,7 +91,7 @@ fig.basemap(region=region, projection=projection, frame=frame) fig.meca( - spec=mt_dict_single, + spec=mt_single, scale="1c", longitude=-3, latitude=0, @@ -99,7 +99,7 @@ component="full", # full seismic moment tensor ) fig.meca( - spec=mt_dict_single, + spec=mt_single, scale="1c", longitude=0, latitude=0, @@ -107,7 +107,7 @@ component="dc", # closest double couple ) fig.meca( - spec=mt_dict_single, + spec=mt_single, scale="1c", longitude=2, latitude=0, @@ -131,7 +131,7 @@ fig.basemap(region=region, projection=projection, frame=frame) fig.meca( - spec=mt_dict_single, + spec=mt_single, scale="1c", longitude=-2, latitude=0, @@ -141,7 +141,7 @@ ) fig.meca( - spec=mt_dict_single, + spec=mt_single, scale="1c", longitude=2, latitude=0, @@ -165,7 +165,7 @@ fig.basemap(region=region, projection=projection, frame=frame) fig.meca( - spec=aki_dict_single, + spec=aki_single, scale="1c", longitude=-2, latitude=0, @@ -175,7 +175,7 @@ ) fig.meca( - spec=aki_dict_single, + spec=aki_single, scale="1c", longitude=2, latitude=0, @@ -200,7 +200,7 @@ fig.basemap(region=region, projection=projection, frame=frame) fig.meca( - spec=aki_dict_single, + spec=aki_single, scale="1c", longitude=-2, latitude=0, @@ -209,7 +209,7 @@ ) fig.meca( - spec=aki_dict_single, + spec=aki_single, scale="1c", longitude=2, latitude=0, @@ -218,7 +218,7 @@ outline="0.5p,black,solid", ) fig.meca( - spec=aki_dict_single, + spec=aki_single, scale="1c", longitude=2, latitude=0, @@ -226,7 +226,7 @@ nodal="1/1p,darkorange,solid", ) fig.meca( - spec=aki_dict_single, + spec=aki_single, scale="1c", longitude=2, latitude=0, @@ -254,7 +254,7 @@ fig.basemap(region=region, projection=projection, frame=frame) fig.meca( - spec=aki_dict_single, + spec=aki_single, scale="1c", longitude=-1, latitude=0, @@ -265,7 +265,7 @@ ) fig.meca( - spec=aki_dict_single, + spec=aki_single, scale="1c", longitude=3, latitude=0, @@ -287,7 +287,7 @@ # Provide lists. # Set up a pandas.DataFrame with multiple focal mechanism parameters. -aki_df_multiple = pd.DataFrame( +aki_multiple = pd.DataFrame( { "strike": [255, 173, 295, 318], "dip": [70, 68, 79, 89], @@ -324,7 +324,7 @@ fig = pygmt.Figure() fig.coast(region="d", projection="N10c", land="lightgray", frame=True) -fig.meca(spec=aki_df_multiple, scale="0.4c+m+f5p", labelbox="white@30", offset="+s0.1c") +fig.meca(spec=aki_multiple, scale="0.4c+m+f5p", labelbox="white@30", offset="+s0.1c") fig.show() @@ -346,7 +346,7 @@ fig.colorbar(frame=["x+lhypocentral depth", "y+lkm"]) fig.meca( - spec=aki_df_multiple, + spec=aki_multiple, scale="0.4c+f5p", offset="0.2p,gray30+s0.1c", labelbox="white@30", From 5dfdc96f3a194fca21a6868d30b50d3a2a5d1123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Wed, 12 Mar 2025 19:45:34 +0100 Subject: [PATCH 084/105] Remove offset parameter for dict input Co-authored-by: Dongdong Tian --- examples/tutorials/advanced/focal_mechanisms.py | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 09f7d3a3819..d40bd09c814 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -261,7 +261,6 @@ depth=0, plot_longitude=-3, plot_latitude=2, - offset=True, ) fig.meca( From 8d19aad202574e6bc95bb8e827646598f8e16b43 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Wed, 12 Mar 2025 19:51:23 +0100 Subject: [PATCH 085/105] Improve explanaition of offset parameter --- examples/tutorials/advanced/focal_mechanisms.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index d40bd09c814..a0e56882cef 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -242,13 +242,14 @@ # Adding offset from event location # --------------------------------- # -# Specify the optional parameters ``plot_longitude`` and ``plot_latitude``. -# Additionally the parameter ``offset`` has to be set. Besides just drawing a line -# between the beachball and the event location, a small circle can be plotted at the -# event location by appending **+s** and the descired circle diameter. The connecting -# line as well as the outline of the circle are plotted with the setting of pen, or -# can be adjusted separately. The fill of the small circle corresponds to the fill -# of the compressive quadrantes. +# Specify the optional parameters ``plot_longitude`` and ``plot_latitude``. If ``spec`` +# is an ASCII file with columns for ``plot_longitude`` and ``plot_latitude`` the +# ``offset`` parameter has to be set to ``True``. Besides just drawing a line between +# the beachball and the event location, a small circle can be plotted at the event +# location by appending **+s** and the descired circle diameter. The connecting line +# as well as the outline of the circle are plotted with the setting of pen, or can be +# adjusted separately. The fill of the small circle corresponds to the fill of the +# compressive quadrantes. fig = pygmt.Figure() fig.basemap(region=region, projection=projection, frame=frame) From 5ed896d7e307f759c07de9bdbf197947ee74edc4 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Wed, 12 Mar 2025 20:03:52 +0100 Subject: [PATCH 086/105] Use for loop for component parameter --- .../tutorials/advanced/focal_mechanisms.py | 39 +++++++------------ 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index a0e56882cef..544c9737c05 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -82,38 +82,25 @@ # Plotting the components of a seismic moment tensor # -------------------------------------------------- # -# A moment tensor can be decomposed into isotropic and deviatoric parts, and deviatoric -# part can be further decomposed into multiple parts (e.g., a double couple and a +# A moment tensor can be decomposed into isotropic and deviatoric parts. The deviatoric +# part can be further decomposed into multiple parts (e.g., a double couple (DC) and a # compensated linear vector dipole (CLVD)). Use the ``component`` parameter to specify # the component you want to plot. fig = pygmt.Figure() fig.basemap(region=region, projection=projection, frame=frame) -fig.meca( - spec=mt_single, - scale="1c", - longitude=-3, - latitude=0, - depth=0, - component="full", # full seismic moment tensor -) -fig.meca( - spec=mt_single, - scale="1c", - longitude=0, - latitude=0, - depth=0, - component="dc", # closest double couple -) -fig.meca( - spec=mt_single, - scale="1c", - longitude=2, - latitude=0, - depth=0, - component="deviatoric", # deviatoric part -) +longitude = -3 +for component in ["full", "dc", "deviatoric"]: + fig.meca( + spec=mt_single, + scale="1c", + longitude=longitude, + latitude=0, + depth=0, + component=component, + ) + longitude = longitude + 3 fig.show() From 379cdb1137ce6d43b89e42408d870fabf9bed357 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Wed, 12 Mar 2025 20:22:17 +0100 Subject: [PATCH 087/105] Add explanation for muliple beachballs --- examples/tutorials/advanced/focal_mechanisms.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 544c9737c05..da8fc6c95d1 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -270,8 +270,9 @@ # Plotting multiple beachballs # ---------------------------- # -# Data of four earthquakes taken from USGS. -# Provide lists. +# Now we want to plot multiple beachballs with one call of :meth:`pygmt.Figure.meca`. We +# use data of four earthquakes taken from USGS. For each focal mechanism parameter a +# list with a length corresponding to the numeber of events has to be given. # Set up a pandas.DataFrame with multiple focal mechanism parameters. aki_multiple = pd.DataFrame( From 4214b71cb0bd2855a59ae2cabd279aa47d3277a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Thu, 13 Mar 2025 13:15:08 +0100 Subject: [PATCH 088/105] Remove unneeded pen attribute Co-authored-by: Dongdong Tian --- examples/tutorials/advanced/focal_mechanisms.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index da8fc6c95d1..add26734555 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -158,7 +158,7 @@ latitude=0, depth=0, # Use a 1-point thick, darkorange and solid line - pen="1p,darkorange,solid", + pen="1p,darkorange", ) fig.meca( @@ -167,7 +167,7 @@ longitude=2, latitude=0, depth=0, - outline="1p,darkorange,solid", + outline="1p,darkorange", ) fig.show() @@ -192,7 +192,7 @@ longitude=-2, latitude=0, depth=0, - nodal="0/1p,black,solid", + nodal="0/1p,black", ) fig.meca( @@ -202,7 +202,7 @@ latitude=0, depth=0, compressionfill="lightorange", - outline="0.5p,black,solid", + outline="0.5p,black", ) fig.meca( spec=aki_single, @@ -210,7 +210,7 @@ longitude=2, latitude=0, depth=0, - nodal="1/1p,darkorange,solid", + nodal="1/1p,darkorange", ) fig.meca( spec=aki_single, @@ -220,7 +220,7 @@ depth=0, compressionfill="white@100", extensionfill="white@100", - pen="1p,gray30,solid", + pen="1p,gray30", ) fig.show() From 20a70f0dfb63cb2ddc921ae53979ae8d86abb1ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Thu, 13 Mar 2025 13:18:04 +0100 Subject: [PATCH 089/105] Use math mode Co-authored-by: Dongdong Tian --- examples/tutorials/advanced/focal_mechanisms.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index add26734555..568f963469e 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -67,7 +67,8 @@ # the focal mechanism convention is automatically determined from dictionary keys or # :class:`pandas.DataFrame` column names. The ``scale`` parameter controls the radius # of the beachball. By default, the value defines the size for a magnitude of 5 (i.e., -# a scalar seismic moment of M0 = 4.0E23 dyn cm). Appand ``"+l"`` to force the radius +# a scalar seismic moment of :math:`M_0 = 4.0 \times 10^23`: dyn cm) and the beachball +# size is proportional to the magnitude. Appand ``"+l"`` to force the radius # to be proportional to the seismic moment. fig = pygmt.Figure() From 7031b2629e9c638e950f0148bbf457e9e22878a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Thu, 13 Mar 2025 13:19:16 +0100 Subject: [PATCH 090/105] Use zip Co-authored-by: Dongdong Tian --- examples/tutorials/advanced/focal_mechanisms.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 568f963469e..dc0928e6718 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -91,8 +91,7 @@ fig = pygmt.Figure() fig.basemap(region=region, projection=projection, frame=frame) -longitude = -3 -for component in ["full", "dc", "deviatoric"]: +for component, longitude in zip(["full", "dc", "deviatoric"], [-3, 0, 3], strict=True): fig.meca( spec=mt_single, scale="1c", @@ -101,7 +100,6 @@ depth=0, component=component, ) - longitude = longitude + 3 fig.show() From a586f11c9bbc17d528c857d52d2d975723113047 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 13 Mar 2025 13:26:50 +0100 Subject: [PATCH 091/105] Fix code style --- examples/tutorials/advanced/focal_mechanisms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index dc0928e6718..0e6c2a7d8b3 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -67,7 +67,7 @@ # the focal mechanism convention is automatically determined from dictionary keys or # :class:`pandas.DataFrame` column names. The ``scale`` parameter controls the radius # of the beachball. By default, the value defines the size for a magnitude of 5 (i.e., -# a scalar seismic moment of :math:`M_0 = 4.0 \times 10^23`: dyn cm) and the beachball +# a scalar seismic moment of :math:`M_0 = 4.0 \times 10^23`: dyn cm) and the beachball # size is proportional to the magnitude. Appand ``"+l"`` to force the radius # to be proportional to the seismic moment. From eb158bb038580496eb556b36842438e68191f667 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 13 Mar 2025 13:38:20 +0100 Subject: [PATCH 092/105] Adjust spacing --- examples/tutorials/advanced/focal_mechanisms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 0e6c2a7d8b3..7d7c2250835 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -91,7 +91,7 @@ fig = pygmt.Figure() fig.basemap(region=region, projection=projection, frame=frame) -for component, longitude in zip(["full", "dc", "deviatoric"], [-3, 0, 3], strict=True): +for component, longitude in zip(["full", "dc", "deviatoric"], [-3, 0, 2], strict=True): fig.meca( spec=mt_single, scale="1c", From 8f6cab667e269a7186e525d340ff92d7038185bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Fri, 14 Mar 2025 12:50:08 +0100 Subject: [PATCH 093/105] Fix math mode Co-authored-by: Dongdong Tian --- examples/tutorials/advanced/focal_mechanisms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 7d7c2250835..37a66a3a1d7 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -67,7 +67,7 @@ # the focal mechanism convention is automatically determined from dictionary keys or # :class:`pandas.DataFrame` column names. The ``scale`` parameter controls the radius # of the beachball. By default, the value defines the size for a magnitude of 5 (i.e., -# a scalar seismic moment of :math:`M_0 = 4.0 \times 10^23`: dyn cm) and the beachball +# a scalar seismic moment of :math:`M_0 = 4.0 \times 10^{23}`: dyn cm) and the beachball # size is proportional to the magnitude. Appand ``"+l"`` to force the radius # to be proportional to the seismic moment. From 9925eab71e96aefc101141b0759a0f6c2edd06ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sat, 15 Mar 2025 12:16:06 +0100 Subject: [PATCH 094/105] Fix math mode Co-authored-by: Dongdong Tian --- examples/tutorials/advanced/focal_mechanisms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 37a66a3a1d7..c13d239725e 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -67,7 +67,7 @@ # the focal mechanism convention is automatically determined from dictionary keys or # :class:`pandas.DataFrame` column names. The ``scale`` parameter controls the radius # of the beachball. By default, the value defines the size for a magnitude of 5 (i.e., -# a scalar seismic moment of :math:`M_0 = 4.0 \times 10^{23}`: dyn cm) and the beachball +# a scalar seismic moment of :math:`M_0 = 4.0 \times 10^{23}` dyn cm) and the beachball # size is proportional to the magnitude. Appand ``"+l"`` to force the radius # to be proportional to the seismic moment. From 46dc736739edc0c7143b817d4a80f1759a45dd49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sat, 15 Mar 2025 20:42:36 +0100 Subject: [PATCH 095/105] Remove overview list Co-authored-by: Dongdong Tian --- examples/tutorials/advanced/focal_mechanisms.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index c13d239725e..33c56d04ad9 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -12,17 +12,8 @@ mechanism (``"partial"``), and, principal axis (``"principal_axis"``). Please refer to the documentation of :meth:`pygmt.Figure.meca` regarding how to set up the input data in respect to the chosen input type and convention (i.e., the expected column -order, keys, or column names). - -This tutorial focus on how to adjust the display of the beachballs: - -- Plotting the components of a seismic moment tensor -- Filling the quadrants -- Adjusting the outlines -- Highlighting the nodal planes -- Adding offset from the event location -- Adding a label -- Using size-coding and color-coding +order, keys, or column names). This tutorial focus on how to adjust the display of +the beachballs. """ # %% From fb70e785537b3671dae5d790e5eae84f198813f3 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 20:45:01 +0100 Subject: [PATCH 096/105] Remove trailing white space --- examples/tutorials/advanced/focal_mechanisms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 33c56d04ad9..9b90a463549 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -12,7 +12,7 @@ mechanism (``"partial"``), and, principal axis (``"principal_axis"``). Please refer to the documentation of :meth:`pygmt.Figure.meca` regarding how to set up the input data in respect to the chosen input type and convention (i.e., the expected column -order, keys, or column names). This tutorial focus on how to adjust the display of +order, keys, or column names). This tutorial focus on how to adjust the display of the beachballs. """ From 6709e51522e9a58bdb1e08723c7399ac20374943 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 20:46:11 +0100 Subject: [PATCH 097/105] Fix typo --- examples/tutorials/advanced/focal_mechanisms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 9b90a463549..afbafc472da 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -262,7 +262,7 @@ # # Now we want to plot multiple beachballs with one call of :meth:`pygmt.Figure.meca`. We # use data of four earthquakes taken from USGS. For each focal mechanism parameter a -# list with a length corresponding to the numeber of events has to be given. +# list with a length corresponding to the number of events has to be given. # Set up a pandas.DataFrame with multiple focal mechanism parameters. aki_multiple = pd.DataFrame( From ddf6211f168519c1322e7eefc6fe067885fe641f Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 15 Mar 2025 20:52:25 +0100 Subject: [PATCH 098/105] Use line length --- .../tutorials/advanced/focal_mechanisms.py | 40 +++++++++---------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index afbafc472da..0bb143571a5 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -2,18 +2,16 @@ Plotting focal mechanisms ========================= -Focal mechanisms can be plotted as beachballs with the :meth:`pygmt.Figure.meca` -method. +Focal mechanisms can be plotted as beachballs with the :meth:`pygmt.Figure.meca` method. -The focal mechanism data or parameters can be provided as different input types: -an ASCII file, 1-D or 2-D :class:`numpy.array`, dictionary, :class:`pandas.Dataframe`. +The focal mechanism data or parameters can be provided as different input types: an +ASCII file, 1-D or 2-D :class:`numpy.array`, dictionary, :class:`pandas.Dataframe`. Different conventions to define the focal mechanism are supported: Aki and Richards -(``"aki"``), global CMT (``"gcmt"``), moment tensor (``"mt"``), partial focal -mechanism (``"partial"``), and, principal axis (``"principal_axis"``). Please refer to -the documentation of :meth:`pygmt.Figure.meca` regarding how to set up the input -data in respect to the chosen input type and convention (i.e., the expected column -order, keys, or column names). This tutorial focus on how to adjust the display of -the beachballs. +(``"aki"``), global CMT (``"gcmt"``), moment tensor (``"mt"``), partial focal mechanism +(``"partial"``), and, principal axis (``"principal_axis"``). Please refer to the +documentation of :meth:`pygmt.Figure.meca` regarding how to set up the input data in +respect to the chosen input type and convention (i.e., the expected column order, keys, +or column names). This tutorial focus on how to adjust the display of the beachballs. """ # %% @@ -59,8 +57,8 @@ # :class:`pandas.DataFrame` column names. The ``scale`` parameter controls the radius # of the beachball. By default, the value defines the size for a magnitude of 5 (i.e., # a scalar seismic moment of :math:`M_0 = 4.0 \times 10^{23}` dyn cm) and the beachball -# size is proportional to the magnitude. Appand ``"+l"`` to force the radius -# to be proportional to the seismic moment. +# size is proportional to the magnitude. Appand ``"+l"`` to force the radius to be +# proportional to the seismic moment. fig = pygmt.Figure() fig.basemap(region=region, projection=projection, frame=frame) @@ -167,11 +165,11 @@ # Highlighting the nodal planes # ----------------------------- # -# Use the parameter ``nodal``, whereby ``"0"`` refers to both, ``"1"`` to the first, -# and ``"2"`` to the second nodal plane(s). Only the circumference and the specified -# nodal plane(s) are plotted, i.e. the quadrants remain unfilled (transparent). If -# needed, make usage of the stacking concept of (Py)GMT and use ``nodal`` with the -# ``outline`` or / and ``pen`` parameters in combination. +# Use the parameter ``nodal``, whereby ``"0"`` refers to both, ``"1"`` to the first, and +# ``"2"`` to the second nodal plane(s). Only the circumference and the specified nodal +# plane(s) are plotted, i.e. the quadrants remain unfilled (transparent). If needed, +# make usage of the stacking concept of (Py)GMT and use ``nodal`` with the ``outline`` +# or / and ``pen`` parameters in combination. fig = pygmt.Figure() fig.basemap(region=region, projection=projection, frame=frame) @@ -223,8 +221,8 @@ # is an ASCII file with columns for ``plot_longitude`` and ``plot_latitude`` the # ``offset`` parameter has to be set to ``True``. Besides just drawing a line between # the beachball and the event location, a small circle can be plotted at the event -# location by appending **+s** and the descired circle diameter. The connecting line -# as well as the outline of the circle are plotted with the setting of pen, or can be +# location by appending **+s** and the descired circle diameter. The connecting line as +# well as the outline of the circle are plotted with the setting of pen, or can be # adjusted separately. The fill of the small circle corresponds to the fill of the # compressive quadrantes. @@ -295,8 +293,8 @@ # **+f** and the desired font (size,name,color) to the argument passed to the ``scale`` # parameter. Additionally, the location of the label relative to the beachball [Default # is ``"TC"``, i.e., Top Center]; can be changed by appending **+j** and an offset can -# be applied by appending **+o** with values for *dx*\ /*dy*. Add a colored [Default -# is white] box behind the label via the label ``labelbox``. Force a fixed size of the +# be applied by appending **+o** with values for *dx*\ /*dy*. Add a colored [Default is +# white] box behind the label via the label ``labelbox``. Force a fixed size of the # beachball by appending **+m** to the argument passed to the ``scale`` parameter. fig = pygmt.Figure() From e37421a03a45731d9c7561f38d9d351ee6cc1deb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 18 Mar 2025 21:58:53 +0100 Subject: [PATCH 099/105] Use for loop and dicts Co-authored-by: Dongdong Tian --- .../tutorials/advanced/focal_mechanisms.py | 41 +++++++------------ 1 file changed, 14 insertions(+), 27 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 0bb143571a5..75b7c6c096f 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -183,33 +183,20 @@ nodal="0/1p,black", ) -fig.meca( - spec=aki_single, - scale="1c", - longitude=2, - latitude=0, - depth=0, - compressionfill="lightorange", - outline="0.5p,black", -) -fig.meca( - spec=aki_single, - scale="1c", - longitude=2, - latitude=0, - depth=0, - nodal="1/1p,darkorange", -) -fig.meca( - spec=aki_single, - scale="1c", - longitude=2, - latitude=0, - depth=0, - compressionfill="white@100", - extensionfill="white@100", - pen="1p,gray30", -) +# Plot the same beachball three times with different settings. +for kwargs in [ + {"compressionfill": "lightorange", "outline": "0.5p,black"}, + {"nodal": "1/1p,darkorange"}, + {"compressionfill": "-", "extensionfill": "-", "pen": "1p,gray30"}, +]: + fig.meca( + spec=aki_single, + scale="1c", + longitude=0, + latitude=0, + depth=0, + **kwargs, + ) fig.show() From 14b31b44a4b73aa37a5494b28ebca86019055618 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 20 Mar 2025 22:39:44 +0100 Subject: [PATCH 100/105] Fix code style --- examples/tutorials/advanced/focal_mechanisms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 75b7c6c096f..08b2a3ffbb5 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -188,7 +188,7 @@ {"compressionfill": "lightorange", "outline": "0.5p,black"}, {"nodal": "1/1p,darkorange"}, {"compressionfill": "-", "extensionfill": "-", "pen": "1p,gray30"}, -]: +]: fig.meca( spec=aki_single, scale="1c", From 4a87d237fca34cb31e48b12fe0b2a1d4ee3c37dd Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 22 Mar 2025 17:11:36 +0100 Subject: [PATCH 101/105] Improve docs --- .../tutorials/advanced/focal_mechanisms.py | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 08b2a3ffbb5..c540c5c9370 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -4,14 +4,15 @@ Focal mechanisms can be plotted as beachballs with the :meth:`pygmt.Figure.meca` method. -The focal mechanism data or parameters can be provided as different input types: an -ASCII file, 1-D or 2-D :class:`numpy.array`, dictionary, :class:`pandas.Dataframe`. -Different conventions to define the focal mechanism are supported: Aki and Richards -(``"aki"``), global CMT (``"gcmt"``), moment tensor (``"mt"``), partial focal mechanism -(``"partial"``), and, principal axis (``"principal_axis"``). Please refer to the -documentation of :meth:`pygmt.Figure.meca` regarding how to set up the input data in -respect to the chosen input type and convention (i.e., the expected column order, keys, -or column names). This tutorial focus on how to adjust the display of the beachballs. +The focal mechanism data or parameters can be provided as various input types: ASCII +file, :class:`numpy.array`, dictionary, or :class:`pandas.Dataframe`. Different +conventions to define the focal mechanism are supported: Aki and Richards (``"aki"``), +global CMT (``"gcmt"``), moment tensor (``"mt"``), partial focal mechanism +(``"partial"``), and, principal axis (``"principal_axis"``). Please refer to the table +in the documentation of :meth:`pygmt.Figure.meca` regarding how to set up the input data +in respect to the chosen input type and convention (i.e., the expected column order, +keys, or column names). This tutorial we focus on how to adjust the display of the +beachballs. """ # %% @@ -28,8 +29,8 @@ # Set up the focal mechanism data # ------------------------------- # -# Here we store focal mechanism parameters (in moment tensor and Aki & Richards -# conventions) for one event in a dictionary: +# We store focal mechanism parameters for two single events in a dictionary using the +# moment tensor and Aki and Richards conventions: # moment tensor convention mt_single = { From 6f449fe77692090433e2d381b658a97f98dc1ce5 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 22 Mar 2025 17:33:02 +0100 Subject: [PATCH 102/105] Improve docs --- .../tutorials/advanced/focal_mechanisms.py | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index c540c5c9370..62900bde7df 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -26,10 +26,10 @@ # %% -# Set up the focal mechanism data -# ------------------------------- +# Setting up the focal mechanism data +# ----------------------------------- # -# We store focal mechanism parameters for two single events in a dictionary using the +# We store focal mechanism parameters for two single events in dictionaries using the # moment tensor and Aki and Richards conventions: # moment tensor convention @@ -135,7 +135,7 @@ # ---------------------- # # Use the parameters ``pen`` and ``outline`` for adjusting the circumference of the -# beachball or all lines (circumference of the beachball and both nodal planes). +# beachball or all lines (i.e, circumference and both nodal planes). fig = pygmt.Figure() fig.basemap(region=region, projection=projection, frame=frame) @@ -166,11 +166,12 @@ # Highlighting the nodal planes # ----------------------------- # -# Use the parameter ``nodal``, whereby ``"0"`` refers to both, ``"1"`` to the first, and -# ``"2"`` to the second nodal plane(s). Only the circumference and the specified nodal -# plane(s) are plotted, i.e. the quadrants remain unfilled (transparent). If needed, -# make usage of the stacking concept of (Py)GMT and use ``nodal`` with the ``outline`` -# or / and ``pen`` parameters in combination. +# Use the parameter ``nodal`` to highlight specific nodal planes. ``"0"`` refers to +# both, ``"1"`` to the first, and ``"2"`` to the second nodal plane(s). Only the +# circumference and the specified nodal plane(s) are plotted, i.e. the quadrants +# remain unfilled (transparent). We can make usage of the stacking concept of (Py)GMT, +# and use ``nodal`` in combination with the ``outline``, ``compressionfill`` / +# ``extensionfill`` and ``pen`` parameters. fig = pygmt.Figure() fig.basemap(region=region, projection=projection, frame=frame) @@ -184,9 +185,12 @@ nodal="0/1p,black", ) -# Plot the same beachball three times with different settings. +# Plot the same beachball three times with different settings: +# (i) Fill the compressiv quadrants +# (ii) Plot the first nodal plane and the circumference in darkorange +# (iii) Plot the circumfence in black on top; use "-" to not fill the quadrants for kwargs in [ - {"compressionfill": "lightorange", "outline": "0.5p,black"}, + {"compressionfill": "lightorange"}, {"nodal": "1/1p,darkorange"}, {"compressionfill": "-", "extensionfill": "-", "pen": "1p,gray30"}, ]: From 93712b23462632b58893a9bcea3d60a76d0669bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sat, 22 Mar 2025 17:47:39 +0100 Subject: [PATCH 103/105] Use equal space between beachballs Co-authored-by: Dongdong Tian --- examples/tutorials/advanced/focal_mechanisms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 62900bde7df..624a13461be 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -81,7 +81,7 @@ fig = pygmt.Figure() fig.basemap(region=region, projection=projection, frame=frame) -for component, longitude in zip(["full", "dc", "deviatoric"], [-3, 0, 2], strict=True): +for component, longitude in zip(["full", "dc", "deviatoric"], [-2, 0, 2], strict=True): fig.meca( spec=mt_single, scale="1c", From 44895901a718ea2e3481ffcd14bf07e930beee8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sun, 23 Mar 2025 15:18:21 +0100 Subject: [PATCH 104/105] Fix typos Co-authored-by: Dongdong Tian --- examples/tutorials/advanced/focal_mechanisms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 624a13461be..435199b8283 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -58,7 +58,7 @@ # :class:`pandas.DataFrame` column names. The ``scale`` parameter controls the radius # of the beachball. By default, the value defines the size for a magnitude of 5 (i.e., # a scalar seismic moment of :math:`M_0 = 4.0 \times 10^{23}` dyn cm) and the beachball -# size is proportional to the magnitude. Appand ``"+l"`` to force the radius to be +# size is proportional to the magnitude. Append ``"+l"`` to force the radius to be # proportional to the seismic moment. fig = pygmt.Figure() @@ -186,7 +186,7 @@ ) # Plot the same beachball three times with different settings: -# (i) Fill the compressiv quadrants +# (i) Fill the compressive quadrants # (ii) Plot the first nodal plane and the circumference in darkorange # (iii) Plot the circumfence in black on top; use "-" to not fill the quadrants for kwargs in [ From 7e529073b9b0460437a75502cd241ee2960ba155 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Mon, 24 Mar 2025 11:33:40 +0100 Subject: [PATCH 105/105] Fix a lot of typos Co-authored-by: Michael Grund <23025878+michaelgrund@users.noreply.github.com> --- examples/tutorials/advanced/focal_mechanisms.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/tutorials/advanced/focal_mechanisms.py b/examples/tutorials/advanced/focal_mechanisms.py index 435199b8283..b44286b6397 100644 --- a/examples/tutorials/advanced/focal_mechanisms.py +++ b/examples/tutorials/advanced/focal_mechanisms.py @@ -11,7 +11,7 @@ (``"partial"``), and, principal axis (``"principal_axis"``). Please refer to the table in the documentation of :meth:`pygmt.Figure.meca` regarding how to set up the input data in respect to the chosen input type and convention (i.e., the expected column order, -keys, or column names). This tutorial we focus on how to adjust the display of the +keys, or column names). In this tutorial we focus on how to adjust the display of the beachballs. """ @@ -52,7 +52,7 @@ # # Required parameters are ``spec`` and ``scale`` as well as ``longitude``, ``latitude`` # (event location), and depth (if these values are not included in the argument passed -# to ``spec``). Additionally the ``convention`` parameter is required if ``spec`` is +# to ``spec``). Additionally, the ``convention`` parameter is required if ``spec`` is # an 1-D or 2-D numpy array; for the input types dictionary and ``pandas.Dataframe``, # the focal mechanism convention is automatically determined from dictionary keys or # :class:`pandas.DataFrame` column names. The ``scale`` parameter controls the radius @@ -169,9 +169,9 @@ # Use the parameter ``nodal`` to highlight specific nodal planes. ``"0"`` refers to # both, ``"1"`` to the first, and ``"2"`` to the second nodal plane(s). Only the # circumference and the specified nodal plane(s) are plotted, i.e. the quadrants -# remain unfilled (transparent). We can make usage of the stacking concept of (Py)GMT, +# remain unfilled (transparent). We can make use of the stacking concept of (Py)GMT, # and use ``nodal`` in combination with the ``outline``, ``compressionfill`` / -# ``extensionfill`` and ``pen`` parameters. +# ``extensionfill`` and ``pen`` parameters. fig = pygmt.Figure() fig.basemap(region=region, projection=projection, frame=frame) @@ -210,7 +210,7 @@ # --------------------------------- # # Specify the optional parameters ``plot_longitude`` and ``plot_latitude``. If ``spec`` -# is an ASCII file with columns for ``plot_longitude`` and ``plot_latitude`` the +# is an ASCII file with columns for ``plot_longitude`` and ``plot_latitude``, the # ``offset`` parameter has to be set to ``True``. Besides just drawing a line between # the beachball and the event location, a small circle can be plotted at the event # location by appending **+s** and the descired circle diameter. The connecting line as @@ -281,10 +281,10 @@ # -------------- # # Use the optional parameter ``event_name`` to add a label near the beachball, e.g., -# event name or event date and time. Change the font of the the label text by appending +# event name or event date and time. Change the font of the label text by appending # **+f** and the desired font (size,name,color) to the argument passed to the ``scale`` # parameter. Additionally, the location of the label relative to the beachball [Default -# is ``"TC"``, i.e., Top Center]; can be changed by appending **+j** and an offset can +# is ``"TC"``, i.e., Top Center] can be changed by appending **+j** and an offset can # be applied by appending **+o** with values for *dx*\ /*dy*. Add a colored [Default is # white] box behind the label via the label ``labelbox``. Force a fixed size of the # beachball by appending **+m** to the argument passed to the ``scale`` parameter.