From 58e2ed608ec45a712d1eb53432f48e720a2e7e84 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Fri, 7 Jan 2022 18:09:03 +0100 Subject: [PATCH 1/8] Create gallery example showing the usage of project --- examples/gallery/lines/great_circles | 40 ++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 examples/gallery/lines/great_circles diff --git a/examples/gallery/lines/great_circles b/examples/gallery/lines/great_circles new file mode 100644 index 00000000000..d029abf0359 --- /dev/null +++ b/examples/gallery/lines/great_circles @@ -0,0 +1,40 @@ +""" +Generate points great circles +----------------------------- + +The :meth:`pygmt.project` method can generate points along a great circle +whose center and end points can be defined via the ``center`` and ``endpoint`` +parameters, respectively. +""" + +import pygmt + +fig = pygmt.Figure() + +# generate points every 10 degrees along a great circle from 10N,50W to 30N,5W +points1 = pygmt.project(center = "-50/10", endpoint = "-5/30", generate = 10) +# generate points every 750 km along a great circle from 10N,50W to 57.5N,90W +points2 = pygmt.project(center = "-50/10", endpoint = "-90/57.5", generate = 750, unit = True) +# generate points every 350 km along a great circle from 10N,50W to 68N,5W +points3 = pygmt.project(center = "-50/10", endpoint = "-5/68", generate = 350, unit = True) + +# create a plot with coast and Mercator projection (M) +fig.basemap(region=[-100, 0, 0, 70], projection="M12c", frame=True) +fig.coast(shorelines = True) + +# plot individual points of first great circle as seagreen line +fig.plot(x=points1.r, y= points1.s, pen="2p,seagreen") +# plot individual points as seagreen squares atop +fig.plot(x=points1.r, y= points1.s, style="s.45c", color="seagreen", pen="1p") + +# plot individual points of second great circle as orange line +fig.plot(x=points2.r, y= points2.s, pen="2p,orange") +# plot individual points as orange inverted triangles atop +fig.plot(x=points2.r, y= points2.s, style="i.6c", color="orange", pen="1p") + +# plot individual points of third great circle as red line +fig.plot(x=points3.r, y= points3.s, pen="2p,red3") +# plot individual points as red circles atop +fig.plot(x=points3.r, y= points3.s, style="c.3c", color="red3", pen="1p") + +fig.show() From 55fea9456e08c8db0544a943ccfc9cc9e71f7209 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Fri, 7 Jan 2022 18:54:53 +0100 Subject: [PATCH 2/8] update --- examples/gallery/lines/{great_circles => great_circles.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/gallery/lines/{great_circles => great_circles.py} (100%) diff --git a/examples/gallery/lines/great_circles b/examples/gallery/lines/great_circles.py similarity index 100% rename from examples/gallery/lines/great_circles rename to examples/gallery/lines/great_circles.py From 2a6a0a969b0f36008a92fbdef45470c28f00c25c Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Fri, 7 Jan 2022 18:55:40 +0100 Subject: [PATCH 3/8] formatting --- examples/gallery/lines/great_circles.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/gallery/lines/great_circles.py b/examples/gallery/lines/great_circles.py index d029abf0359..5852f913d65 100644 --- a/examples/gallery/lines/great_circles.py +++ b/examples/gallery/lines/great_circles.py @@ -12,29 +12,29 @@ fig = pygmt.Figure() # generate points every 10 degrees along a great circle from 10N,50W to 30N,5W -points1 = pygmt.project(center = "-50/10", endpoint = "-5/30", generate = 10) +points1 = pygmt.project(center="-50/10", endpoint="-5/30", generate=10) # generate points every 750 km along a great circle from 10N,50W to 57.5N,90W -points2 = pygmt.project(center = "-50/10", endpoint = "-90/57.5", generate = 750, unit = True) +points2 = pygmt.project(center="-50/10", endpoint="-90/57.5", generate=750, unit=True) # generate points every 350 km along a great circle from 10N,50W to 68N,5W -points3 = pygmt.project(center = "-50/10", endpoint = "-5/68", generate = 350, unit = True) +points3 = pygmt.project(center="-50/10", endpoint="-5/68", generate=350, unit=True) -# create a plot with coast and Mercator projection (M) +# create a plot with coast and Mercator projection (M) fig.basemap(region=[-100, 0, 0, 70], projection="M12c", frame=True) -fig.coast(shorelines = True) +fig.coast(shorelines=True) # plot individual points of first great circle as seagreen line -fig.plot(x=points1.r, y= points1.s, pen="2p,seagreen") +fig.plot(x=points1.r, y=points1.s, pen="2p,seagreen") # plot individual points as seagreen squares atop -fig.plot(x=points1.r, y= points1.s, style="s.45c", color="seagreen", pen="1p") +fig.plot(x=points1.r, y=points1.s, style="s.45c", color="seagreen", pen="1p") # plot individual points of second great circle as orange line -fig.plot(x=points2.r, y= points2.s, pen="2p,orange") +fig.plot(x=points2.r, y=points2.s, pen="2p,orange") # plot individual points as orange inverted triangles atop -fig.plot(x=points2.r, y= points2.s, style="i.6c", color="orange", pen="1p") +fig.plot(x=points2.r, y=points2.s, style="i.6c", color="orange", pen="1p") # plot individual points of third great circle as red line -fig.plot(x=points3.r, y= points3.s, pen="2p,red3") +fig.plot(x=points3.r, y=points3.s, pen="2p,red3") # plot individual points as red circles atop -fig.plot(x=points3.r, y= points3.s, style="c.3c", color="red3", pen="1p") +fig.plot(x=points3.r, y=points3.s, style="c.3c", color="red3", pen="1p") fig.show() From 27ec38b81fe4fba7c264da2f767978ffc57e880d Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Fri, 7 Jan 2022 18:57:35 +0100 Subject: [PATCH 4/8] formatting --- examples/gallery/lines/great_circles.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/gallery/lines/great_circles.py b/examples/gallery/lines/great_circles.py index 5852f913d65..c8a8a89f71a 100644 --- a/examples/gallery/lines/great_circles.py +++ b/examples/gallery/lines/great_circles.py @@ -2,9 +2,9 @@ Generate points great circles ----------------------------- -The :meth:`pygmt.project` method can generate points along a great circle -whose center and end points can be defined via the ``center`` and ``endpoint`` -parameters, respectively. +The :meth:`pygmt.project` method can generate points along a great circle +whose center and end points can be defined via the ``center`` and ``endpoint`` +parameters, respectively. """ import pygmt From f70948b47357faa470de85ea0672258a034a2aa3 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Fri, 7 Jan 2022 19:15:01 +0100 Subject: [PATCH 5/8] update title --- examples/gallery/lines/great_circles.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gallery/lines/great_circles.py b/examples/gallery/lines/great_circles.py index c8a8a89f71a..602be670828 100644 --- a/examples/gallery/lines/great_circles.py +++ b/examples/gallery/lines/great_circles.py @@ -1,6 +1,6 @@ """ -Generate points great circles ------------------------------ +Generate points along great circles +----------------------------------- The :meth:`pygmt.project` method can generate points along a great circle whose center and end points can be defined via the ``center`` and ``endpoint`` From b97a5f633bcc4341b7eece3b9e49da89dd094e52 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Sun, 9 Jan 2022 17:37:56 +0100 Subject: [PATCH 6/8] Apply suggestions from code review Co-authored-by: Dongdong Tian --- examples/gallery/lines/great_circles.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/gallery/lines/great_circles.py b/examples/gallery/lines/great_circles.py index 602be670828..df10c2af23e 100644 --- a/examples/gallery/lines/great_circles.py +++ b/examples/gallery/lines/great_circles.py @@ -12,11 +12,11 @@ fig = pygmt.Figure() # generate points every 10 degrees along a great circle from 10N,50W to 30N,5W -points1 = pygmt.project(center="-50/10", endpoint="-5/30", generate=10) +points1 = pygmt.project(center=[-50, 10], endpoint=[-5, 30], generate=10) # generate points every 750 km along a great circle from 10N,50W to 57.5N,90W -points2 = pygmt.project(center="-50/10", endpoint="-90/57.5", generate=750, unit=True) +points2 = pygmt.project(center=[-50, 10], endpoint=[-90, 57.5], generate=750, unit=True) # generate points every 350 km along a great circle from 10N,50W to 68N,5W -points3 = pygmt.project(center="-50/10", endpoint="-5/68", generate=350, unit=True) +points3 = pygmt.project(center=[-50, 10], endpoint=[-5, 68], generate=350, unit=True) # create a plot with coast and Mercator projection (M) fig.basemap(region=[-100, 0, 0, 70], projection="M12c", frame=True) From 7c722a3b4ddc55c7152b5f5fda9f501d196232d2 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Mon, 10 Jan 2022 08:53:03 +0100 Subject: [PATCH 7/8] Update examples/gallery/lines/great_circles.py Co-authored-by: Dongdong Tian --- examples/gallery/lines/great_circles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/lines/great_circles.py b/examples/gallery/lines/great_circles.py index df10c2af23e..1f2701b0014 100644 --- a/examples/gallery/lines/great_circles.py +++ b/examples/gallery/lines/great_circles.py @@ -20,7 +20,7 @@ # create a plot with coast and Mercator projection (M) fig.basemap(region=[-100, 0, 0, 70], projection="M12c", frame=True) -fig.coast(shorelines=True) +fig.coast(shorelines=True, area_thresh=5000) # plot individual points of first great circle as seagreen line fig.plot(x=points1.r, y=points1.s, pen="2p,seagreen") From 3eb7004ebf641cd02988326f1db6b420b48f8b36 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Mon, 10 Jan 2022 18:22:17 +0100 Subject: [PATCH 8/8] update docstring --- examples/gallery/lines/great_circles.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/gallery/lines/great_circles.py b/examples/gallery/lines/great_circles.py index 1f2701b0014..f3c30b787d3 100644 --- a/examples/gallery/lines/great_circles.py +++ b/examples/gallery/lines/great_circles.py @@ -4,7 +4,10 @@ The :meth:`pygmt.project` method can generate points along a great circle whose center and end points can be defined via the ``center`` and ``endpoint`` -parameters, respectively. +parameters, respectively. Using the ``generate`` parameter allows to generate +(*r*, *s*, *p*) points every *dist* units of *p* along a profile as +output. By default all units (*r*, *s* and *p*) are set to degrees while +``unit=True`` allows to set the unit for *p* to km. """ import pygmt