@@ -1336,6 +1336,65 @@ def firwin_2d(hsize, window, *, fc=None, fs=2, circular=False, pass_zero=True, s
1336
1336
-------
1337
1337
filter_2d : (hsize[0], hsize[1]) ndarray
1338
1338
Coefficients of 2D FIR filter.
1339
+
1340
+ Raises
1341
+ ------
1342
+ ValueError
1343
+ If `hsize` and `window` are not 2-element tuples or lists.
1344
+ If `cutoff` is None when `circular` is True.
1345
+ If `cutoff` is outside the range [0, fs / 2] and `circular` is False.
1346
+ If any of the elements in `window` are not recognized.
1347
+ RuntimeError
1348
+ If `firwin` fails to converge when designing the filter.
1349
+
1350
+ See Also
1351
+ --------
1352
+ scipy.signal.firwin, scipy.signal.get_window
1353
+
1354
+ Examples
1355
+ --------
1356
+ Generate a 5x5 low-pass filter with cutoff frequency 0.1.
1357
+
1358
+ >>> import numpy as np
1359
+ >>> from scipy.signal import get_window
1360
+ >>> from scipy.signal import fwind1
1361
+ >>> hsize = (5, 5)
1362
+ >>> window = (("kaiser", 5.0), ("kaiser", 5.0))
1363
+ >>> fc = 0.1
1364
+ >>> filter_2d = fwind1(hsize, window, fc=fc)
1365
+ >>> filter_2d
1366
+ array([[0.00025366, 0.00401662, 0.00738617, 0.00401662, 0.00025366],
1367
+ [0.00401662, 0.06360159, 0.11695714, 0.06360159, 0.00401662],
1368
+ [0.00738617, 0.11695714, 0.21507283, 0.11695714, 0.00738617],
1369
+ [0.00401662, 0.06360159, 0.11695714, 0.06360159, 0.00401662],
1370
+ [0.00025366, 0.00401662, 0.00738617, 0.00401662, 0.00025366]])
1371
+
1372
+ Generate a circularly symmetric 5x5 low-pass filter with Hamming window.
1373
+
1374
+ >>> filter_2d = fwind1((5, 5), 'hamming', fc=fc, circular=True)
1375
+ >>> filter_2d
1376
+ array([[-0.00020354, -0.00020354, -0.00020354, -0.00020354, -0.00020354],
1377
+ [-0.00020354, 0.01506844, 0.09907658, 0.01506844, -0.00020354],
1378
+ [-0.00020354, 0.09907658, -0.00020354, 0.09907658, -0.00020354],
1379
+ [-0.00020354, 0.01506844, 0.09907658, 0.01506844, -0.00020354],
1380
+ [-0.00020354, -0.00020354, -0.00020354, -0.00020354, -0.00020354]])
1381
+
1382
+ Plotting the generated 2D filters (optional).
1383
+
1384
+ >>> import matplotlib.pyplot as plt
1385
+ >>> hsize, fc = (50, 50), 0.05
1386
+ >>> window = (("kaiser", 5.0), ("kaiser", 5.0))
1387
+ >>> filter0_2d = fwind1(hsize, window, fc=fc)
1388
+ >>> filter1_2d = fwind1((50, 50), 'hamming', fc=fc, circular=True)
1389
+ ...
1390
+ >>> fg, (ax0, ax1) = plt.subplots(1, 2, tight_layout=True, figsize=(6.5, 3.5))
1391
+ >>> ax0.set_title("Product of 2 Windows")
1392
+ >>> im0 = ax0.imshow(filter0_2d, cmap='viridis', origin='lower', aspect='equal')
1393
+ >>> fg.colorbar(im0, ax=ax0, shrink=0.7)
1394
+ >>> ax1.set_title("Circular Window")
1395
+ >>> im1 = ax1.imshow(filter1_2d, cmap='plasma', origin='lower', aspect='equal')
1396
+ >>> fg.colorbar(im1, ax=ax1, shrink=0.7)
1397
+ >>> plt.show()
1339
1398
"""
1340
1399
if len (hsize ) != 2 :
1341
1400
raise ValueError ("hsize must be a 2-element tuple or list" )
0 commit comments