From d25d89040ef4b3666b95cb8a9861458e03db9cc3 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Mon, 9 Aug 2021 07:31:33 +0200 Subject: [PATCH 01/16] Update/add grdlandmask parameters and aliases --- pygmt/src/grdlandmask.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pygmt/src/grdlandmask.py b/pygmt/src/grdlandmask.py index 1da363dc2fe..0994b78a3fe 100644 --- a/pygmt/src/grdlandmask.py +++ b/pygmt/src/grdlandmask.py @@ -19,6 +19,8 @@ G="outgrid", I="spacing", R="region", + N="mask_geog", + D="resolution" V="verbose", r="registration", ) From 1ba89d2812115cdf51d8e9e6f718b21395ce89b2 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Mon, 9 Aug 2021 07:38:04 +0200 Subject: [PATCH 02/16] formatting --- pygmt/src/grdlandmask.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/grdlandmask.py b/pygmt/src/grdlandmask.py index 0994b78a3fe..80307ff6f8c 100644 --- a/pygmt/src/grdlandmask.py +++ b/pygmt/src/grdlandmask.py @@ -20,7 +20,7 @@ I="spacing", R="region", N="mask_geog", - D="resolution" + D="resolution", V="verbose", r="registration", ) From de4b2f526b1d2205538371b036f8c582d923b96d Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Mon, 9 Aug 2021 17:20:23 +0200 Subject: [PATCH 03/16] update --- pygmt/src/grdlandmask.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pygmt/src/grdlandmask.py b/pygmt/src/grdlandmask.py index 80307ff6f8c..7999a61787a 100644 --- a/pygmt/src/grdlandmask.py +++ b/pygmt/src/grdlandmask.py @@ -19,8 +19,10 @@ G="outgrid", I="spacing", R="region", - N="mask_geog", + A="area_thresh", D="resolution", + E="bordervalues", + N="mask_geog", V="verbose", r="registration", ) @@ -47,6 +49,10 @@ def grdlandmask(**kwargs): in. {I} {R} + area_thresh: todo + resolution : todo + bordervalues : todo + mask_geog : todo {V} {r} From 2e033c54c128152d9626ef7333b80af62fec8a06 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Tue, 10 Aug 2021 23:36:10 +0200 Subject: [PATCH 04/16] add resolution parameter docstring --- pygmt/src/grdlandmask.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pygmt/src/grdlandmask.py b/pygmt/src/grdlandmask.py index 7999a61787a..3d5f9031de0 100644 --- a/pygmt/src/grdlandmask.py +++ b/pygmt/src/grdlandmask.py @@ -49,8 +49,18 @@ def grdlandmask(**kwargs): in. {I} {R} - area_thresh: todo - resolution : todo + {A} + resolution : str + res[**+f**]. Selects the resolution of the data set to use + ((**f**)ull, (**h**)igh, (**i**)ntermediate, (**l**)ow, or + (**c**)rude). The resolution drops off by ~80% between data sets. + [Default is **l**]. Append **+f** to automatically select a lower + resolution should the one requested not be available + [abort if not found]. Alternatively, choose (**a**)uto to automatically + select the best resolution given the chosen region. Note that because + the coastlines differ in details a node in a mask file using one + resolution is not guaranteed to remain inside [or outside] when a + different resolution is selected. bordervalues : todo mask_geog : todo {V} From 89789dd84711d7f90d7bee066621c8d7c51051d7 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Tue, 10 Aug 2021 23:45:44 +0200 Subject: [PATCH 05/16] add bordervalues parameter docstring --- pygmt/src/grdlandmask.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pygmt/src/grdlandmask.py b/pygmt/src/grdlandmask.py index 3d5f9031de0..9f569a7d36c 100644 --- a/pygmt/src/grdlandmask.py +++ b/pygmt/src/grdlandmask.py @@ -61,7 +61,19 @@ def grdlandmask(**kwargs): the coastlines differ in details a node in a mask file using one resolution is not guaranteed to remain inside [or outside] when a different resolution is selected. - bordervalues : todo + bordervalues : str or list + [values]. Nodes that fall exactly on a polygon boundary should be + considered to be outside the polygon [Default considers them to be + inside]. Alternatively, append either the four values *cborder*/ + *lborder*/*iborder*/*pborder* or just the single value *bordervalue* + (for the case when they should all be the same value). This turns on + the line-tracking mode. Now, after setting the mask values specified + via ``mask_geog``` we trace the lines and change the node values for + all cells traversed by a line to the corresponding border value. Here, + *cborder* is used for cells traversed by the coastline, *lborder* for + cells traversed by a lake outline, *iborder* for islands-in-lakes + outlines, and *pborder* for ponds-in-islands-in-lakes outlines + [Default is no line tracing]. mask_geog : todo {V} {r} From a49c3b29de14764b26e4cd4271a2b5afd5456786 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Tue, 10 Aug 2021 23:56:48 +0200 Subject: [PATCH 06/16] add maskvalues parameter docstring --- pygmt/src/grdlandmask.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/pygmt/src/grdlandmask.py b/pygmt/src/grdlandmask.py index 9f569a7d36c..f1b845288e7 100644 --- a/pygmt/src/grdlandmask.py +++ b/pygmt/src/grdlandmask.py @@ -22,7 +22,7 @@ A="area_thresh", D="resolution", E="bordervalues", - N="mask_geog", + N="maskvalues", V="verbose", r="registration", ) @@ -51,7 +51,7 @@ def grdlandmask(**kwargs): {R} {A} resolution : str - res[**+f**]. Selects the resolution of the data set to use + *res*[**+f**]. Selects the resolution of the data set to use ((**f**)ull, (**h**)igh, (**i**)ntermediate, (**l**)ow, or (**c**)rude). The resolution drops off by ~80% between data sets. [Default is **l**]. Append **+f** to automatically select a lower @@ -62,7 +62,7 @@ def grdlandmask(**kwargs): resolution is not guaranteed to remain inside [or outside] when a different resolution is selected. bordervalues : str or list - [values]. Nodes that fall exactly on a polygon boundary should be + [*values*]. Nodes that fall exactly on a polygon boundary should be considered to be outside the polygon [Default considers them to be inside]. Alternatively, append either the four values *cborder*/ *lborder*/*iborder*/*pborder* or just the single value *bordervalue* @@ -74,7 +74,19 @@ def grdlandmask(**kwargs): cells traversed by a lake outline, *iborder* for islands-in-lakes outlines, and *pborder* for ponds-in-islands-in-lakes outlines [Default is no line tracing]. - mask_geog : todo + maskvalues : str or list + *values*. Sets the values that will be assigned to nodes. Values can + be any number, including the textstring NaN. Also select + ``bordervalues``` to let nodes exactly on feature boundaries be + considered outside [Default is inside]. Specify this information + using 1 of 2 formats: + + -``maskvalues``*wet*/*dry*. + + -``maskvalues``*ocean*/*land*/*lake*/*island*/*pond*. + + [Default is 0/1/0/1/0 (i.e., 0/1)]. + {V} {r} From e4d71176bebd3ecd993bcac22cfef29a6eb759fd Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Wed, 11 Aug 2021 08:59:53 +0200 Subject: [PATCH 07/16] adjustments --- pygmt/src/grdlandmask.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/pygmt/src/grdlandmask.py b/pygmt/src/grdlandmask.py index f1b845288e7..ca1170c703e 100644 --- a/pygmt/src/grdlandmask.py +++ b/pygmt/src/grdlandmask.py @@ -51,7 +51,7 @@ def grdlandmask(**kwargs): {R} {A} resolution : str - *res*[**+f**]. Selects the resolution of the data set to use + *res*\[\ **+f**\]. Selects the resolution of the data set to use **f**\|\ **h**\|\ **i**\|\ **l**\|\ **c** ((**f**)ull, (**h**)igh, (**i**)ntermediate, (**l**)ow, or (**c**)rude). The resolution drops off by ~80% between data sets. [Default is **l**]. Append **+f** to automatically select a lower @@ -68,7 +68,7 @@ def grdlandmask(**kwargs): *lborder*/*iborder*/*pborder* or just the single value *bordervalue* (for the case when they should all be the same value). This turns on the line-tracking mode. Now, after setting the mask values specified - via ``mask_geog``` we trace the lines and change the node values for + via ``maskvalues`` we trace the lines and change the node values for all cells traversed by a line to the corresponding border value. Here, *cborder* is used for cells traversed by the coastline, *lborder* for cells traversed by a lake outline, *iborder* for islands-in-lakes @@ -77,16 +77,13 @@ def grdlandmask(**kwargs): maskvalues : str or list *values*. Sets the values that will be assigned to nodes. Values can be any number, including the textstring NaN. Also select - ``bordervalues``` to let nodes exactly on feature boundaries be + ``bordervalues`` to let nodes exactly on feature boundaries be considered outside [Default is inside]. Specify this information using 1 of 2 formats: - -``maskvalues``*wet*/*dry*. - - -``maskvalues``*ocean*/*land*/*lake*/*island*/*pond*. - + - \``maskvalues``\ *wet*/*dry*. + - \``maskvalues``\ *ocean*/*land*/*lake*/*island*/*pond*. [Default is 0/1/0/1/0 (i.e., 0/1)]. - {V} {r} From ae8373a4cb29dafe247785f62f0483efd2f7b01e Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Wed, 11 Aug 2021 17:21:04 +0200 Subject: [PATCH 08/16] Apply suggestions from code review Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- pygmt/src/grdlandmask.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pygmt/src/grdlandmask.py b/pygmt/src/grdlandmask.py index ca1170c703e..7ee4fd9c9b2 100644 --- a/pygmt/src/grdlandmask.py +++ b/pygmt/src/grdlandmask.py @@ -16,13 +16,13 @@ @fmt_docstring @use_alias( - G="outgrid", - I="spacing", - R="region", A="area_thresh", D="resolution", E="bordervalues", + G="outgrid", + I="spacing", N="maskvalues", + R="region", V="verbose", r="registration", ) @@ -51,7 +51,7 @@ def grdlandmask(**kwargs): {R} {A} resolution : str - *res*\[\ **+f**\]. Selects the resolution of the data set to use **f**\|\ **h**\|\ **i**\|\ **l**\|\ **c** + *res*\[\ **+f**\]. Selects the resolution of the data set to use ((**f**)ull, (**h**)igh, (**i**)ntermediate, (**l**)ow, or (**c**)rude). The resolution drops off by ~80% between data sets. [Default is **l**]. Append **+f** to automatically select a lower From 4a1eac6049db1b61d3cbc5c2c713054a580ede50 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Wed, 11 Aug 2021 17:25:01 +0200 Subject: [PATCH 09/16] adjust ordering in index.rst --- doc/api/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/index.rst b/doc/api/index.rst index 3536e83f640..a9bec80af88 100644 --- a/doc/api/index.rst +++ b/doc/api/index.rst @@ -92,8 +92,8 @@ Operations on grids: grdcut grdfill grdfilter - grdlandmask grdgradient + grdlandmask grdsample grdtrack xyz2grd From 1e76b813f6efcf406a62778d0f545e48dd076b73 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Wed, 11 Aug 2021 19:07:20 +0200 Subject: [PATCH 10/16] formatting --- pygmt/src/grdlandmask.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/grdlandmask.py b/pygmt/src/grdlandmask.py index 7ee4fd9c9b2..91cd412cecb 100644 --- a/pygmt/src/grdlandmask.py +++ b/pygmt/src/grdlandmask.py @@ -81,8 +81,8 @@ def grdlandmask(**kwargs): considered outside [Default is inside]. Specify this information using 1 of 2 formats: - - \``maskvalues``\ *wet*/*dry*. - - \``maskvalues``\ *ocean*/*land*/*lake*/*island*/*pond*. + - ``maskvalues`` \*wet*/*dry*. + - ``maskvalues`` \*ocean*/*land*/*lake*/*island*/*pond*. [Default is 0/1/0/1/0 (i.e., 0/1)]. {V} {r} From 6456fac8da5194cd9c7b7a5acfb7a9678d20f62f Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Fri, 13 Aug 2021 09:47:14 +0200 Subject: [PATCH 11/16] Apply suggestions from code review Co-authored-by: Dongdong Tian --- pygmt/src/grdlandmask.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pygmt/src/grdlandmask.py b/pygmt/src/grdlandmask.py index 91cd412cecb..b5d63b37b58 100644 --- a/pygmt/src/grdlandmask.py +++ b/pygmt/src/grdlandmask.py @@ -61,10 +61,10 @@ def grdlandmask(**kwargs): the coastlines differ in details a node in a mask file using one resolution is not guaranteed to remain inside [or outside] when a different resolution is selected. - bordervalues : str or list - [*values*]. Nodes that fall exactly on a polygon boundary should be + bordervalues : bool or str or list + Nodes that fall exactly on a polygon boundary should be considered to be outside the polygon [Default considers them to be - inside]. Alternatively, append either the four values *cborder*/ + inside]. Alternatively, append either the four values *cborder*/\ *lborder*/*iborder*/*pborder* or just the single value *bordervalue* (for the case when they should all be the same value). This turns on the line-tracking mode. Now, after setting the mask values specified @@ -79,10 +79,7 @@ def grdlandmask(**kwargs): be any number, including the textstring NaN. Also select ``bordervalues`` to let nodes exactly on feature boundaries be considered outside [Default is inside]. Specify this information - using 1 of 2 formats: - - - ``maskvalues`` \*wet*/*dry*. - - ``maskvalues`` \*ocean*/*land*/*lake*/*island*/*pond*. + using either *wet*/*dry* or *ocean*/*land*/*lake*/*island*/*pond*. [Default is 0/1/0/1/0 (i.e., 0/1)]. {V} {r} From 611975ebd143bfbf60ceec21e4a9390c0196c2d9 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Sun, 15 Aug 2021 14:10:05 +0200 Subject: [PATCH 12/16] updated kwargs_to_strings decorator --- pygmt/src/grdlandmask.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/grdlandmask.py b/pygmt/src/grdlandmask.py index b5d63b37b58..df59f501bb2 100644 --- a/pygmt/src/grdlandmask.py +++ b/pygmt/src/grdlandmask.py @@ -26,7 +26,7 @@ V="verbose", r="registration", ) -@kwargs_to_strings(R="sequence") +@kwargs_to_strings(R="sequence", N="sequence", E="sequence") def grdlandmask(**kwargs): r""" Create a grid file with set values for land and water. From 342efa71819ff4262c628324ab0dd529a99b7003 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Tue, 17 Aug 2021 14:12:42 +0200 Subject: [PATCH 13/16] Apply suggestions from code review Co-authored-by: Dongdong Tian --- pygmt/src/grdlandmask.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pygmt/src/grdlandmask.py b/pygmt/src/grdlandmask.py index df59f501bb2..7abdbc61b2b 100644 --- a/pygmt/src/grdlandmask.py +++ b/pygmt/src/grdlandmask.py @@ -61,11 +61,11 @@ def grdlandmask(**kwargs): the coastlines differ in details a node in a mask file using one resolution is not guaranteed to remain inside [or outside] when a different resolution is selected. - bordervalues : bool or str or list + bordervalues : bool or str or float or list Nodes that fall exactly on a polygon boundary should be considered to be outside the polygon [Default considers them to be - inside]. Alternatively, append either the four values *cborder*/\ - *lborder*/*iborder*/*pborder* or just the single value *bordervalue* + inside]. Alternatively, append either a list of four values + [*cborder*, *lborder*, *iborder*, *pborder*] or just the single value *bordervalue* (for the case when they should all be the same value). This turns on the line-tracking mode. Now, after setting the mask values specified via ``maskvalues`` we trace the lines and change the node values for @@ -75,12 +75,12 @@ def grdlandmask(**kwargs): outlines, and *pborder* for ponds-in-islands-in-lakes outlines [Default is no line tracing]. maskvalues : str or list - *values*. Sets the values that will be assigned to nodes. Values can - be any number, including the textstring NaN. Also select + [*wet*, *dry*] or [*ocean*, *land*, *lake*, *island*, *pond*]. + Sets the values that will be assigned to nodes. Values can + be any number, including the textstring NaN + [Default is 0/1/0/1/0 (i.e., 0/1)]. Also select ``bordervalues`` to let nodes exactly on feature boundaries be - considered outside [Default is inside]. Specify this information - using either *wet*/*dry* or *ocean*/*land*/*lake*/*island*/*pond*. - [Default is 0/1/0/1/0 (i.e., 0/1)]. + considered outside [Default is inside]. {V} {r} From f019a12bb090f3156443d1c203edcad7415a586f Mon Sep 17 00:00:00 2001 From: actions-bot <58130806+actions-bot@users.noreply.github.com> Date: Tue, 17 Aug 2021 12:20:16 +0000 Subject: [PATCH 14/16] [format-command] fixes --- pygmt/src/grdlandmask.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pygmt/src/grdlandmask.py b/pygmt/src/grdlandmask.py index 7abdbc61b2b..c28349dd4b1 100644 --- a/pygmt/src/grdlandmask.py +++ b/pygmt/src/grdlandmask.py @@ -64,7 +64,7 @@ def grdlandmask(**kwargs): bordervalues : bool or str or float or list Nodes that fall exactly on a polygon boundary should be considered to be outside the polygon [Default considers them to be - inside]. Alternatively, append either a list of four values + inside]. Alternatively, append either a list of four values [*cborder*, *lborder*, *iborder*, *pborder*] or just the single value *bordervalue* (for the case when they should all be the same value). This turns on the line-tracking mode. Now, after setting the mask values specified @@ -75,12 +75,12 @@ def grdlandmask(**kwargs): outlines, and *pborder* for ponds-in-islands-in-lakes outlines [Default is no line tracing]. maskvalues : str or list - [*wet*, *dry*] or [*ocean*, *land*, *lake*, *island*, *pond*]. + [*wet*, *dry*] or [*ocean*, *land*, *lake*, *island*, *pond*]. Sets the values that will be assigned to nodes. Values can - be any number, including the textstring NaN + be any number, including the textstring NaN [Default is 0/1/0/1/0 (i.e., 0/1)]. Also select ``bordervalues`` to let nodes exactly on feature boundaries be - considered outside [Default is inside]. + considered outside [Default is inside]. {V} {r} From 352f7658186c7ea1d2271771da775ee119329798 Mon Sep 17 00:00:00 2001 From: Michael Grund Date: Tue, 17 Aug 2021 17:33:44 +0200 Subject: [PATCH 15/16] formatting --- pygmt/src/grdlandmask.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pygmt/src/grdlandmask.py b/pygmt/src/grdlandmask.py index c28349dd4b1..6ceb22ba4ff 100644 --- a/pygmt/src/grdlandmask.py +++ b/pygmt/src/grdlandmask.py @@ -65,15 +65,15 @@ def grdlandmask(**kwargs): Nodes that fall exactly on a polygon boundary should be considered to be outside the polygon [Default considers them to be inside]. Alternatively, append either a list of four values - [*cborder*, *lborder*, *iborder*, *pborder*] or just the single value *bordervalue* - (for the case when they should all be the same value). This turns on - the line-tracking mode. Now, after setting the mask values specified - via ``maskvalues`` we trace the lines and change the node values for - all cells traversed by a line to the corresponding border value. Here, - *cborder* is used for cells traversed by the coastline, *lborder* for - cells traversed by a lake outline, *iborder* for islands-in-lakes - outlines, and *pborder* for ponds-in-islands-in-lakes outlines - [Default is no line tracing]. + [*cborder*, *lborder*, *iborder*, *pborder*] or just the single value + *bordervalue* (for the case when they should all be the same value). + This turns on the line-tracking mode. Now, after setting the mask + values specified via ``maskvalues`` we trace the lines and change the + node values for all cells traversed by a line to the corresponding + border value. Here, *cborder* is used for cells traversed by the + coastline, *lborder* for cells traversed by a lake outline, *iborder* + for islands-in-lakes outlines, and *pborder* for + ponds-in-islands-in-lakes outlines [Default is no line tracing]. maskvalues : str or list [*wet*, *dry*] or [*ocean*, *land*, *lake*, *island*, *pond*]. Sets the values that will be assigned to nodes. Values can From b31162e95b58a84da97d643d05c06282565df773 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Wed, 18 Aug 2021 07:24:09 +0200 Subject: [PATCH 16/16] Update pygmt/src/grdlandmask.py Co-authored-by: Dongdong Tian --- pygmt/src/grdlandmask.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/grdlandmask.py b/pygmt/src/grdlandmask.py index 6ceb22ba4ff..8965d9d1a87 100644 --- a/pygmt/src/grdlandmask.py +++ b/pygmt/src/grdlandmask.py @@ -78,7 +78,7 @@ def grdlandmask(**kwargs): [*wet*, *dry*] or [*ocean*, *land*, *lake*, *island*, *pond*]. Sets the values that will be assigned to nodes. Values can be any number, including the textstring NaN - [Default is 0/1/0/1/0 (i.e., 0/1)]. Also select + [Default is [0, 1, 0, 1, 0] (i.e., [0, 1])]. Also select ``bordervalues`` to let nodes exactly on feature boundaries be considered outside [Default is inside]. {V}