回答編集履歴

2

コメントアウトしてたミス

2018/09/26 12:04

投稿

takey
takey

スコア312

test CHANGED
@@ -34,8 +34,6 @@
34
34
 
35
35
 
36
36
 
37
- """
38
-
39
37
  listT = []
40
38
 
41
39
  listV = []
@@ -44,7 +42,7 @@
44
42
 
45
43
  listV = filename['value']
46
44
 
47
- """
45
+
48
46
 
49
47
  type = input('please input type.\n1:curve\r2:average')
50
48
 

1

プログラムミス

2018/09/26 12:04

投稿

takey
takey

スコア312

test CHANGED
@@ -4,7 +4,87 @@
4
4
 
5
5
  ```python
6
6
 
7
+ from scipy.optimize import curve_fit
8
+
9
+ import seaborn as sns
10
+
11
+
12
+
13
+ import sys
14
+
15
+ import codecs as cd # 追加
16
+
17
+ import pandas as pd
18
+
19
+ import numpy as np
20
+
21
+ import matplotlib.pyplot as plt
22
+
23
+
24
+
25
+ sys.setrecursionlimit(100000)
26
+
27
+ filepath = input('please input file path.')
28
+
7
- filename = pd.read_csv(filepath, encoding="shift-jis", "ignore")
29
+ #filename = pd.read_csv(filepath, encoding="SHIFT-JIS", "ignore") # コメントアウト
30
+
31
+ with cd.open(filepath, "r", "shift-jis", "ignore") as csv_file: # 追加
32
+
33
+ filename = pd.read_table(csv_file)
34
+
35
+
36
+
37
+ """
38
+
39
+ listT = []
40
+
41
+ listV = []
42
+
43
+ listT = filename['time']
44
+
45
+ listV = filename['value']
46
+
47
+ """
48
+
49
+ type = input('please input type.\n1:curve\r2:average')
50
+
51
+ if type == '1':
52
+
53
+ res = np.polyfit(listT,listV,10)
54
+
55
+ y2 = np.poly1d(res)(listT)
56
+
57
+ plt.figure(figsize=(20,10))
58
+
59
+ plt.plot(listT,listV,label='ori')
60
+
61
+ plt.plot(listT,y2,label='curve_fit')
62
+
63
+ else:
64
+
65
+ num = 10000
66
+
67
+ b = np.ones(num)/num
68
+
69
+ y2 = np.convolve(listV, b, mode='same')
70
+
71
+ plt.figure(figsize=(20,10))
72
+
73
+ plt.plot(listT,listV, label='ori')
74
+
75
+ plt.plot(listT,y2, label='ave')
76
+
77
+
78
+
79
+ plt.legend()
80
+
81
+ plt.show()
82
+
83
+
84
+
85
+ input()
86
+
87
+
8
88
 
9
89
  ```
10
90