From 679ccf9aedb334b5e2310988ed68b3638abfe894 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 24 Apr 2023 08:26:45 +0200 Subject: [PATCH 01/45] Add basic code --- examples/gallery/images/track.py | 99 ++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100755 examples/gallery/images/track.py diff --git a/examples/gallery/images/track.py b/examples/gallery/images/track.py new file mode 100755 index 00000000000..6c3ee5e0843 --- /dev/null +++ b/examples/gallery/images/track.py @@ -0,0 +1,99 @@ +r""" +Title +===== +TODO + +""" + +import pygmt + + +region_map = [122, 149, 30, 49] + +fig = pygmt.Figure() + +#----------------------------------------------------------------------------- +fig.basemap( + region=region_map, + projection="M12c", + frame="af", +) + +grid_map = pygmt.datasets.load_earth_relief( + resolution="10m", + region=region_map, +) + +fig.grdimage(grid=grid_map, cmap="oleron") + +fig.plot( + x=[126, 146], + y=[42, 40], + pen="2p,red,--", +) + +fig.text( + x=[126, 146], + y=[42, 40], + text=["A", "B"], + offset="0c/0.2c", + font="15p", +) + +fig.colorbar( + position="jBR+o0.7c/0.8c+h+w5c/0.3c+ml", + box="+gwhite@30+p0.8p,black", + frame=["x+lElevation", "y+lm"], +) + +#----------------------------------------------------------------------------- +fig.shift_origin(yshift="12.5c") + +fig.basemap( + region=[0, 15, -8000, 6000], + projection="X12/3c", + frame=["WSrt", "xa2f1+lDistance+u@.", "ya4000+lElevation / m"], +) + +fig.text( + x=[0, 15], + y=[7000, 7000], + text=["A", "B"], + no_clip=True, + font="10p", +) + +track_df = pygmt.project( + center="126/42", + endpoint="146/40", + generate="0.1", +) + +grid_track = pygmt.datasets.load_earth_relief( + resolution="04m", + region=region_map, +) + +track_df = pygmt.grdtrack( + grid=grid_track, + points=track_df, + newcolname="elevation", +) + +fig.plot( + x=[0, 15], + y=[0, 0], + fill="lightblue", + pen="0.25p,black,solid", + close="+y-8000", +) + +fig.plot( + data=track_df, + fill="gray", + pen="1p,black,solid", + close="+y-8000", + incols=[2, 3], +) + +fig.show() From 588eec821278f6fa08530b082076f415d94e11ff Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 24 Apr 2023 08:58:33 +0200 Subject: [PATCH 02/45] Add introduction --- examples/gallery/images/track.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/examples/gallery/images/track.py b/examples/gallery/images/track.py index 6c3ee5e0843..2fb6b9c2461 100755 --- a/examples/gallery/images/track.py +++ b/examples/gallery/images/track.py @@ -1,18 +1,25 @@ r""" -Title -===== +Cross-section along a transect +============================== +:func:`pygmt.project` and :func:`pygmt.grdtrack` can be used to estimate +a quantity along a track. +In this example, the elevation is extracted from a gird provided via +:func:`pygmt.datasets.load_earth_relief`. + +*The example is orientated on +https://docs.gmt-china.org/latest/examples/ex026/.* TODO - """ import pygmt - region_map = [122, 149, 30, 49] fig = pygmt.Figure() -#----------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- +# Bottom: Map + fig.basemap( region=region_map, projection="M12c", @@ -46,7 +53,9 @@ frame=["x+lElevation", "y+lm"], ) -#----------------------------------------------------------------------------- +# ---------------------------------------------------------------------------- +# Top: Profil + fig.shift_origin(yshift="12.5c") fig.basemap( From 86ee2fb782f0cd065d4e73eb286cded5bf43646e Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 24 Apr 2023 09:42:09 +0200 Subject: [PATCH 03/45] Add first comments to code --- examples/gallery/images/track.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/examples/gallery/images/track.py b/examples/gallery/images/track.py index 2fb6b9c2461..a2bf1648340 100755 --- a/examples/gallery/images/track.py +++ b/examples/gallery/images/track.py @@ -13,8 +13,10 @@ import pygmt +# Define region of study area region_map = [122, 149, 30, 49] +# Create a new instance or object of the pygmt.Figure() class fig = pygmt.Figure() # ---------------------------------------------------------------------------- @@ -22,23 +24,29 @@ fig.basemap( region=region_map, - projection="M12c", + projection="M12c", # Mercator projection with a width of 12 centimeters frame="af", ) +# Download grid for Earth relief with a resolution of 10 arc-minutes and +# gridline registration [Default] grid_map = pygmt.datasets.load_earth_relief( resolution="10m", region=region_map, ) +# Plot the downloaded grid with color-coding for the elevation fig.grdimage(grid=grid_map, cmap="oleron") +# Choose a track fig.plot( - x=[126, 146], - y=[42, 40], - pen="2p,red,--", + x=[126, 146], # Longitude in degrees East + y=[42, 40], # Latitude in degrees North + # Draw a 2-points thick red dashed line for the track + pen="2p,red,dashed", ) +# Add labels for start and end points of the track fig.text( x=[126, 146], y=[42, 40], @@ -47,6 +55,7 @@ font="15p", ) +# Add a colorbar for the elevation fig.colorbar( position="jBR+o0.7c/0.8c+h+w5c/0.3c+ml", box="+gwhite@30+p0.8p,black", @@ -54,16 +63,20 @@ ) # ---------------------------------------------------------------------------- -# Top: Profil +# Top: Track +# Shift plot origin 12.5 centimeters to the right fig.shift_origin(yshift="12.5c") fig.basemap( region=[0, 15, -8000, 6000], + # Carthesian projection with a width of 12 centimeters and + # a height of 3 centimeters projection="X12/3c", frame=["WSrt", "xa2f1+lDistance+u@.", "ya4000+lElevation / m"], ) +# Add labels for start and end points of the track fig.text( x=[0, 15], y=[7000, 7000], @@ -72,23 +85,28 @@ font="10p", ) +# Calculate track track_df = pygmt.project( center="126/42", endpoint="146/40", generate="0.1", ) +# Download grid for Earth relief with a resolution of 4 arc-minutes and +# gridline registration [Default] grid_track = pygmt.datasets.load_earth_relief( resolution="04m", region=region_map, ) +# Extract elevation from downloaded grid along calculated track track_df = pygmt.grdtrack( grid=grid_track, points=track_df, newcolname="elevation", ) +# Plot water masses fig.plot( x=[0, 15], y=[0, 0], @@ -97,6 +115,7 @@ close="+y-8000", ) +# Plot elevation along track fig.plot( data=track_df, fill="gray", From 8807d26aea85dadc32ea4fede74a543a8306f1b3 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 24 Apr 2023 10:00:57 +0200 Subject: [PATCH 04/45] Replace tabs by four spaces --- examples/gallery/images/track.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gallery/images/track.py b/examples/gallery/images/track.py index a2bf1648340..379a67ce5cd 100755 --- a/examples/gallery/images/track.py +++ b/examples/gallery/images/track.py @@ -42,7 +42,7 @@ fig.plot( x=[126, 146], # Longitude in degrees East y=[42, 40], # Latitude in degrees North - # Draw a 2-points thick red dashed line for the track + # Draw a 2-points thick red dashed line for the track pen="2p,red,dashed", ) @@ -70,7 +70,7 @@ fig.basemap( region=[0, 15, -8000, 6000], - # Carthesian projection with a width of 12 centimeters and + # Carthesian projection with a width of 12 centimeters and # a height of 3 centimeters projection="X12/3c", frame=["WSrt", "xa2f1+lDistance+u@.", "ya4000+lElevation / m"], From 02e3a44148e2c24018d816b6c9035266cbfa4308 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 24 Apr 2023 10:04:01 +0200 Subject: [PATCH 05/45] Rename 'track.py' -> 'cross_section.py' --- examples/gallery/images/{track.py => cross_section.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/gallery/images/{track.py => cross_section.py} (100%) diff --git a/examples/gallery/images/track.py b/examples/gallery/images/cross_section.py similarity index 100% rename from examples/gallery/images/track.py rename to examples/gallery/images/cross_section.py From 50fdb7626fca58795b9dcfc897fb85bd375ff894 Mon Sep 17 00:00:00 2001 From: actions-bot <58130806+actions-bot@users.noreply.github.com> Date: Mon, 24 Apr 2023 08:09:19 +0000 Subject: [PATCH 06/45] [format-command] fixes --- examples/gallery/images/cross_section.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/images/cross_section.py diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py old mode 100755 new mode 100644 From 9f82ebce8ccd14c1199f671ef24c7e7ec992c4ec Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 24 Apr 2023 11:26:25 +0200 Subject: [PATCH 07/45] Add more comments to code --- examples/gallery/images/cross_section.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index 379a67ce5cd..f78d712a02c 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -65,7 +65,7 @@ # ---------------------------------------------------------------------------- # Top: Track -# Shift plot origin 12.5 centimeters to the right +# Shift plot origin 12.5 centimeters to the top fig.shift_origin(yshift="12.5c") fig.basemap( @@ -81,11 +81,11 @@ x=[0, 15], y=[7000, 7000], text=["A", "B"], - no_clip=True, - font="10p", + no_clip=True, # Do not clip text that fall outside of the plot bounds + font="10p", # Use a font size of 10 points ) -# Calculate track +# Set up track and store it in a DataFrame track_df = pygmt.project( center="126/42", endpoint="146/40", @@ -99,7 +99,8 @@ region=region_map, ) -# Extract elevation from downloaded grid along calculated track +# Extract the elevation along the defined track from the downloaded grid +# and add it as new column "elevation" to the DataFrame track_df = pygmt.grdtrack( grid=grid_track, points=track_df, @@ -110,18 +111,20 @@ fig.plot( x=[0, 15], y=[0, 0], - fill="lightblue", + fill="lightblue", # Fill the polygon in "lightblue" + # Draw a 0.25-points thick black solid outline pen="0.25p,black,solid", - close="+y-8000", + close="+y-8000", # Close to polygon ) # Plot elevation along track fig.plot( data=track_df, - fill="gray", + fill="gray", # Fill the polygon in "gray" + # Draw a 1-point thick black solid outline pen="1p,black,solid", - close="+y-8000", - incols=[2, 3], + close="+y-8000", # Close to polygon + incols=[2, 3], # Select order of input columns (zero-based indexing) ) fig.show() From 9ca69d22701e63698289f5503f3c189ffd8ecb32 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 24 Apr 2023 11:48:50 +0200 Subject: [PATCH 08/45] Replace tabs by four spaces --- examples/gallery/images/cross_section.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index f78d712a02c..b4af4e4bb33 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -112,7 +112,7 @@ x=[0, 15], y=[0, 0], fill="lightblue", # Fill the polygon in "lightblue" - # Draw a 0.25-points thick black solid outline + # Draw a 0.25-points thick black solid outline pen="0.25p,black,solid", close="+y-8000", # Close to polygon ) @@ -121,7 +121,7 @@ fig.plot( data=track_df, fill="gray", # Fill the polygon in "gray" - # Draw a 1-point thick black solid outline + # Draw a 1-point thick black solid outline pen="1p,black,solid", close="+y-8000", # Close to polygon incols=[2, 3], # Select order of input columns (zero-based indexing) From 1ec8745da9ba0c181edff138fd5bf446ed635f5f Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 24 Apr 2023 14:24:25 +0200 Subject: [PATCH 09/45] Fix typo --- examples/gallery/images/cross_section.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index b4af4e4bb33..2fece3504eb 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -123,7 +123,7 @@ fill="gray", # Fill the polygon in "gray" # Draw a 1-point thick black solid outline pen="1p,black,solid", - close="+y-8000", # Close to polygon + close="+y-8000", # Close the polygon incols=[2, 3], # Select order of input columns (zero-based indexing) ) From a7573af843d99a9d9a965a18522ad6676e94a71d Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Mon, 24 Apr 2023 14:34:52 +0200 Subject: [PATCH 10/45] Improve formulation --- examples/gallery/images/cross_section.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index 2fece3504eb..5ca0e897e77 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -114,7 +114,7 @@ fill="lightblue", # Fill the polygon in "lightblue" # Draw a 0.25-points thick black solid outline pen="0.25p,black,solid", - close="+y-8000", # Close to polygon + close="+y-8000", # Force closed polygon ) # Plot elevation along track @@ -123,7 +123,7 @@ fill="gray", # Fill the polygon in "gray" # Draw a 1-point thick black solid outline pen="1p,black,solid", - close="+y-8000", # Close the polygon + close="+y-8000", # Force closed polygon incols=[2, 3], # Select order of input columns (zero-based indexing) ) From b88416787fe597aeb703c03433cb6956ec9489d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 2 May 2023 22:51:24 +0200 Subject: [PATCH 11/45] Improve formulation of reference to GMT/China docs --- examples/gallery/images/cross_section.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index 5ca0e897e77..8a58d4c426b 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -6,9 +6,10 @@ In this example, the elevation is extracted from a gird provided via :func:`pygmt.datasets.load_earth_relief`. -*The example is orientated on -https://docs.gmt-china.org/latest/examples/ex026/.* TODO + +*This example is orientated on an example in the GMT/China documentation*: +https://docs.gmt-china.org/latest/examples/ex026/ """ import pygmt From 68ec8739aa326eb1851a5b4738579a7917843e1c Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Tue, 2 May 2023 22:54:37 +0200 Subject: [PATCH 12/45] Remove trailing white space --- examples/gallery/images/cross_section.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index 8a58d4c426b..23fec38a1f1 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -8,7 +8,7 @@ TODO -*This example is orientated on an example in the GMT/China documentation*: +*This example is orientated on an example in the GMT/China documentation*: https://docs.gmt-china.org/latest/examples/ex026/ """ From 209cfb71db1f1aaa6cb7b17de58f0ac05f4d61f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Wed, 3 May 2023 15:05:13 +0200 Subject: [PATCH 13/45] Reduce resolution temporarly --- examples/gallery/images/cross_section.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index 23fec38a1f1..fe6e030d93a 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -96,7 +96,7 @@ # Download grid for Earth relief with a resolution of 4 arc-minutes and # gridline registration [Default] grid_track = pygmt.datasets.load_earth_relief( - resolution="04m", + resolution="10m", region=region_map, ) From dbf4e82cafc208a8640780283f6f979f4ac7b735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sun, 7 May 2023 21:26:07 +0200 Subject: [PATCH 14/45] Remove 'r' at the beginning of the docstrings --- examples/gallery/images/cross_section.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index fe6e030d93a..a570a53a4ce 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -1,4 +1,4 @@ -r""" +""" Cross-section along a transect ============================== :func:`pygmt.project` and :func:`pygmt.grdtrack` can be used to estimate From f2f84290312efd8785d75e417b4224603e82d9a7 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 7 May 2023 21:44:19 +0200 Subject: [PATCH 15/45] Improve comments --- examples/gallery/images/cross_section.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index a570a53a4ce..fc448749877 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -86,7 +86,7 @@ font="10p", # Use a font size of 10 points ) -# Set up track and store it in a DataFrame +# Set up track and store it in a pandas.DataFrame track_df = pygmt.project( center="126/42", endpoint="146/40", @@ -101,7 +101,7 @@ ) # Extract the elevation along the defined track from the downloaded grid -# and add it as new column "elevation" to the DataFrame +# and add it as new column "elevation" to the pandas.DataFrame track_df = pygmt.grdtrack( grid=grid_track, points=track_df, From 1a2dc75a73976a22f57121d1d4743948c2478d9e Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 7 May 2023 21:45:07 +0200 Subject: [PATCH 16/45] Adjust comments temporaly --- examples/gallery/images/cross_section.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index fc448749877..05a0aa4ca9f 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -93,7 +93,7 @@ generate="0.1", ) -# Download grid for Earth relief with a resolution of 4 arc-minutes and +# Download grid for Earth relief with a resolution of 10 arc-minutes and # gridline registration [Default] grid_track = pygmt.datasets.load_earth_relief( resolution="10m", From 321ca298e8b7d8bdcad8ead8adb5753942b0614a Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 7 May 2023 21:47:08 +0200 Subject: [PATCH 17/45] Improve comments --- examples/gallery/images/cross_section.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index 05a0aa4ca9f..be29493fc29 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -21,7 +21,7 @@ fig = pygmt.Figure() # ---------------------------------------------------------------------------- -# Bottom: Map +# Bottom: Map of elevation in study area fig.basemap( region=region_map, @@ -64,7 +64,7 @@ ) # ---------------------------------------------------------------------------- -# Top: Track +# Top: Elevation along track # Shift plot origin 12.5 centimeters to the top fig.shift_origin(yshift="12.5c") From 387eb872ea62f96b009cd1e57d3869baa3917d6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sun, 14 May 2023 23:56:24 +0200 Subject: [PATCH 18/45] Improve comment for track labels --- examples/gallery/images/cross_section.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index be29493fc29..b3357f0e7f8 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -47,7 +47,7 @@ pen="2p,red,dashed", ) -# Add labels for start and end points of the track +# Add labels "A" and "B" for the start and end points of the track, respectively fig.text( x=[126, 146], y=[42, 40], From 03aacf2e84dcd191dd8281a5cb793082f11bb5e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Sun, 14 May 2023 23:56:40 +0200 Subject: [PATCH 19/45] Improve comment for track labels --- examples/gallery/images/cross_section.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index b3357f0e7f8..3739dacaac7 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -77,7 +77,7 @@ frame=["WSrt", "xa2f1+lDistance+u@.", "ya4000+lElevation / m"], ) -# Add labels for start and end points of the track +# Add labels "A" and "B" for the start and end points of the track, respectively fig.text( x=[0, 15], y=[7000, 7000], From 84a766c7d970bcad9c137d8c63d5bd518599e9f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Mon, 15 May 2023 00:04:58 +0200 Subject: [PATCH 20/45] Fix line length - shorten comment --- examples/gallery/images/cross_section.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index 3739dacaac7..cff5cacb931 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -47,7 +47,7 @@ pen="2p,red,dashed", ) -# Add labels "A" and "B" for the start and end points of the track, respectively +# Add labels "A" and "B" for the start and end points of the track fig.text( x=[126, 146], y=[42, 40], From ad23ec9f1a71a7ed4ae72679b042dd580a39ee2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Mon, 15 May 2023 00:05:11 +0200 Subject: [PATCH 21/45] Fix line length - shorten comment --- examples/gallery/images/cross_section.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index cff5cacb931..d2dbea8712a 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -77,7 +77,7 @@ frame=["WSrt", "xa2f1+lDistance+u@.", "ya4000+lElevation / m"], ) -# Add labels "A" and "B" for the start and end points of the track, respectively +# Add labels "A" and "B" for the start and end points of the track fig.text( x=[0, 15], y=[7000, 7000], From f9bccb837096dd371c34e667f4712321b3197200 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 11 Jun 2023 14:37:58 +0200 Subject: [PATCH 22/45] Expand introduction and comments --- examples/gallery/images/cross_section.py | 55 +++++++++++++++--------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index d2dbea8712a..a9345d10a0b 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -1,12 +1,13 @@ """ Cross-section along a transect ============================== -:func:`pygmt.project` and :func:`pygmt.grdtrack` can be used to estimate -a quantity along a track. +:func:`pygmt.project` and :func:`pygmt.grdtrack` can be used to focus on +a quantity and its variation along a desired survey line. In this example, the elevation is extracted from a gird provided via :func:`pygmt.datasets.load_earth_relief`. - -TODO +The figure consists of the two parts, a map of the elevation in the study +area showing the survey line and a Cartesian plot showing the elevation +along the survey line. *This example is orientated on an example in the GMT/China documentation*: https://docs.gmt-china.org/latest/examples/ex026/ @@ -15,6 +16,7 @@ import pygmt # Define region of study area +# lon_min, lon_max, lat_min, lat_max in degrees East and North region_map = [122, 149, 30, 49] # Create a new instance or object of the pygmt.Figure() class @@ -23,6 +25,7 @@ # ---------------------------------------------------------------------------- # Bottom: Map of elevation in study area +# Set up basic map fig.basemap( region=region_map, projection="M12c", # Mercator projection with a width of 12 centimeters @@ -36,48 +39,57 @@ region=region_map, ) -# Plot the downloaded grid with color-coding for the elevation +# Plot the downloaded grid with color-coding based on the elevation fig.grdimage(grid=grid_map, cmap="oleron") -# Choose a track +# Choose a survey line fig.plot( x=[126, 146], # Longitude in degrees East y=[42, 40], # Latitude in degrees North - # Draw a 2-points thick red dashed line for the track + # Draw a 2-points thick red dashed line for the survey line pen="2p,red,dashed", ) -# Add labels "A" and "B" for the start and end points of the track +# Add labels "A" and "B" for the start and end points of the survey line fig.text( x=[126, 146], y=[42, 40], text=["A", "B"], - offset="0c/0.2c", - font="15p", + offset="0c/0.2c", # Move text 0.2 centimeters up (y direction) + font="15p", # Use a font size of 15 points ) # Add a colorbar for the elevation fig.colorbar( + # Place colorbar inside the plot (lower-case "j") with justification + # Bottom Right and an offset (+o) of 0.7 centimeters and 0.3 centimeters + # in x and y directions, respectively + # Move the x label above the horizontal colorbar ("+ml") position="jBR+o0.7c/0.8c+h+w5c/0.3c+ml", + # Add a box around the colobar with a white fill ("+g") with a + # transparency ("@) of 30 % and a 0.8-points thick black solid outline box="+gwhite@30+p0.8p,black", + # Add x and y labels ("+l") frame=["x+lElevation", "y+lm"], ) # ---------------------------------------------------------------------------- -# Top: Elevation along track +# Top: Elevation along survey line # Shift plot origin 12.5 centimeters to the top fig.shift_origin(yshift="12.5c") fig.basemap( - region=[0, 15, -8000, 6000], - # Carthesian projection with a width of 12 centimeters and + region=[0, 15, -8000, 6000], # x_min, x_max, y_min, y_max + # Cartesian projection with a width of 12 centimeters and # a height of 3 centimeters - projection="X12/3c", + projection="X12c/3c", + # Add annodations ("a") and ticks ("f") as well as labels ("+l") + # at the west or left and south or bottom sides ("WSrt") frame=["WSrt", "xa2f1+lDistance+u@.", "ya4000+lElevation / m"], ) -# Add labels "A" and "B" for the start and end points of the track +# Add labels "A" and "B" for the start and end points of the survey line fig.text( x=[0, 15], y=[7000, 7000], @@ -86,11 +98,12 @@ font="10p", # Use a font size of 10 points ) -# Set up track and store it in a pandas.DataFrame +# Generate points along a great circle corresponding the survey line +# and store them in a pandas.DataFrame track_df = pygmt.project( - center="126/42", - endpoint="146/40", - generate="0.1", + center="126/42", # Start point of survey line (longitude/latitude) + endpoint="146/40", # End point of survey line (longitude/latitude) + generate="0.1", # Output data in steps of 0.1 degrees ) # Download grid for Earth relief with a resolution of 10 arc-minutes and @@ -100,7 +113,7 @@ region=region_map, ) -# Extract the elevation along the defined track from the downloaded grid +# Extract the elevation at the generated points from the downloaded grid # and add it as new column "elevation" to the pandas.DataFrame track_df = pygmt.grdtrack( grid=grid_track, @@ -118,7 +131,7 @@ close="+y-8000", # Force closed polygon ) -# Plot elevation along track +# Plot elevation along the survey line fig.plot( data=track_df, fill="gray", # Fill the polygon in "gray" From d102f7db4e9c51f21d0bca3484e5cd4d916dddef Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 11 Jun 2023 16:06:47 +0200 Subject: [PATCH 23/45] Improve comment --- examples/gallery/images/cross_section.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index a9345d10a0b..c10ff357e10 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -62,12 +62,12 @@ # Add a colorbar for the elevation fig.colorbar( # Place colorbar inside the plot (lower-case "j") with justification - # Bottom Right and an offset (+o) of 0.7 centimeters and 0.3 centimeters - # in x and y directions, respectively + # Bottom Right and an offset ("+o") of 0.7 centimeters and + # 0.3 centimeters in x or y directions, respectively # Move the x label above the horizontal colorbar ("+ml") position="jBR+o0.7c/0.8c+h+w5c/0.3c+ml", - # Add a box around the colobar with a white fill ("+g") with a - # transparency ("@) of 30 % and a 0.8-points thick black solid outline + # Add a box around the colobar with a fill ("+g") in "white" color and + # a transparency ("@") of 30 % and a 0.8-points thick black outline ("+p") box="+gwhite@30+p0.8p,black", # Add x and y labels ("+l") frame=["x+lElevation", "y+lm"], From 51f637390eb086f1ddd26c0b65ccc407119f3d13 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 18 Jun 2023 15:43:34 +0200 Subject: [PATCH 24/45] Fix typo --- examples/gallery/images/cross_section.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index c10ff357e10..5a5541d7186 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -84,7 +84,7 @@ # Cartesian projection with a width of 12 centimeters and # a height of 3 centimeters projection="X12c/3c", - # Add annodations ("a") and ticks ("f") as well as labels ("+l") + # Add annotations ("a") and ticks ("f") as well as labels ("+l") # at the west or left and south or bottom sides ("WSrt") frame=["WSrt", "xa2f1+lDistance+u@.", "ya4000+lElevation / m"], ) From f909f1955db4fdd9b57868cd9e88d2afd3a152d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Thu, 22 Jun 2023 17:56:07 +0200 Subject: [PATCH 25/45] Fix typo introduction (code review) Co-authored-by: Michael Grund <23025878+michaelgrund@users.noreply.github.com> --- examples/gallery/images/cross_section.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index 5a5541d7186..1fc5e3183a4 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -3,7 +3,7 @@ ============================== :func:`pygmt.project` and :func:`pygmt.grdtrack` can be used to focus on a quantity and its variation along a desired survey line. -In this example, the elevation is extracted from a gird provided via +In this example, the elevation is extracted from a grid provided via :func:`pygmt.datasets.load_earth_relief`. The figure consists of the two parts, a map of the elevation in the study area showing the survey line and a Cartesian plot showing the elevation From 1f4000249e27b9f67dd3f9155b4bf8c3c0f36c5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Thu, 22 Jun 2023 17:56:43 +0200 Subject: [PATCH 26/45] Shorten comment (code review) Co-authored-by: Dongdong Tian --- examples/gallery/images/cross_section.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index 1fc5e3183a4..3188890fbf8 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -19,7 +19,7 @@ # lon_min, lon_max, lat_min, lat_max in degrees East and North region_map = [122, 149, 30, 49] -# Create a new instance or object of the pygmt.Figure() class +# Create a new pygmt.Figure instance fig = pygmt.Figure() # ---------------------------------------------------------------------------- From c40401bb1e9d278140c6c9261053401fbce2092a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Thu, 22 Jun 2023 17:57:36 +0200 Subject: [PATCH 27/45] Remove not required word (code review) Co-authored-by: Michael Grund <23025878+michaelgrund@users.noreply.github.com> --- examples/gallery/images/cross_section.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index 3188890fbf8..5c3f06e16d7 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -5,7 +5,7 @@ a quantity and its variation along a desired survey line. In this example, the elevation is extracted from a grid provided via :func:`pygmt.datasets.load_earth_relief`. -The figure consists of the two parts, a map of the elevation in the study +The figure consists of two parts, a map of the elevation in the study area showing the survey line and a Cartesian plot showing the elevation along the survey line. From e6f716d95f0cadf40282e86fbfbcdd2102091e13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Thu, 22 Jun 2023 17:58:17 +0200 Subject: [PATCH 28/45] Add missing word (code review) Co-authored-by: Michael Grund <23025878+michaelgrund@users.noreply.github.com> --- examples/gallery/images/cross_section.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index 5c3f06e16d7..390c591db6a 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -98,7 +98,7 @@ font="10p", # Use a font size of 10 points ) -# Generate points along a great circle corresponding the survey line +# Generate points along a great circle corresponding to the survey line # and store them in a pandas.DataFrame track_df = pygmt.project( center="126/42", # Start point of survey line (longitude/latitude) From 70727e558b29426b22b569e0e4f75b49f493988d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Thu, 22 Jun 2023 18:01:07 +0200 Subject: [PATCH 29/45] Remove not required word (code review) Co-authored-by: Michael Grund <23025878+michaelgrund@users.noreply.github.com> --- examples/gallery/images/cross_section.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index 390c591db6a..f469e051249 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -94,7 +94,7 @@ x=[0, 15], y=[7000, 7000], text=["A", "B"], - no_clip=True, # Do not clip text that fall outside of the plot bounds + no_clip=True, # Do not clip text that fall outside the plot bounds font="10p", # Use a font size of 10 points ) From b0735aeeca21980d62cb52073c4a76b2754402bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Thu, 22 Jun 2023 18:15:49 +0200 Subject: [PATCH 30/45] Remove colorbar (code review) Co-authored-by: Dongdong Tian --- examples/gallery/images/cross_section.py | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index f469e051249..bce153a2cb4 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -59,20 +59,6 @@ font="15p", # Use a font size of 15 points ) -# Add a colorbar for the elevation -fig.colorbar( - # Place colorbar inside the plot (lower-case "j") with justification - # Bottom Right and an offset ("+o") of 0.7 centimeters and - # 0.3 centimeters in x or y directions, respectively - # Move the x label above the horizontal colorbar ("+ml") - position="jBR+o0.7c/0.8c+h+w5c/0.3c+ml", - # Add a box around the colobar with a fill ("+g") in "white" color and - # a transparency ("@") of 30 % and a 0.8-points thick black outline ("+p") - box="+gwhite@30+p0.8p,black", - # Add x and y labels ("+l") - frame=["x+lElevation", "y+lm"], -) - # ---------------------------------------------------------------------------- # Top: Elevation along survey line From 992bd0c71d714196a286fd516bed06c3a96d8bd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Thu, 22 Jun 2023 18:16:43 +0200 Subject: [PATCH 31/45] Add colorbar immediately after grdimage (code review) Co-authored-by: Dongdong Tian --- examples/gallery/images/cross_section.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index bce153a2cb4..443bf8f4d92 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -42,6 +42,20 @@ # Plot the downloaded grid with color-coding based on the elevation fig.grdimage(grid=grid_map, cmap="oleron") +# Add a colorbar for the elevation +fig.colorbar( + # Place colorbar inside the plot (lower-case "j") with justification + # Bottom Right and an offset ("+o") of 0.7 centimeters and + # 0.3 centimeters in x or y directions, respectively + # Move the x label above the horizontal colorbar ("+ml") + position="jBR+o0.7c/0.8c+h+w5c/0.3c+ml", + # Add a box around the colobar with a fill ("+g") in "white" color and + # a transparency ("@") of 30 % and a 0.8-points thick black outline ("+p") + box="+gwhite@30+p0.8p,black", + # Add x and y labels ("+l") + frame=["x+lElevation", "y+lm"], +) + # Choose a survey line fig.plot( x=[126, 146], # Longitude in degrees East From 116171b3c34bf9b5862ba365b5a0d093fa50c6a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Thu, 22 Jun 2023 23:12:12 +0200 Subject: [PATCH 32/45] Download grid only once (code review) Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- examples/gallery/images/cross_section.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index 443bf8f4d92..7c3c6bafa0d 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -106,17 +106,10 @@ generate="0.1", # Output data in steps of 0.1 degrees ) -# Download grid for Earth relief with a resolution of 10 arc-minutes and -# gridline registration [Default] -grid_track = pygmt.datasets.load_earth_relief( - resolution="10m", - region=region_map, -) - # Extract the elevation at the generated points from the downloaded grid # and add it as new column "elevation" to the pandas.DataFrame track_df = pygmt.grdtrack( - grid=grid_track, + grid=grid_map, points=track_df, newcolname="elevation", ) From 5e4a497581ba2183b44bdbcc036e98b244d89025 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Thu, 22 Jun 2023 23:42:49 +0200 Subject: [PATCH 33/45] Improve formulation for comment for colorbar argument --- examples/gallery/images/cross_section.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index 7c3c6bafa0d..18e526b5ae9 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -44,13 +44,14 @@ # Add a colorbar for the elevation fig.colorbar( - # Place colorbar inside the plot (lower-case "j") with justification + # Place the colorbar inside the plot (lower-case "j") with justification # Bottom Right and an offset ("+o") of 0.7 centimeters and # 0.3 centimeters in x or y directions, respectively # Move the x label above the horizontal colorbar ("+ml") position="jBR+o0.7c/0.8c+h+w5c/0.3c+ml", # Add a box around the colobar with a fill ("+g") in "white" color and - # a transparency ("@") of 30 % and a 0.8-points thick black outline ("+p") + # a transparency ("@") of 30 % and with a 0.8-points thick black + # outline ("+p") box="+gwhite@30+p0.8p,black", # Add x and y labels ("+l") frame=["x+lElevation", "y+lm"], From f791a080225b5e3cc1307c36abc465aa575d9da0 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Fri, 23 Jun 2023 06:57:35 +0200 Subject: [PATCH 34/45] Reduce step size of survey line --- examples/gallery/images/cross_section.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index 18e526b5ae9..56b53d6cc08 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -104,7 +104,7 @@ track_df = pygmt.project( center="126/42", # Start point of survey line (longitude/latitude) endpoint="146/40", # End point of survey line (longitude/latitude) - generate="0.1", # Output data in steps of 0.1 degrees + generate="0.5", # Output data in steps of 0.1 degrees ) # Extract the elevation at the generated points from the downloaded grid From b142510a73ba3e0022e27565c00d7a7a6ddb94a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Fri, 23 Jun 2023 09:50:24 +0200 Subject: [PATCH 35/45] Update als comment to larger step size along survey line Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- examples/gallery/images/cross_section.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index 56b53d6cc08..dff1ebad4b8 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -104,7 +104,7 @@ track_df = pygmt.project( center="126/42", # Start point of survey line (longitude/latitude) endpoint="146/40", # End point of survey line (longitude/latitude) - generate="0.5", # Output data in steps of 0.1 degrees + generate="0.5", # Output data in steps of 0.5 degrees ) # Extract the elevation at the generated points from the downloaded grid From 0cc6b9e75700fa2d820b741fa3d2de6972deb1b9 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 24 Jun 2023 08:05:38 +0200 Subject: [PATCH 36/45] Comment code parts related to 'pygmt.grdtrack' out --- examples/gallery/images/cross_section.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index dff1ebad4b8..089e0a11c63 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -106,7 +106,7 @@ endpoint="146/40", # End point of survey line (longitude/latitude) generate="0.5", # Output data in steps of 0.5 degrees ) - +""" # Extract the elevation at the generated points from the downloaded grid # and add it as new column "elevation" to the pandas.DataFrame track_df = pygmt.grdtrack( @@ -114,7 +114,7 @@ points=track_df, newcolname="elevation", ) - +""" # Plot water masses fig.plot( x=[0, 15], @@ -124,7 +124,7 @@ pen="0.25p,black,solid", close="+y-8000", # Force closed polygon ) - +""" # Plot elevation along the survey line fig.plot( data=track_df, @@ -134,5 +134,5 @@ close="+y-8000", # Force closed polygon incols=[2, 3], # Select order of input columns (zero-based indexing) ) - +""" fig.show() From 68bc2fd1d4e9c3e65832a5540d90ddc77daee801 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 24 Jun 2023 18:57:04 +0200 Subject: [PATCH 37/45] Fix code style for comments --- examples/gallery/images/cross_section.py | 34 ++++++++++++------------ 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index 089e0a11c63..7f693124152 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -106,15 +106,15 @@ endpoint="146/40", # End point of survey line (longitude/latitude) generate="0.5", # Output data in steps of 0.5 degrees ) -""" + # Extract the elevation at the generated points from the downloaded grid # and add it as new column "elevation" to the pandas.DataFrame -track_df = pygmt.grdtrack( - grid=grid_map, - points=track_df, - newcolname="elevation", -) -""" +# track_df = pygmt.grdtrack( +# grid=grid_map, +# points=track_df, +# newcolname="elevation", +# ) + # Plot water masses fig.plot( x=[0, 15], @@ -124,15 +124,15 @@ pen="0.25p,black,solid", close="+y-8000", # Force closed polygon ) -""" + # Plot elevation along the survey line -fig.plot( - data=track_df, - fill="gray", # Fill the polygon in "gray" - # Draw a 1-point thick black solid outline - pen="1p,black,solid", - close="+y-8000", # Force closed polygon - incols=[2, 3], # Select order of input columns (zero-based indexing) -) -""" +# fig.plot( +# data=track_df, +# fill="gray", # Fill the polygon in "gray" +# # Draw a 1-point thick black solid outline +# pen="1p,black,solid", +# close="+y-8000", # Force closed polygon +# incols=[2, 3], # Select order of input columns (zero-based indexing) +# ) + fig.show() From a467834c1f697bd6500274a0d861fe20ab1179f9 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 24 Jun 2023 18:57:49 +0200 Subject: [PATCH 38/45] Revert step size increase for survey line --- examples/gallery/images/cross_section.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index 7f693124152..4eb77326db0 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -104,7 +104,7 @@ track_df = pygmt.project( center="126/42", # Start point of survey line (longitude/latitude) endpoint="146/40", # End point of survey line (longitude/latitude) - generate="0.5", # Output data in steps of 0.5 degrees + generate="0.1", # Output data in steps of 0.1 degrees ) # Extract the elevation at the generated points from the downloaded grid From 63b71ab2d4d045a1f8bfbcdda662aecaf76eec24 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 19 Aug 2023 23:06:20 +0200 Subject: [PATCH 39/45] Un-comment only calculation of 'track_df' via 'grdtrack' --- examples/gallery/images/cross_section.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index 4eb77326db0..fede0ce1e0e 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -109,11 +109,11 @@ # Extract the elevation at the generated points from the downloaded grid # and add it as new column "elevation" to the pandas.DataFrame -# track_df = pygmt.grdtrack( -# grid=grid_map, -# points=track_df, -# newcolname="elevation", -# ) +track_df = pygmt.grdtrack( + grid=grid_map, + points=track_df, + newcolname="elevation", +) # Plot water masses fig.plot( From a9f2e5d8489804b553ed22d14420d080ce57b1fb Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 19 Aug 2023 23:27:06 +0200 Subject: [PATCH 40/45] Un-comment plotting 'track_df' via 'data' and 'incols' --- examples/gallery/images/cross_section.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index fede0ce1e0e..18e526b5ae9 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -126,13 +126,13 @@ ) # Plot elevation along the survey line -# fig.plot( -# data=track_df, -# fill="gray", # Fill the polygon in "gray" -# # Draw a 1-point thick black solid outline -# pen="1p,black,solid", -# close="+y-8000", # Force closed polygon -# incols=[2, 3], # Select order of input columns (zero-based indexing) -# ) +fig.plot( + data=track_df, + fill="gray", # Fill the polygon in "gray" + # Draw a 1-point thick black solid outline + pen="1p,black,solid", + close="+y-8000", # Force closed polygon + incols=[2, 3], # Select order of input columns (zero-based indexing) +) fig.show() From c25a7781b1dff8fc84c8f1489318a5a6c0eea0c6 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sat, 19 Aug 2023 23:29:38 +0200 Subject: [PATCH 41/45] Test plotting 'track_df' via 'x' and 'y' --- examples/gallery/images/cross_section.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index 18e526b5ae9..38e4d6b88de 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -127,12 +127,12 @@ # Plot elevation along the survey line fig.plot( - data=track_df, + x=track_df.p, + y=track_df.elevation, fill="gray", # Fill the polygon in "gray" # Draw a 1-point thick black solid outline pen="1p,black,solid", close="+y-8000", # Force closed polygon - incols=[2, 3], # Select order of input columns (zero-based indexing) ) fig.show() From ab5d52bbafcfbb9d730b0b60a79eddc40520ca6c Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 20 Aug 2023 16:11:49 +0200 Subject: [PATCH 42/45] Test using 'int' with 'data' and 'incols' --- examples/gallery/images/cross_section.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index 38e4d6b88de..e7c213c9a4b 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -127,12 +127,14 @@ # Plot elevation along the survey line fig.plot( - x=track_df.p, - y=track_df.elevation, + data=track_df.astype(int), + # x=track_df.p, + # y=track_df.elevation, fill="gray", # Fill the polygon in "gray" # Draw a 1-point thick black solid outline pen="1p,black,solid", close="+y-8000", # Force closed polygon + incols=[2, 3], ) fig.show() From 5fb3e49a8141616d360d7b48069046a6492046b4 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 20 Aug 2023 16:32:06 +0200 Subject: [PATCH 43/45] Test using 'float' with 'data' and 'incols' --- examples/gallery/images/cross_section.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index e7c213c9a4b..26acaa45f08 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -127,7 +127,7 @@ # Plot elevation along the survey line fig.plot( - data=track_df.astype(int), + data=track_df.astype(float), # x=track_df.p, # y=track_df.elevation, fill="gray", # Fill the polygon in "gray" From b666712b77c7d05c0d1ddb4e1e381c530d7ec467 Mon Sep 17 00:00:00 2001 From: yvonnefroelich Date: Sun, 20 Aug 2023 16:46:35 +0200 Subject: [PATCH 44/45] Redo test changes and use 'x' and 'y' --- examples/gallery/images/cross_section.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index 26acaa45f08..38e4d6b88de 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -127,14 +127,12 @@ # Plot elevation along the survey line fig.plot( - data=track_df.astype(float), - # x=track_df.p, - # y=track_df.elevation, + x=track_df.p, + y=track_df.elevation, fill="gray", # Fill the polygon in "gray" # Draw a 1-point thick black solid outline pen="1p,black,solid", close="+y-8000", # Force closed polygon - incols=[2, 3], ) fig.show() From 765f2fd5b6605a2bfddb7acd11eb3e45b7211fcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Mon, 21 Aug 2023 20:13:57 +0200 Subject: [PATCH 45/45] =?UTF-8?q?Use=20'+u=C2=B0'=20instead=20of=20'+u@.'?= =?UTF-8?q?=20=20following=20PR=20#2584?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Dongdong Tian --- examples/gallery/images/cross_section.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/images/cross_section.py b/examples/gallery/images/cross_section.py index 38e4d6b88de..27c24c01410 100644 --- a/examples/gallery/images/cross_section.py +++ b/examples/gallery/images/cross_section.py @@ -87,7 +87,7 @@ projection="X12c/3c", # Add annotations ("a") and ticks ("f") as well as labels ("+l") # at the west or left and south or bottom sides ("WSrt") - frame=["WSrt", "xa2f1+lDistance+u@.", "ya4000+lElevation / m"], + frame=["WSrt", "xa2f1+lDistance+u°", "ya4000+lElevation / m"], ) # Add labels "A" and "B" for the start and end points of the survey line