質問するログイン新規登録

質問編集履歴

3

コード修正

2021/01/01 14:25

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -10,7 +10,7 @@
10
10
  import scipy.stats
11
11
  from scipy import signal
12
12
  from scipy import integrate
13
-
13
+ # -*- coding: utf-8 -*-
14
14
  import numpy as np
15
15
  import matplotlib.pyplot as plt
16
16
 
@@ -40,6 +40,7 @@
40
40
  np.savetxt('%sPDF.csv' %name, result, delimiter=',', header = Header, comments='')
41
41
 
42
42
  SpecHeader = 'f[Hz],E'
43
+ # データのパラメータ
43
44
  SN = 524288 # サンプル数
44
45
  fs = 10000 # カットオフ周波数 S/ sec
45
46
  N = SN
@@ -64,7 +65,9 @@
64
65
 
65
66
  freq1 = np.linspace(0, int(fs), SN)
66
67
 
68
+ # calculate energy spectrum
67
69
  freq1, P1 = signal.welch(f, fs, nperseg=N / 8)
70
+ # freq2, P2 = signal.welch(y, fs, nperseg=n/64)
68
71
  SpectrumResult = np.array([freq1, P1]).T
69
72
  np.savetxt('%d_%dPowerSpectrum.csv'%((i+1)*5, j+1),SpectrumResult,delimiter=',',header = SpecHeader,comments ='')
70
73
  plt.subplot(2, 2, 3)

2

インデントの修正

2021/01/01 14:25

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -2,6 +2,7 @@
2
2
  既に書かれたFFTを求めるコードにローパスフィルタを追加したいのですが、プログラミングの知識がほとんど無く、至急やる必要があり、大変困っております...
3
3
  以下にそのコードを示しました(同時にPDFも求めるコードとなっています)。コードを書いていただけると嬉しい限りです。
4
4
 
5
+ ```python
5
6
  import numpy as np
6
7
  from scipy.signal import butter, lfilter, freqz
7
8
  import matplotlib.pyplot as plt
@@ -75,4 +76,5 @@
75
76
  plt.yscale('log')
76
77
  plt.xlabel("Frequency[Hz]")
77
78
  plt.ylabel("Power")
78
- plt.title("Energy spectrum")
79
+ plt.title("Energy spectrum")
80
+ ```

1

誤字

2021/01/01 13:43

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -9,7 +9,7 @@
9
9
  import scipy.stats
10
10
  from scipy import signal
11
11
  from scipy import integrate
12
- # -*- coding: utf-8 -*-
12
+
13
13
  import numpy as np
14
14
  import matplotlib.pyplot as plt
15
15
 
@@ -39,7 +39,6 @@
39
39
  np.savetxt('%sPDF.csv' %name, result, delimiter=',', header = Header, comments='')
40
40
 
41
41
  SpecHeader = 'f[Hz],E'
42
- # データのパラメータ
43
42
  SN = 524288 # サンプル数
44
43
  fs = 10000 # カットオフ周波数 S/ sec
45
44
  N = SN
@@ -64,9 +63,7 @@
64
63
 
65
64
  freq1 = np.linspace(0, int(fs), SN)
66
65
 
67
- # calculate energy spectrum
68
66
  freq1, P1 = signal.welch(f, fs, nperseg=N / 8)
69
- # freq2, P2 = signal.welch(y, fs, nperseg=n/64)
70
67
  SpectrumResult = np.array([freq1, P1]).T
71
68
  np.savetxt('%d_%dPowerSpectrum.csv'%((i+1)*5, j+1),SpectrumResult,delimiter=',',header = SpecHeader,comments ='')
72
69
  plt.subplot(2, 2, 3)
@@ -78,6 +75,4 @@
78
75
  plt.yscale('log')
79
76
  plt.xlabel("Frequency[Hz]")
80
77
  plt.ylabel("Power")
81
- plt.title("Energy spectrum")
78
+ plt.title("Energy spectrum")
82
-
83
- #plt.show()