From 830552af69520b4903d8decbcc6860f0f43a7178 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Sun, 12 Sep 2021 21:28:09 -0400 Subject: [PATCH 01/19] add parameters --- pygmt/src/xyz2grd.py | 91 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 90 insertions(+), 1 deletion(-) diff --git a/pygmt/src/xyz2grd.py b/pygmt/src/xyz2grd.py index be08657f463..d00fd9872d1 100644 --- a/pygmt/src/xyz2grd.py +++ b/pygmt/src/xyz2grd.py @@ -14,14 +14,18 @@ @fmt_docstring @use_alias( + A="duplicate", + D="dname", G="outgrid", I="spacing", R="region", V="verbose", + Z="onecolumn", + r="registration", ) @kwargs_to_strings(R="sequence") def xyz2grd(table, **kwargs): - """ + r""" Create a grid file from table data. xyz2grd reads one or more z or xyz tables and creates a binary grid file. @@ -40,9 +44,94 @@ def xyz2grd(table, **kwargs): outgrid : str or None Optional. The name of the output netCDF file with extension .nc to store the grid in. + duplicate : str + [**d**\|\ **f**\|\ **l**\|\ **m**\|\ **n**\|\ + **r**\|\ **S**\|\ **s**\|\ **u**\|\ **z**] + By default we will calculate mean values if multiple entries fall on + the same node. Use **-A** to change this behavior, except it is + ignored if **-Z** is given. Append **f** or **s** to simply keep the + first or last data point that was assigned to each node. Append + **l** or **u** or **d** to find the lowest (minimum) or upper (maximum) value + or the difference between the maximum and miminum value + at each node, respectively. Append **m** or **r** or **S** to compute mean or + RMS value or standard deviation at each node, respectively. Append **n** to simply count + the number of data points that were assigned to each node (this only + requires two input columns *x* and *y* as *z* is not consulted). Append + **z** to sum multiple values that belong to the same node. + dname : str + [**+x**\ *xname*][**+y**\ *yname*][**+z**\ *zname*][**+d**\ *vname*] + [**+s**\ *scale*][**+o**\ *offset*][**+n**\ *invalid*][**+t**\ *title*] + [**+r**\ *remark*][**+v**\ *varname*]. + Give one or more combinations for values *xname*, *yname*, *zname* (3rd dimension in cube), + and *dname* (data value name) and give the names of those variables + and in square bracket their units, e.g., "distance [km]"), *scale* (to multiply data values after + read [normally 1]), *offset* (to add to data after scaling [normally 0]), + *invalid* (a value to represent missing data [NaN]), *title* (anything you + like), and *remark* (anything you like). Items not listed will remain untouched. + Give a blank name to completely reset a particular string. + Use quotes to group texts with more than one word. If any of your text contains plus symbols + you need to escape them (place a backslash before each plus-sign) so they are not confused with the + option modifiers. Alternatively, you can place the entire double-quoted string inside single + quotes. If you have shell variables that contain plus symbols you cannot use single quotes but + you can escape the plus symbols in a variable using constructs like ${variable/+/\\+}. + Note that for geographic grids and cubes (**-fg**) *xname* and *yname* are set automatically. + Normally, the data netCDF variable is called "z" (grid) or "cube" (data cube). You can name this + netCDF variable via **+v**\ *varname*. + {I} {R} {V} + onecolumn : str + [*flags*] + Read a 1-column ASCII [or binary] table. This assumes that all the + nodes are present and sorted according to specified ordering + convention contained in *flags*. If incoming data represents rows, + make *flags* start with **T**\ (op) if first row is y + = ymax or **B**\ (ottom) if first row is y = ymin. + Then, append **L** or **R** to indicate that first element is at + left or right end of row. Likewise for column formats: start with + **L** or **R** to position first column, and then append **T** or + **B** to position first element in a row. **Note**: These two row/column + indicators are only required for grids; for other tables they do not + apply. For gridline registered grids: If data are periodic in x but + the incoming data do not contain the (redundant) column at x = xmax, + append **x**. For data periodic in y without redundant row at y = + ymax, append **y**. Append **s**\ *n* to skip the first *n* number + of bytes (probably a header). If the byte-order or the words needs + to be swapped, append **w**. Select one of several data types (all + binary except **a**): + + **A** ASCII representation of one or more floating point values per record + + **a** ASCII representation of a single item per record + + **c** int8_t, signed 1-byte character + + **u** uint8_t, unsigned 1-byte character + + **h** int16_t, signed 2-byte integer + + **H** uint16_t, unsigned 2-byte integer + + **i** int32_t, signed 4-byte integer + + **I** uint32_t, unsigned 4-byte integer + + **l** int64_t, long (8-byte) integer + + **L** uint64_t, unsigned long (8-byte) integer + + **f** 4-byte floating point single precision + + **d** 8-byte floating point double precision + + Default format is scanline orientation of ASCII numbers: **-ZTLa**. + The difference between **A** and **a** is that the latter can decode both + *date*\ **T**\ *clock* and *ddd:mm:ss[.xx]* formats but expects each + input record to have a single value, while the former can handle multiple + values per record but can only parse regular floating point values. + Translate incoming *z*-values via the **-i**\ 0 option and needed modifiers. + {r} Returns ------- From 1651d23976954399c619e09ab22f2624697a7feb Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 14 Sep 2021 19:51:45 -0400 Subject: [PATCH 02/19] add docstrings to xyz2grd --- pygmt/src/xyz2grd.py | 72 ++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/pygmt/src/xyz2grd.py b/pygmt/src/xyz2grd.py index d00fd9872d1..d7600281917 100644 --- a/pygmt/src/xyz2grd.py +++ b/pygmt/src/xyz2grd.py @@ -45,39 +45,37 @@ def xyz2grd(table, **kwargs): Optional. The name of the output netCDF file with extension .nc to store the grid in. duplicate : str - [**d**\|\ **f**\|\ **l**\|\ **m**\|\ **n**\|\ + [**d**\|\ **f**\|\ **l**\|\ **m**\|\ **n**\|\ **r**\|\ **S**\|\ **s**\|\ **u**\|\ **z**] By default we will calculate mean values if multiple entries fall on the same node. Use **-A** to change this behavior, except it is ignored if **-Z** is given. Append **f** or **s** to simply keep the first or last data point that was assigned to each node. Append - **l** or **u** or **d** to find the lowest (minimum) or upper (maximum) value - or the difference between the maximum and miminum value - at each node, respectively. Append **m** or **r** or **S** to compute mean or - RMS value or standard deviation at each node, respectively. Append **n** to simply count - the number of data points that were assigned to each node (this only - requires two input columns *x* and *y* as *z* is not consulted). Append - **z** to sum multiple values that belong to the same node. + **l** or **u** or **d** to find the lowest (minimum) or upper (maximum) + value or the difference between the maximum and miminum value + at each node, respectively. Append **m** or **r** or **S** to compute + mean or RMS value or standard deviation at each node, respectively. + Append **n** to simply count the number of data points that were + assigned to each node (this only requires two input columns *x* and + *y* as *z* is not consulted). Append **z** to sum multiple values that + belong to the same node. dname : str [**+x**\ *xname*][**+y**\ *yname*][**+z**\ *zname*][**+d**\ *vname*] [**+s**\ *scale*][**+o**\ *offset*][**+n**\ *invalid*][**+t**\ *title*] [**+r**\ *remark*][**+v**\ *varname*]. - Give one or more combinations for values *xname*, *yname*, *zname* (3rd dimension in cube), - and *dname* (data value name) and give the names of those variables - and in square bracket their units, e.g., "distance [km]"), *scale* (to multiply data values after - read [normally 1]), *offset* (to add to data after scaling [normally 0]), - *invalid* (a value to represent missing data [NaN]), *title* (anything you - like), and *remark* (anything you like). Items not listed will remain untouched. - Give a blank name to completely reset a particular string. - Use quotes to group texts with more than one word. If any of your text contains plus symbols - you need to escape them (place a backslash before each plus-sign) so they are not confused with the - option modifiers. Alternatively, you can place the entire double-quoted string inside single - quotes. If you have shell variables that contain plus symbols you cannot use single quotes but - you can escape the plus symbols in a variable using constructs like ${variable/+/\\+}. - Note that for geographic grids and cubes (**-fg**) *xname* and *yname* are set automatically. - Normally, the data netCDF variable is called "z" (grid) or "cube" (data cube). You can name this - netCDF variable via **+v**\ *varname*. - + Give one or more combinations for values *xname*, *yname*, *zname* + (3rd dimension in cube), and *dname* (data value name) and give the + names of those variables and in square bracket their units, + e.g., "distance [km]"), *scale* (to multiply data values after + read [normally 1]), *offset* (to add to data after scaling + [normally 0]), *invalid* (a value to represent missing data [NaN]), + *title* (anything you like), and *remark* (anything you like). Items + not listed will remain untouched. Give a blank name to completely reset + a particular string. Use quotes to group texts with more than one word. + If any of your text contains plus symbols you need to escape them + (place a backslash before each plus-sign) so they are not confused with + the option modifiers. Alternatively, you can place the entire + double-quoted string inside single quotes. {I} {R} {V} @@ -91,17 +89,18 @@ def xyz2grd(table, **kwargs): Then, append **L** or **R** to indicate that first element is at left or right end of row. Likewise for column formats: start with **L** or **R** to position first column, and then append **T** or - **B** to position first element in a row. **Note**: These two row/column - indicators are only required for grids; for other tables they do not - apply. For gridline registered grids: If data are periodic in x but - the incoming data do not contain the (redundant) column at x = xmax, - append **x**. For data periodic in y without redundant row at y = - ymax, append **y**. Append **s**\ *n* to skip the first *n* number + **B** to position first element in a row. **Note**: These two + row/column indicators are only required for grids; for other tables + they do not apply. For gridline registered grids: If data are periodic + in x but the incoming data do not contain the (redundant) column at + x = xmax, append **x**. For data periodic in y without redundant row at + y = ymax, append **y**. Append **s**\ *n* to skip the first *n* number of bytes (probably a header). If the byte-order or the words needs to be swapped, append **w**. Select one of several data types (all binary except **a**): - **A** ASCII representation of one or more floating point values per record + **A** ASCII representation of one or more floating point values per + record **a** ASCII representation of a single item per record @@ -126,11 +125,12 @@ def xyz2grd(table, **kwargs): **d** 8-byte floating point double precision Default format is scanline orientation of ASCII numbers: **-ZTLa**. - The difference between **A** and **a** is that the latter can decode both - *date*\ **T**\ *clock* and *ddd:mm:ss[.xx]* formats but expects each - input record to have a single value, while the former can handle multiple - values per record but can only parse regular floating point values. - Translate incoming *z*-values via the **-i**\ 0 option and needed modifiers. + The difference between **A** and **a** is that the latter can decode + both *date*\ **T**\ *clock* and *ddd:mm:ss[.xx]* formats but expects + each input record to have a single value, while the former can handle + multiple values per record but can only parse regular floating point + values. Translate incoming *z*-values via the **-i**\ 0 option and + needed modifiers. {r} Returns From 3eefbbfad677c87c969ec610460c1f7b28a68e60 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Sun, 19 Sep 2021 18:45:35 -0400 Subject: [PATCH 03/19] add parameters tag to docstring --- pygmt/src/xyz2grd.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pygmt/src/xyz2grd.py b/pygmt/src/xyz2grd.py index d7600281917..79997b9b108 100644 --- a/pygmt/src/xyz2grd.py +++ b/pygmt/src/xyz2grd.py @@ -35,6 +35,8 @@ def xyz2grd(table, **kwargs): Full option list at :gmt-docs:`xyz2grd.html` + {aliases} + Parameters ---------- table : str or {table-like} From c64736c58912a09862c0d60a25166e5bf8ea9b94 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Fri, 24 Sep 2021 09:47:21 +0100 Subject: [PATCH 04/19] Apply suggestions from code review Co-authored-by: Meghan Jones --- pygmt/src/xyz2grd.py | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/pygmt/src/xyz2grd.py b/pygmt/src/xyz2grd.py index 79997b9b108..1c9fb278ce8 100644 --- a/pygmt/src/xyz2grd.py +++ b/pygmt/src/xyz2grd.py @@ -101,30 +101,19 @@ def xyz2grd(table, **kwargs): to be swapped, append **w**. Select one of several data types (all binary except **a**): - **A** ASCII representation of one or more floating point values per - record - - **a** ASCII representation of a single item per record - - **c** int8_t, signed 1-byte character - - **u** uint8_t, unsigned 1-byte character - - **h** int16_t, signed 2-byte integer - - **H** uint16_t, unsigned 2-byte integer - - **i** int32_t, signed 4-byte integer - - **I** uint32_t, unsigned 4-byte integer - - **l** int64_t, long (8-byte) integer - - **L** uint64_t, unsigned long (8-byte) integer - - **f** 4-byte floating point single precision - - **d** 8-byte floating point double precision + - **A** ASCII representation of one or more floating point values per + record + - **a** ASCII representation of a single item per record + - **c** int8_t, signed 1-byte character + - **u** uint8_t, unsigned 1-byte character + - **h** int16_t, signed 2-byte integer + - **H** uint16_t, unsigned 2-byte integer + - **i** int32_t, signed 4-byte integer + - **I** uint32_t, unsigned 4-byte integer + - **l** int64_t, long (8-byte) integer + - **L** uint64_t, unsigned long (8-byte) integer + - **f** 4-byte floating point single precision + - **d** 8-byte floating point double precision Default format is scanline orientation of ASCII numbers: **-ZTLa**. The difference between **A** and **a** is that the latter can decode From fda29eb41637a79e5fc76b3d881d36177e111fcb Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Fri, 24 Sep 2021 09:49:13 +0100 Subject: [PATCH 05/19] move xyz2grd to tabular data section in index --- 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 0426f79385d..bad857f0e64 100644 --- a/doc/api/index.rst +++ b/doc/api/index.rst @@ -82,6 +82,7 @@ Operations on tabular data: blockmean blockmedian surface + xyz2grd Operations on grids: @@ -98,7 +99,6 @@ Operations on grids: grdsample grdtrack sphdistance - xyz2grd Crossover analysis with x2sys: From 25185dadadb01aa86ebf061f3348b00a1a64b988 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Sun, 26 Sep 2021 10:37:51 +0100 Subject: [PATCH 06/19] Apply suggestions from code review Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- pygmt/src/xyz2grd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/xyz2grd.py b/pygmt/src/xyz2grd.py index 1c9fb278ce8..2bdf5995987 100644 --- a/pygmt/src/xyz2grd.py +++ b/pygmt/src/xyz2grd.py @@ -28,7 +28,7 @@ def xyz2grd(table, **kwargs): r""" Create a grid file from table data. - xyz2grd reads one or more z or xyz tables and creates a binary grid file. + Reads one or more tables with *x, y, z* columns and creates a binary grid file. xyz2grd will report if some of the nodes are not filled in with data. Such unconstrained nodes are set to a value specified by the user [Default is NaN]. Nodes with more than one value will be set to the mean value. From d890a75654b390948ab2b9e04819b0c083ef1a56 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Sun, 26 Sep 2021 10:59:23 +0100 Subject: [PATCH 07/19] remove dname parameters --- pygmt/src/xyz2grd.py | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/pygmt/src/xyz2grd.py b/pygmt/src/xyz2grd.py index 2bdf5995987..b250ed3cae0 100644 --- a/pygmt/src/xyz2grd.py +++ b/pygmt/src/xyz2grd.py @@ -15,7 +15,6 @@ @fmt_docstring @use_alias( A="duplicate", - D="dname", G="outgrid", I="spacing", R="region", @@ -61,23 +60,6 @@ def xyz2grd(table, **kwargs): assigned to each node (this only requires two input columns *x* and *y* as *z* is not consulted). Append **z** to sum multiple values that belong to the same node. - dname : str - [**+x**\ *xname*][**+y**\ *yname*][**+z**\ *zname*][**+d**\ *vname*] - [**+s**\ *scale*][**+o**\ *offset*][**+n**\ *invalid*][**+t**\ *title*] - [**+r**\ *remark*][**+v**\ *varname*]. - Give one or more combinations for values *xname*, *yname*, *zname* - (3rd dimension in cube), and *dname* (data value name) and give the - names of those variables and in square bracket their units, - e.g., "distance [km]"), *scale* (to multiply data values after - read [normally 1]), *offset* (to add to data after scaling - [normally 0]), *invalid* (a value to represent missing data [NaN]), - *title* (anything you like), and *remark* (anything you like). Items - not listed will remain untouched. Give a blank name to completely reset - a particular string. Use quotes to group texts with more than one word. - If any of your text contains plus symbols you need to escape them - (place a backslash before each plus-sign) so they are not confused with - the option modifiers. Alternatively, you can place the entire - double-quoted string inside single quotes. {I} {R} {V} From 080d3aaa5abf58edb949c108326df7bef3c60fa9 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Sun, 26 Sep 2021 11:00:50 +0100 Subject: [PATCH 08/19] change "duplicate" to "multiple_nodes" --- pygmt/src/xyz2grd.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/xyz2grd.py b/pygmt/src/xyz2grd.py index b250ed3cae0..1a4a5441bd6 100644 --- a/pygmt/src/xyz2grd.py +++ b/pygmt/src/xyz2grd.py @@ -14,7 +14,7 @@ @fmt_docstring @use_alias( - A="duplicate", + A="multiple_nodes", G="outgrid", I="spacing", R="region", @@ -45,7 +45,7 @@ def xyz2grd(table, **kwargs): outgrid : str or None Optional. The name of the output netCDF file with extension .nc to store the grid in. - duplicate : str + multiple_nodes : str [**d**\|\ **f**\|\ **l**\|\ **m**\|\ **n**\|\ **r**\|\ **S**\|\ **s**\|\ **u**\|\ **z**] By default we will calculate mean values if multiple entries fall on From 160157ff75d046fbfa0952e9e298210d72fdc664 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Sun, 26 Sep 2021 11:01:37 +0100 Subject: [PATCH 09/19] replace "onecolumn" to "flags" --- pygmt/src/xyz2grd.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/xyz2grd.py b/pygmt/src/xyz2grd.py index 1a4a5441bd6..d94d13e98c7 100644 --- a/pygmt/src/xyz2grd.py +++ b/pygmt/src/xyz2grd.py @@ -19,7 +19,7 @@ I="spacing", R="region", V="verbose", - Z="onecolumn", + Z="flags", r="registration", ) @kwargs_to_strings(R="sequence") @@ -63,7 +63,7 @@ def xyz2grd(table, **kwargs): {I} {R} {V} - onecolumn : str + flags : str [*flags*] Read a 1-column ASCII [or binary] table. This assumes that all the nodes are present and sorted according to specified ordering From 58bc787919584290b07178e9f5c3d6d9573b8d64 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Mon, 11 Oct 2021 15:57:02 +0100 Subject: [PATCH 10/19] changing "flags" to "z_convention" --- pygmt/src/xyz2grd.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/xyz2grd.py b/pygmt/src/xyz2grd.py index 29203d18c42..7b2f730b99a 100644 --- a/pygmt/src/xyz2grd.py +++ b/pygmt/src/xyz2grd.py @@ -19,7 +19,7 @@ I="spacing", R="region", V="verbose", - Z="flags", + Z="z_convention", r="registration", ) @kwargs_to_strings(R="sequence") @@ -63,7 +63,7 @@ def xyz2grd(data, **kwargs): {I} {R} {V} - flags : str + z_convention : str [*flags*] Read a 1-column ASCII [or binary] table. This assumes that all the nodes are present and sorted according to specified ordering From 1eab216437c2a06a7bd7d81e57f1eb1c45ad4c28 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Sat, 23 Oct 2021 07:44:09 +0100 Subject: [PATCH 11/19] change z_convention to convention --- pygmt/src/xyz2grd.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/xyz2grd.py b/pygmt/src/xyz2grd.py index 2a1803c3027..6f896b99516 100644 --- a/pygmt/src/xyz2grd.py +++ b/pygmt/src/xyz2grd.py @@ -19,7 +19,7 @@ I="spacing", R="region", V="verbose", - Z="z_convention", + Z="convention", r="registration", ) @kwargs_to_strings(R="sequence") @@ -64,7 +64,7 @@ def xyz2grd(data=None, x=None, y=None, z=None, **kwargs): {I} {R} {V} - z_convention : str + convention : str [*flags*] Read a 1-column ASCII [or binary] table. This assumes that all the nodes are present and sorted according to specified ordering From 9dea9cb226e79c92e4c42d65c5ca858044268d6b Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Thu, 28 Oct 2021 07:01:29 +0100 Subject: [PATCH 12/19] Apply suggestions from code review Co-authored-by: Meghan Jones --- pygmt/src/xyz2grd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/xyz2grd.py b/pygmt/src/xyz2grd.py index 6f896b99516..859cd2946c6 100644 --- a/pygmt/src/xyz2grd.py +++ b/pygmt/src/xyz2grd.py @@ -85,7 +85,7 @@ def xyz2grd(data=None, x=None, y=None, z=None, **kwargs): binary except **a**): - **A** ASCII representation of one or more floating point values per - record + record - **a** ASCII representation of a single item per record - **c** int8_t, signed 1-byte character - **u** uint8_t, unsigned 1-byte character From fce671f8f5ae9784a24860d65a7a7a8a4d28c095 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Thu, 28 Oct 2021 07:03:27 +0100 Subject: [PATCH 13/19] add incols to xyz2grd --- pygmt/src/xyz2grd.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pygmt/src/xyz2grd.py b/pygmt/src/xyz2grd.py index 859cd2946c6..5ac46cdeca4 100644 --- a/pygmt/src/xyz2grd.py +++ b/pygmt/src/xyz2grd.py @@ -20,6 +20,7 @@ R="region", V="verbose", Z="convention", + i="incols", r="registration", ) @kwargs_to_strings(R="sequence") @@ -105,6 +106,7 @@ def xyz2grd(data=None, x=None, y=None, z=None, **kwargs): multiple values per record but can only parse regular floating point values. Translate incoming *z*-values via the **-i**\ 0 option and needed modifiers. + {i} {r} Returns From 41507e20e51ba24a4de53cb4470748d846e6ed68 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Thu, 28 Oct 2021 07:09:05 +0100 Subject: [PATCH 14/19] change "mulitple_nodes" to "duplicate" --- pygmt/src/xyz2grd.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/src/xyz2grd.py b/pygmt/src/xyz2grd.py index 5ac46cdeca4..422b0fc439b 100644 --- a/pygmt/src/xyz2grd.py +++ b/pygmt/src/xyz2grd.py @@ -14,7 +14,7 @@ @fmt_docstring @use_alias( - A="multiple_nodes", + A="duplicate", G="outgrid", I="spacing", R="region", @@ -47,7 +47,7 @@ def xyz2grd(data=None, x=None, y=None, z=None, **kwargs): outgrid : str or None Optional. The name of the output netCDF file with extension .nc to store the grid in. - multiple_nodes : str + duplicate : str [**d**\|\ **f**\|\ **l**\|\ **m**\|\ **n**\|\ **r**\|\ **S**\|\ **s**\|\ **u**\|\ **z**] By default we will calculate mean values if multiple entries fall on From 80c6a6f092b4533ea81459f5823521c91ff0c2b3 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Thu, 28 Oct 2021 14:51:21 +0100 Subject: [PATCH 15/19] Apply suggestions from code review Co-authored-by: Meghan Jones --- pygmt/src/xyz2grd.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/pygmt/src/xyz2grd.py b/pygmt/src/xyz2grd.py index 422b0fc439b..bd63595a48e 100644 --- a/pygmt/src/xyz2grd.py +++ b/pygmt/src/xyz2grd.py @@ -20,8 +20,14 @@ R="region", V="verbose", Z="convention", + b="binary", + d="nodata", + e="find", + f="coltypes", + h="header", i="incols", r="registration", + w="wrap", ) @kwargs_to_strings(R="sequence") def xyz2grd(data=None, x=None, y=None, z=None, **kwargs): @@ -104,10 +110,15 @@ def xyz2grd(data=None, x=None, y=None, z=None, **kwargs): both *date*\ **T**\ *clock* and *ddd:mm:ss[.xx]* formats but expects each input record to have a single value, while the former can handle multiple values per record but can only parse regular floating point - values. Translate incoming *z*-values via the **-i**\ 0 option and - needed modifiers. + values. Translate incoming *z*-values via the ``incols`` parameter. + {b} + {d} + {e} + {f} + {h} {i} {r} + {w} Returns ------- From 3057c220d39a7251484a042efbbaf8145a9e422a Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Thu, 28 Oct 2021 15:36:38 +0100 Subject: [PATCH 16/19] Fix line length issue --- pygmt/src/xyz2grd.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pygmt/src/xyz2grd.py b/pygmt/src/xyz2grd.py index bd63595a48e..b0d1af1222b 100644 --- a/pygmt/src/xyz2grd.py +++ b/pygmt/src/xyz2grd.py @@ -34,10 +34,11 @@ def xyz2grd(data=None, x=None, y=None, z=None, **kwargs): """ Create a grid file from table data. - Reads one or more tables with *x, y, z* columns and creates a binary grid file. - xyz2grd will report if some of the nodes are not filled in with data. Such - unconstrained nodes are set to a value specified by the user [Default is - NaN]. Nodes with more than one value will be set to the mean value. + Reads one or more tables with *x, y, z* columns and creates a binary grid + file. xyz2grd will report if some of the nodes are not filled in with + data. Such unconstrained nodes are set to a value specified by the user + [Default is NaN]. Nodes with more than one value will be set to the mean + value. Full option list at :gmt-docs:`xyz2grd.html` From b67cffaaae1dc3f353839728491846b90a429f11 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Thu, 28 Oct 2021 22:03:50 +0100 Subject: [PATCH 17/19] Update pygmt/src/xyz2grd.py Co-authored-by: Meghan Jones --- pygmt/src/xyz2grd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/src/xyz2grd.py b/pygmt/src/xyz2grd.py index b0d1af1222b..add89e196bd 100644 --- a/pygmt/src/xyz2grd.py +++ b/pygmt/src/xyz2grd.py @@ -31,7 +31,7 @@ ) @kwargs_to_strings(R="sequence") def xyz2grd(data=None, x=None, y=None, z=None, **kwargs): - """ + r""" Create a grid file from table data. Reads one or more tables with *x, y, z* columns and creates a binary grid From c020b1971a7efce7a309d2ef7231197ebaee0b40 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Thu, 28 Oct 2021 22:06:23 +0100 Subject: [PATCH 18/19] remove trailing whitespaces --- pygmt/src/xyz2grd.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pygmt/src/xyz2grd.py b/pygmt/src/xyz2grd.py index add89e196bd..18300acb804 100644 --- a/pygmt/src/xyz2grd.py +++ b/pygmt/src/xyz2grd.py @@ -34,10 +34,10 @@ def xyz2grd(data=None, x=None, y=None, z=None, **kwargs): r""" Create a grid file from table data. - Reads one or more tables with *x, y, z* columns and creates a binary grid - file. xyz2grd will report if some of the nodes are not filled in with - data. Such unconstrained nodes are set to a value specified by the user - [Default is NaN]. Nodes with more than one value will be set to the mean + Reads one or more tables with *x, y, z* columns and creates a binary grid + file. xyz2grd will report if some of the nodes are not filled in with + data. Such unconstrained nodes are set to a value specified by the user + [Default is NaN]. Nodes with more than one value will be set to the mean value. Full option list at :gmt-docs:`xyz2grd.html` From fc45f66da2136b69a52a1e753bdc178e5af217bb Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Thu, 28 Oct 2021 22:20:23 +0100 Subject: [PATCH 19/19] Apply suggestions from code review Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- pygmt/src/xyz2grd.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pygmt/src/xyz2grd.py b/pygmt/src/xyz2grd.py index 18300acb804..fd38c73ffe9 100644 --- a/pygmt/src/xyz2grd.py +++ b/pygmt/src/xyz2grd.py @@ -17,6 +17,7 @@ A="duplicate", G="outgrid", I="spacing", + J="projection", R="region", V="verbose", Z="convention", @@ -56,7 +57,7 @@ def xyz2grd(data=None, x=None, y=None, z=None, **kwargs): store the grid in. duplicate : str [**d**\|\ **f**\|\ **l**\|\ **m**\|\ **n**\|\ - **r**\|\ **S**\|\ **s**\|\ **u**\|\ **z**] + **r**\|\ **S**\|\ **s**\|\ **u**\|\ **z**]. By default we will calculate mean values if multiple entries fall on the same node. Use **-A** to change this behavior, except it is ignored if **-Z** is given. Append **f** or **s** to simply keep the @@ -70,10 +71,11 @@ def xyz2grd(data=None, x=None, y=None, z=None, **kwargs): *y* as *z* is not consulted). Append **z** to sum multiple values that belong to the same node. {I} + {J} {R} {V} convention : str - [*flags*] + [*flags*]. Read a 1-column ASCII [or binary] table. This assumes that all the nodes are present and sorted according to specified ordering convention contained in *flags*. If incoming data represents rows,