2
2
filter1d - Time domain filtering of 1-D data tables
3
3
"""
4
4
5
+ from typing import Literal
6
+
5
7
import pandas as pd
6
8
from pygmt .clib import Session
7
9
from pygmt .exceptions import GMTInvalidInput
20
22
F = "filter_type" ,
21
23
N = "time_col" ,
22
24
)
23
- def filter1d (data , output_type = "pandas" , outfile = None , ** kwargs ):
25
+ def filter1d (
26
+ data ,
27
+ output_type : Literal ["pandas" , "numpy" , "file" ] = "pandas" ,
28
+ outfile : str | None = None ,
29
+ ** kwargs ,
30
+ ):
24
31
r"""
25
32
Time domain filtering of 1-D data tables.
26
33
@@ -38,6 +45,15 @@ def filter1d(data, output_type="pandas", outfile=None, **kwargs):
38
45
39
46
Parameters
40
47
----------
48
+ output_type
49
+ Desired output type of the result data.
50
+
51
+ - ``pandas`` will return a :class:`pandas.DataFrame` object.
52
+ - ``numpy`` will return a :class:`numpy.ndarray` object.
53
+ - ``file`` will save the result to the file given by the ``outfile`` parameter.
54
+ outfile
55
+ The file name for saving the result. If specified, ``output_type`` will be
56
+ forced to be ``"file"``.
41
57
filter_type : str
42
58
**type**\ *width*\ [**+h**].
43
59
Set the filter **type**. Choose among convolution and non-convolution
@@ -91,26 +107,14 @@ def filter1d(data, output_type="pandas", outfile=None, **kwargs):
91
107
left-most column is 0, while the right-most is (*n_cols* - 1)
92
108
[Default is ``0``].
93
109
94
- output_type : str
95
- Determine the format the xyz data will be returned in [Default is
96
- ``pandas``]:
97
-
98
- - ``numpy`` - :class:`numpy.ndarray`
99
- - ``pandas``- :class:`pandas.DataFrame`
100
- - ``file`` - ASCII file (requires ``outfile``)
101
- outfile : str
102
- The file name for the output ASCII file.
103
-
104
110
Returns
105
111
-------
106
112
ret : pandas.DataFrame or numpy.ndarray or None
107
113
Return type depends on ``outfile`` and ``output_type``:
108
114
109
- - None if ``outfile`` is set (output will be stored in file set by
110
- ``outfile``)
111
- - :class:`pandas.DataFrame` or :class:`numpy.ndarray` if ``outfile`` is
112
- not set (depends on ``output_type`` [Default is
113
- :class:`pandas.DataFrame`])
115
+ - None if ``outfile`` is set (output will be stored in file set by ``outfile``)
116
+ - :class:`pandas.DataFrame` or :class:`numpy.ndarray` if ``outfile`` is not set
117
+ (depends on ``output_type``)
114
118
"""
115
119
if kwargs .get ("F" ) is None :
116
120
raise GMTInvalidInput ("Pass a required argument to 'filter_type'." )
0 commit comments