개정판 611e39d5
issue #1461: min max test
Change-Id: I486cb36088c1c88e42c930b419728afd2b95a935
DTI_PID/DTI_PID/HMBDialog.py | ||
---|---|---|
97 | 97 |
import pandas as pd |
98 | 98 |
from HMBTable import HMBData, StreamData |
99 | 99 |
|
100 |
allowed_error = 0.00001 |
|
100 | 101 |
hmb_list = [] |
101 | 102 |
sheets = pd.read_excel(self._file_path, sheet_name=None, header=None, convert_float=False) |
103 |
sheets = list(sheets.items()) |
|
104 |
|
|
105 |
if sheets: |
|
106 |
sheets_name, df = sheets[0] |
|
102 | 107 |
|
103 |
for name, df in sheets.items(): |
|
104 | 108 |
rows, cols = df.shape[0], df.shape[1] |
105 | 109 |
for col in range(2, cols): |
106 | 110 |
stream_no = df.iloc[0, col] |
... | ... | |
130 | 134 |
value = value_ if (type(value_) is str) or (type(value_) is float and not math.isnan(value_)) \ |
131 | 135 |
else '' |
132 | 136 |
|
133 |
data.append(StreamData(name, unit, value, row, name_type)) |
|
137 |
# find min max value |
|
138 |
value_normal = value |
|
139 |
value_max = None |
|
140 |
value_min = None |
|
141 |
|
|
142 |
#if value_normal and value_normal != '-' and len(sheets) > 1: |
|
143 |
if value_normal and type(value_normal) is float and len(sheets) > 1: |
|
144 |
for sheet in sheets[1:]: |
|
145 |
value_ = df.iloc[row, col] |
|
146 |
value = value_ if (type(value_) is str) or (type(value_) is float and not math.isnan(value_)) \ |
|
147 |
else '' |
|
148 |
if value and type(value) is float: |
|
149 |
diff = value_normal - value |
|
150 |
if abs(diff) < allowed_error: |
|
151 |
continue |
|
152 |
|
|
153 |
if diff > 0: |
|
154 |
if value_min is None or value < value_min: |
|
155 |
value_min = value |
|
156 |
elif diff < 0: |
|
157 |
if value_max is None or value > value_max: |
|
158 |
value_max = value |
|
159 |
|
|
160 |
data.append(StreamData(name, unit, value_normal, row, name_type, value_max, value_min)) |
|
134 | 161 |
|
135 | 162 |
hmb.data = data |
136 | 163 |
hmb_list.append(hmb) |
137 |
break |
|
138 | 164 |
|
139 | 165 |
app_doc_data = AppDocData.instance() |
140 | 166 |
app_doc_data.save_hmb_data(hmb_list) |
DTI_PID/DTI_PID/HMBTable.py | ||
---|---|---|
7 | 7 |
|
8 | 8 |
|
9 | 9 |
class StreamData: |
10 |
def __init__(self, name, unit='', value='', index=0, phase=''): |
|
10 |
def __init__(self, name, unit='', value='', index=0, phase='', value_max='', value_min=''):
|
|
11 | 11 |
self.name = name |
12 | 12 |
self.unit = unit |
13 | 13 |
self.value = value |
14 | 14 |
self.index = index |
15 | 15 |
self.phase = phase |
16 |
self.value_max = value_max |
|
17 |
self.value_min = value_min |
|
16 | 18 |
|
17 | 19 |
|
18 | 20 |
class HMBData: |
내보내기 Unified diff