@@ -320,6 +320,7 @@ def firwin(numtaps, cutoff, *, width=None, window='hamming', pass_zero=True,
320
320
See Also
321
321
--------
322
322
firwin2
323
+ firwin_2d
323
324
firls
324
325
minimum_phase
325
326
remez
@@ -1283,7 +1284,7 @@ def minimum_phase(h: np.ndarray,
1283
1284
return h_minimum [:n_out ]
1284
1285
1285
1286
1286
- def firwin_2d (hsize , window , * , fc = None , fs = 2 , circular = False ,
1287
+ def firwin_2d (hsize , window , * , fc = None , fs = 2 , circular = False ,
1287
1288
pass_zero = True , scale = True ):
1288
1289
"""
1289
1290
2D FIR filter design using the window method.
@@ -1315,25 +1316,25 @@ def firwin_2d(hsize, window, *, fc=None, fs=2, circular=False,
1315
1316
fs : float, optional
1316
1317
The sampling frequency of the signal. Default is 2.
1317
1318
circular : bool, optional
1318
- Whether to create a circularly symmetric 2-D window. Default is False.
1319
- pass_zero : This parameter is passed to the `firwin` function for each
1320
- scalar frequency axis.
1319
+ Whether to create a circularly symmetric 2-D window. Default is `` False`` .
1320
+ pass_zero : {True, False, 'bandpass', 'lowpass', 'highpass', 'bandstop'}, optional
1321
+ This parameter is directly passed to `firwin` for each scalar frequency axis.
1321
1322
Hence, if ``True``, the DC gain, i.e., the gain at frequency (0, 0), is 1.
1322
1323
If ``False``, the DC gain is 0 at frequency (0, 0) if `circular` is ``True``.
1323
- If `circular` is ``False`` the frequencies (0, f1) and (f0, 0) will have gain 0.
1324
+ If `circular` is ``False`` the frequencies (0, f1) and (f0, 0) will
1325
+ have gain 0.
1324
1326
It can also be a string argument for the desired filter type
1325
1327
(equivalent to ``btype`` in IIR design functions).
1326
1328
scale : bool, optional
1327
- This parameter is passed to the `firwin` function for
1328
- each scalar frequency axis.
1329
+ This parameter is directly passed to `firwin` for each scalar frequency axis.
1329
1330
Set to ``True`` to scale the coefficients so that the frequency
1330
1331
response is exactly unity at a certain frequency on one frequency axis.
1331
1332
That frequency is either:
1332
1333
1333
1334
- 0 (DC) if the first passband starts at 0 (i.e. pass_zero is ``True``)
1334
- - `fs/2` (the Nyquist frequency) if the first passband ends at
1335
- `fs/2` (i.e the filter is a single band highpass filter);
1336
- center of first passband otherwise
1335
+ - `fs`/2 (the Nyquist frequency) if the first passband ends at `fs`/2
1336
+ (i.e., the filter is a single band highpass filter);
1337
+ center of first passband otherwise
1337
1338
1338
1339
Returns
1339
1340
-------
@@ -1343,52 +1344,54 @@ def firwin_2d(hsize, window, *, fc=None, fs=2, circular=False,
1343
1344
Raises
1344
1345
------
1345
1346
ValueError
1346
- If `hsize` and `window` are not 2-element tuples or lists.
1347
- If `cutoff` is None when `circular` is True.
1348
- If `cutoff` is outside the range [0, fs / 2] and `circular` is False.
1349
- If any of the elements in `window` are not recognized.
1347
+ - If `hsize` and `window` are not 2-element tuples or lists.
1348
+ - If `cutoff` is None when `circular` is True.
1349
+ - If `cutoff` is outside the range [0, `fs`/ 2] and `circular` is `` False`` .
1350
+ - If any of the elements in `window` are not recognized.
1350
1351
RuntimeError
1351
1352
If `firwin` fails to converge when designing the filter.
1352
1353
1353
1354
See Also
1354
1355
--------
1355
- scipy.signal.firwin, scipy.signal.get_window
1356
+ firwin: FIR filter design using the window method for 1d arrays.
1357
+ get_window: Return a window of a given length and type.
1356
1358
1357
1359
Examples
1358
1360
--------
1359
- Generate a 5x5 low-pass filter with cutoff frequency 0.1.
1361
+ Generate a 5x5 low-pass filter with cutoff frequency 0.1:
1360
1362
1361
1363
>>> import numpy as np
1362
1364
>>> from scipy.signal import get_window
1363
- >>> from scipy.signal import fwind1
1365
+ >>> from scipy.signal import firwin_2d
1364
1366
>>> hsize = (5, 5)
1365
1367
>>> window = (("kaiser", 5.0), ("kaiser", 5.0))
1366
1368
>>> fc = 0.1
1367
- >>> filter_2d = fwind1 (hsize, window, fc=fc)
1369
+ >>> filter_2d = firwin_2d (hsize, window, fc=fc)
1368
1370
>>> filter_2d
1369
1371
array([[0.00025366, 0.00401662, 0.00738617, 0.00401662, 0.00025366],
1370
1372
[0.00401662, 0.06360159, 0.11695714, 0.06360159, 0.00401662],
1371
1373
[0.00738617, 0.11695714, 0.21507283, 0.11695714, 0.00738617],
1372
1374
[0.00401662, 0.06360159, 0.11695714, 0.06360159, 0.00401662],
1373
1375
[0.00025366, 0.00401662, 0.00738617, 0.00401662, 0.00025366]])
1374
1376
1375
- Generate a circularly symmetric 5x5 low-pass filter with Hamming window.
1377
+ Generate a circularly symmetric 5x5 low-pass filter with Hamming window:
1376
1378
1377
- >>> filter_2d = fwind1 ((5, 5), 'hamming', fc=fc, circular=True)
1379
+ >>> filter_2d = firwin_2d ((5, 5), 'hamming', fc=fc, circular=True)
1378
1380
>>> filter_2d
1379
1381
array([[-0.00020354, -0.00020354, -0.00020354, -0.00020354, -0.00020354],
1380
1382
[-0.00020354, 0.01506844, 0.09907658, 0.01506844, -0.00020354],
1381
1383
[-0.00020354, 0.09907658, -0.00020354, 0.09907658, -0.00020354],
1382
1384
[-0.00020354, 0.01506844, 0.09907658, 0.01506844, -0.00020354],
1383
1385
[-0.00020354, -0.00020354, -0.00020354, -0.00020354, -0.00020354]])
1384
1386
1385
- Plotting the generated 2D filters (optional).
1387
+ Generate Plots comparing the product of two 1d filters with a circular
1388
+ symmetric filter:
1386
1389
1387
1390
>>> import matplotlib.pyplot as plt
1388
1391
>>> hsize, fc = (50, 50), 0.05
1389
1392
>>> window = (("kaiser", 5.0), ("kaiser", 5.0))
1390
- >>> filter0_2d = fwind1 (hsize, window, fc=fc)
1391
- >>> filter1_2d = fwind1 ((50, 50), 'hamming', fc=fc, circular=True)
1393
+ >>> filter0_2d = firwin_2d (hsize, window, fc=fc)
1394
+ >>> filter1_2d = firwin_2d ((50, 50), 'hamming', fc=fc, circular=True)
1392
1395
...
1393
1396
>>> fg, (ax0, ax1) = plt.subplots(1, 2, tight_layout=True, figsize=(6.5, 3.5))
1394
1397
>>> ax0.set_title("Product of 2 Windows")
0 commit comments