From 9a031b20eb53a4d1c13370054304329f18db8baa Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 29 May 2023 20:43:09 +0200 Subject: [PATCH 01/61] 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 02/61] 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 03/61] [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 04/61] 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 05/61] 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 06/61] 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 07/61] 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 08/61] 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 09/61] 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 10/61] 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 11/61] 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 12/61] 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 13/61] 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 14/61] 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 15/61] 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 16/61] 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 17/61] 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 18/61] 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 19/61] 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 20/61] 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 21/61] 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 22/61] 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 23/61] 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 24/61] 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 25/61] 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 26/61] 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 27/61] 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 28/61] [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 29/61] 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 30/61] 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 31/61] 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 32/61] 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 33/61] 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 34/61] 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 35/61] 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 36/61] 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 37/61] 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 38/61] 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 39/61] 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 40/61] 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 41/61] 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 42/61] 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 43/61] 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 44/61] 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 45/61] 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 46/61] 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 47/61] 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 48/61] 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 49/61] 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 50/61] 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 51/61] 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 52/61] 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 53/61] 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 54/61] 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 55/61] 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 56/61] 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 57/61] 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 58/61] 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 59/61] 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 60/61] 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 61/61] 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