stanley-king 3 tahun lalu
induk
melakukan
233ce2d0d1
1 mengubah file dengan 9 tambahan dan 10 penghapusan
  1. 9 10
      plot/MchDataCenter.py

+ 9 - 10
plot/MchDataCenter.py

@@ -401,8 +401,8 @@ class MchDataCenter(object):
         return predata
 
     def _calc_mratio(self,data,startes,end):
-        all = data[1] + data[2]
-        ySucc = data[1]
+        succ = data[1]
+        fail = data[2]
         x = np.arange(0, 86400, 1)
 
         result = {}
@@ -414,18 +414,17 @@ class MchDataCenter(object):
 
             pos = np.where(x >= start_pos)
             t = x[pos]
-            _all = all[pos]
-            _succ = ySucc[pos]
+            _fail = fail[pos]
+            _succ = succ[pos]
 
             pos = np.where(t < end)
-            _all = _all[pos]
+            _fail = _fail[pos]
             _succ = _succ[pos]
 
-            succ_count = np.sum(_succ) + 0.00001
-            all_count  = np.sum(_all) + 0.00001
-
-            ratio = round(succ_count / all_count, 4)
-            result[start] = ratio
+            succs = np.sum(_succ)
+            fails  = np.sum(_fail)
+            ratio = round((succs + 0.00001) / (succs + fails + 0.00001), 4)
+            result[start] = [succs, fails, ratio]
         return result
 
     def mratios(self, time_stamp,presecs):