|
1 | 1 | """
|
2 |
| -blockm - Block average (x,y,z) data tables by mean or median estimation. |
| 2 | +blockm - Block average (x,y,z) data tables by mean, median, or mode estimation. |
3 | 3 | """
|
4 | 4 | import pandas as pd
|
5 | 5 | from pygmt.clib import Session
|
|
14 | 14 |
|
15 | 15 | def _blockm(block_method, table, outfile, x, y, z, **kwargs):
|
16 | 16 | r"""
|
17 |
| - Block average (x,y,z) data tables by mean or median estimation. |
| 17 | + Block average (x,y,z) data tables by mean, median, or mode estimation. |
18 | 18 |
|
19 | 19 | Reads arbitrarily located (x,y,z) triples [or optionally weighted
|
20 |
| - quadruples (x,y,z,w)] from a table and writes to the output a mean or |
21 |
| - median (depending on ``block_method``) position and value for every |
22 |
| - non-empty block in a grid region defined by the ``region`` and ``spacing`` |
23 |
| - parameters. |
| 20 | + quadruples (x,y,z,w)] from a table and writes to the output a mean, |
| 21 | + median, or mode (depending on ``block_method``) position and value for |
| 22 | + every non-empty block in a grid region defined by the ``region`` and |
| 23 | + ``spacing`` parameters. |
24 | 24 |
|
25 | 25 | Parameters
|
26 | 26 | ----------
|
27 | 27 | block_method : str
|
28 |
| - Name of the GMT module to call. Must be "blockmean" or "blockmedian". |
| 28 | + Name of the GMT module to call. Must be "blockmean", "blockmedian" or |
| 29 | + "blockmode". |
29 | 30 |
|
30 | 31 | Returns
|
31 | 32 | -------
|
@@ -226,3 +227,82 @@ def blockmedian(table=None, outfile=None, *, x=None, y=None, z=None, **kwargs):
|
226 | 227 | z=z,
|
227 | 228 | **kwargs
|
228 | 229 | )
|
| 230 | + |
| 231 | + |
| 232 | +@fmt_docstring |
| 233 | +@use_alias( |
| 234 | + I="spacing", |
| 235 | + R="region", |
| 236 | + V="verbose", |
| 237 | + a="aspatial", |
| 238 | + b="binary", |
| 239 | + d="data", |
| 240 | + e="find", |
| 241 | + f="coltypes", |
| 242 | + h="header", |
| 243 | + i="incols", |
| 244 | + o="outcols", |
| 245 | + r="registration", |
| 246 | + s="skiprows", |
| 247 | + w="wrap", |
| 248 | +) |
| 249 | +@kwargs_to_strings(R="sequence", i="sequence_comma") |
| 250 | +def blockmode(table=None, outfile=None, *, x=None, y=None, z=None, **kwargs): |
| 251 | + r""" |
| 252 | + Block average (x,y,z) data tables by mode estimation. |
| 253 | +
|
| 254 | + Reads arbitrarily located (x,y,z) triples [or optionally weighted |
| 255 | + quadruples (x,y,z,w)] and writes to the output a mode position and value |
| 256 | + for every non-empty block in a grid region defined by the ``region`` and |
| 257 | + ``spacing`` parameters. |
| 258 | +
|
| 259 | + Takes a matrix, xyz triplets, or a file name as input. |
| 260 | +
|
| 261 | + Must provide either ``table`` or ``x``, ``y``, and ``z``. |
| 262 | +
|
| 263 | + Full option list at :gmt-docs:`blockmode.html` |
| 264 | +
|
| 265 | + {aliases} |
| 266 | +
|
| 267 | + Parameters |
| 268 | + ---------- |
| 269 | + table : str or {table-like} |
| 270 | + Pass in (x, y, z) or (longitude, latitude, elevation) values by |
| 271 | + providing a file name to an ASCII data table, a 2D |
| 272 | + {table-classes}. |
| 273 | + x/y/z : 1d arrays |
| 274 | + Arrays of x and y coordinates and values z of the data points. |
| 275 | +
|
| 276 | + {I} |
| 277 | +
|
| 278 | + {R} |
| 279 | +
|
| 280 | + outfile : str |
| 281 | + The file name for the output ASCII file. |
| 282 | +
|
| 283 | + {V} |
| 284 | + {a} |
| 285 | + {b} |
| 286 | + {d} |
| 287 | + {e} |
| 288 | + {f} |
| 289 | + {h} |
| 290 | + {i} |
| 291 | + {o} |
| 292 | + {r} |
| 293 | + {s} |
| 294 | + {w} |
| 295 | +
|
| 296 | + Returns |
| 297 | + ------- |
| 298 | + output : pandas.DataFrame or None |
| 299 | + Return type depends on whether the ``outfile`` parameter is set: |
| 300 | +
|
| 301 | + - :class:`pandas.DataFrame` table with (x, y, z) columns if ``outfile`` |
| 302 | + is not set. |
| 303 | + - None if ``outfile`` is set (filtered output will be stored in file |
| 304 | + set by ``outfile``). |
| 305 | + """ |
| 306 | + return _blockm( |
| 307 | + block_method="blockmode", table=table, outfile=outfile, x=x, y=y, z=z, **kwargs |
| 308 | + ) |
0 commit comments