{"id":8370,"date":"2019-02-17T22:43:57","date_gmt":"2019-02-17T13:43:57","guid":{"rendered":"http:\/\/fry.no.coocan.jp\/WordPress\/?p=8370"},"modified":"2019-02-17T22:44:15","modified_gmt":"2019-02-17T13:44:15","slug":"fir%e3%83%95%e3%82%a3%e3%83%ab%e3%82%bf%e3%83%bc","status":"publish","type":"post","link":"http:\/\/fry.no.coocan.jp\/WordPress\/?p=8370","title":{"rendered":"fir\u30d5\u30a3\u30eb\u30bf\u30fc"},"content":{"rendered":"<p>\u4e00\u6628\u65e5\u306e\u300c\u3044\u305f\u305a\u3089\u300d\u306e\u300c\u30ed\u30fc\u30d1\u30b9\u30d5\u30a3\u30eb\u30bf\u30fc\u300d\u3092\u78ba\u8a8d\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u3063\u3066\u307f\u305f\u3002<\/p>\n<p>\uff1d\uff1d<\/p>\n<div>import numpy as np<br \/>\nimport matplotlib.pyplot as plt<br \/>\nimport scipy.signal<\/div>\n<div>def main():<br \/>\n# \u30c7\u30fc\u30bf\u306e\u30d1\u30e9\u30e1\u30fc\u30bf<br \/>\nN = 500\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 # \u30b5\u30f3\u30d7\u30eb\u6570<br \/>\ndt = 0.002\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 # \u30b5\u30f3\u30d7\u30ea\u30f3\u30b0\u9593\u9694<br \/>\nf1, f2 = 10, 20\u00a0\u00a0\u00a0 # \u5468\u6ce2\u6570<br \/>\nt = np.arange(0, N*dt, dt) # \u6642\u9593\u8ef8<br \/>\nfreq = np.linspace(0, 1.0\/dt, N) # \u5468\u6ce2\u6570\u8ef8<\/div>\n<div>\u00a0\u00a0\u00a0 # \u4fe1\u53f7\u3092\u751f\u6210\uff08\u5468\u6ce2\u657010\u306e\u6b63\u5f26\u6ce2+\u5468\u6ce2\u657020\u306e\u6b63\u5f26\u6ce2+\u30e9\u30f3\u30c0\u30e0\u30ce\u30a4\u30ba\uff09<br \/>\n#\u00a0\u00a0\u00a0 f = np.sin(2*np.pi*f1*t) + np.sin(2*np.pi*f2*t) + 0.3 * np.random.randn(N)<br \/>\no= np.random.rand(N)<br \/>\nfs = N #\u30b5\u30f3\u30d7\u30ea\u30f3\u30b0\u5468\u6ce2\u6570<br \/>\nnyq = fs \/ 2.0\u00a0 #\u30ca\u30a4\u30ad\u30b9\u30c8\u5468\u6ce2\u6570<\/div>\n<div># \u30d5\u30a3\u30eb\u30bf\u306e\u8a2d\u8a08<br \/>\nf1 = 50.0 \/ nyq\u00a0\u00a0\u00a0\u00a0\u00a0 #\u30ab\u30c3\u30c8\u30aa\u30d5\u5468\u6ce2\u65701<br \/>\nf2 = 70.0 \/ nyq\u00a0\u00a0\u00a0\u00a0\u00a0 #\u30ab\u30c3\u30c8\u30aa\u30d5\u5468\u6ce2\u65702<br \/>\nnumtaps = 127\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #\u30d5\u30a3\u30eb\u30bf\u4fc2\u6570\u306e\u6570(\u5947\u6570)<\/div>\n<div>\u00a0\u00a0\u00a0 #b = scipy.signal.firwin(numtaps, f1)\u00a0 #\u30ed\u30fc\u30d1\u30b9<br \/>\n#b = scipy.signal.firwin(numtaps, f2, pass_zero=False)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 # \u30cf\u30a4\u30d1\u30b9<br \/>\nb = scipy.signal.firwin(numtaps, [f1, f2], pass_zero=False) # \u30d0\u30f3\u30c9\u30d1\u30b9f = scipy.signal.lfilter(b, 1, o)<\/p>\n<p># \u9ad8\u901f\u30d5\u30fc\u30ea\u30a8\u5909\u63db<br \/>\nF = np.fft.fft(f)<\/p>\n<\/div>\n<div>\u00a0\u00a0\u00a0 # \u632f\u5e45\u30b9\u30da\u30af\u30c8\u30eb\u3092\u8a08\u7b97<br \/>\nAmp = np.abs(F)<\/div>\n<div>\u00a0\u00a0\u00a0 # \u30b0\u30e9\u30d5\u8868\u793a<br \/>\nplt.figure()<br \/>\nplt.rcParams[&#8216;font.family&#8217;] = &#8216;Times New Roman&#8217;<br \/>\nplt.rcParams[&#8216;font.size&#8217;] = 17<br \/>\nplt.subplot(121)<br \/>\nplt.plot(t, f, label=&#8217;f(n)&#8217;)<br \/>\nplt.xlabel(&#8220;&#8221;, fontsize=5)<br \/>\nplt.ylabel(&#8220;&#8221;, fontsize=5)<br \/>\nplt.grid()<br \/>\nleg = plt.legend(loc=1, fontsize=12)<br \/>\nleg.get_frame().set_alpha(1)<br \/>\nplt.subplot(122)<br \/>\nplt.plot(freq, Amp, label=&#8217;|F(k)|&#8217;)<br \/>\nplt.xlabel(&#8221;, fontsize=20)<br \/>\nplt.ylabel(&#8221;, fontsize=20)<br \/>\nplt.grid()<br \/>\nleg = plt.legend(loc=1, fontsize=12)<br \/>\nleg.get_frame().set_alpha(1)<br \/>\nplt.show()<\/div>\n<div>if __name__ == &#8220;__main__&#8221;:<br \/>\nmain()<\/div>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u6628\u65e5\u306e\u300c\u3044\u305f\u305a\u3089\u300d\u306e\u300c\u30ed\u30fc\u30d1\u30b9\u30d5\u30a3\u30eb\u30bf\u30fc\u300d\u3092\u78ba\u8a8d\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u3063\u3066\u307f\u305f\u3002 \uff1d\uff1d import numpy as np import matplotlib.pyplot as plt import scipy.sig &hellip; <a href=\"http:\/\/fry.no.coocan.jp\/WordPress\/?p=8370\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/fry.no.coocan.jp\/WordPress\/index.php?rest_route=\/wp\/v2\/posts\/8370"}],"collection":[{"href":"http:\/\/fry.no.coocan.jp\/WordPress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/fry.no.coocan.jp\/WordPress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/fry.no.coocan.jp\/WordPress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/fry.no.coocan.jp\/WordPress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8370"}],"version-history":[{"count":2,"href":"http:\/\/fry.no.coocan.jp\/WordPress\/index.php?rest_route=\/wp\/v2\/posts\/8370\/revisions"}],"predecessor-version":[{"id":8372,"href":"http:\/\/fry.no.coocan.jp\/WordPress\/index.php?rest_route=\/wp\/v2\/posts\/8370\/revisions\/8372"}],"wp:attachment":[{"href":"http:\/\/fry.no.coocan.jp\/WordPress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8370"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/fry.no.coocan.jp\/WordPress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8370"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/fry.no.coocan.jp\/WordPress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8370"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}