@@ -60,14 +60,17 @@ def info(table, **kwargs):
60
60
"""
61
61
Get information about data tables.
62
62
63
- Reads from files and finds the extreme values in each of the columns.
64
- It recognizes NaNs and will print warnings if the number of columns vary
65
- from record to record. As an option, it will find the extent of the first
66
- n columns rounded up and down to the nearest multiple of the supplied
67
- increments. By default, this output will be in the form *-Rw/e/s/n*,
68
- or the output will be in column form for as many columns as there are
69
- increments provided. The *nearest_multiple* option will provide a
70
- *-Tzmin/zmax/dz* string for makecpt.
63
+ Reads from files and finds the extreme values in each of the columns
64
+ reported as min/max pairs. It recognizes NaNs and will print warnings if
65
+ the number of columns vary from record to record. As an option, it will
66
+ find the extent of the first two columns rounded up and down to the nearest
67
+ multiple of the supplied increments given by *spacing*. Such output will be
68
+ in a numpy.ndarray form ``[w, e, s, n]``, which can be used directly as the
69
+ *region* argument for other modules (hence only dx and dy are needed). If
70
+ the *per_column* option is combined with *spacing*, then the numpy.ndarray
71
+ output will be rounded up/down for as many columns as there are increments
72
+ provided in *spacing*. A similar option *nearest_multiple* option will
73
+ provide a numpy.ndarray in the form of ``[zmin, zmax, dz]`` for makecpt.
71
74
72
75
Full option list at :gmt-docs:`gmtinfo.html`
73
76
@@ -83,12 +86,21 @@ def info(table, **kwargs):
83
86
spacing : str
84
87
``'[b|p|f|s]dx[/dy[/dz...]]'``.
85
88
Report the min/max of the first n columns to the nearest multiple of
86
- the provided increments and output results in the form *-Rw/e/s/n*
87
- (unless *per_column* is set) .
89
+ the provided increments and output results in the form
90
+ ``[w, e, s, n]`` .
88
91
nearest_multiple : str
89
92
``'dz[+ccol]'``
90
93
Report the min/max of the first (0'th) column to the nearest multiple
91
- of dz and output this as the string *-Tzmin/zmax/dz*.
94
+ of dz and output this in the form ``[zmin, zmax, dz]``.
95
+
96
+ Returns
97
+ -------
98
+ output : np.ndarray or str
99
+ Return type depends on whether any of the 'per_column', 'spacing', or
100
+ 'nearest_multiple' parameters are set.
101
+
102
+ - np.ndarray if either of the above parameters are used.
103
+ - str if none of the above parameters are used.
92
104
"""
93
105
kind = data_kind (table )
94
106
with Session () as lib :
@@ -108,7 +120,16 @@ def info(table, **kwargs):
108
120
[fname , build_arg_string (kwargs ), "->" + tmpfile .name ]
109
121
)
110
122
lib .call_module ("info" , arg_str )
111
- return tmpfile .read ()
123
+ result = tmpfile .read ()
124
+
125
+ if any (arg in kwargs for arg in ["C" , "I" , "T" ]):
126
+ # Converts certain output types into a numpy array
127
+ # instead of a raw string that is less useful.
128
+ if result .startswith (("-R" , "-T" )): # e.g. -R0/1/2/3 or -T0/9/1
129
+ result = result [2 :].replace ("/" , " " )
130
+ result = np .loadtxt (result .splitlines ())
131
+
132
+ return result
112
133
113
134
114
135
@fmt_docstring
0 commit comments