Spaces:
Build error
Build error
Luis commited on
Commit ·
df944a0
1
Parent(s): 393095a
mod light_list with clamp_list
Browse files
analysis_db.py
CHANGED
|
@@ -16,9 +16,9 @@ def read_db(db_file):
|
|
| 16 |
return read_section(db_name, 'tb_section', '')
|
| 17 |
|
| 18 |
|
| 19 |
-
def read_section(db_name, tb_name='tb_section'
|
| 20 |
res_fig = None
|
| 21 |
-
debug_print('read_section, db_name = ', db_name, ', tb_name = ', tb_name
|
| 22 |
conn = sqlite3.connect(db_name)
|
| 23 |
|
| 24 |
if not tb_name:
|
|
@@ -28,22 +28,34 @@ def read_section(db_name, tb_name='tb_section', section_id=''):
|
|
| 28 |
print('table_names = ', str(table_names))
|
| 29 |
return
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
|
|
|
| 39 |
res_fig = read_sample(conn, section_id, tb_name)
|
| 40 |
-
else:
|
| 41 |
-
res_fig = read_sample(conn, section_id, tb_name)
|
| 42 |
-
|
| 43 |
conn.close()
|
|
|
|
| 44 |
return res_fig
|
| 45 |
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
def read_sample(conn, section_id, tb_name):
|
| 48 |
sql_str = ' SELECT section_id, _sample_id, _sample_end_id, section_date, section_end_date FROM ' + str(
|
| 49 |
tb_name) + ' WHERE section_id == ' + str(section_id)
|
|
@@ -86,12 +98,12 @@ def read_sample(conn, section_id, tb_name):
|
|
| 86 |
title_str = str(section_id) + ', ' + str(format_date(section_date)) + ', ' + str(format_date(section_end_date))
|
| 87 |
|
| 88 |
if len(light_list) > 0:
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
screen_list =
|
| 93 |
-
|
| 94 |
-
|
| 95 |
|
| 96 |
|
| 97 |
if __name__ == '__main__':
|
|
@@ -105,5 +117,4 @@ if __name__ == '__main__':
|
|
| 105 |
|
| 106 |
db_uri = argv[0] if argc >= 1 else ''
|
| 107 |
tb_name = argv[1] if argc >= 2 else ''
|
| 108 |
-
|
| 109 |
-
read_section(db_uri, tb_name, section_id)
|
|
|
|
| 16 |
return read_section(db_name, 'tb_section', '')
|
| 17 |
|
| 18 |
|
| 19 |
+
def read_section(db_name, tb_name='tb_section'):
|
| 20 |
res_fig = None
|
| 21 |
+
debug_print('read_section, db_name = ', db_name, ', tb_name = ', tb_name)
|
| 22 |
conn = sqlite3.connect(db_name)
|
| 23 |
|
| 24 |
if not tb_name:
|
|
|
|
| 28 |
print('table_names = ', str(table_names))
|
| 29 |
return
|
| 30 |
|
| 31 |
+
section_cursor = conn.execute(' SELECT section_id, section_date, section_end_date, section_mark FROM ' + tb_name)
|
| 32 |
+
for section_row in section_cursor:
|
| 33 |
+
section_id = section_row[0]
|
| 34 |
+
section_date = section_row[1]
|
| 35 |
+
section_end_date = section_row[2]
|
| 36 |
+
section_mark = section_row[3]
|
| 37 |
+
if section_mark == -1:
|
| 38 |
+
print('section_id = ', section_id, ', section_date = ', str(section_date), ', section_end_date = ',
|
| 39 |
+
str(section_end_date))
|
| 40 |
res_fig = read_sample(conn, section_id, tb_name)
|
|
|
|
|
|
|
|
|
|
| 41 |
conn.close()
|
| 42 |
+
|
| 43 |
return res_fig
|
| 44 |
|
| 45 |
|
| 46 |
+
def clamp(_value, _min, _max):
|
| 47 |
+
if _value < _min:
|
| 48 |
+
return _min
|
| 49 |
+
elif _value > _max:
|
| 50 |
+
return _max
|
| 51 |
+
else:
|
| 52 |
+
return _value
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def clamp_list(_list, _min, _max):
|
| 56 |
+
return [clamp(x, _min, _max) for x in _list]
|
| 57 |
+
|
| 58 |
+
|
| 59 |
def read_sample(conn, section_id, tb_name):
|
| 60 |
sql_str = ' SELECT section_id, _sample_id, _sample_end_id, section_date, section_end_date FROM ' + str(
|
| 61 |
tb_name) + ' WHERE section_id == ' + str(section_id)
|
|
|
|
| 98 |
title_str = str(section_id) + ', ' + str(format_date(section_date)) + ', ' + str(format_date(section_end_date))
|
| 99 |
|
| 100 |
if len(light_list) > 0:
|
| 101 |
+
light_list = clamp_list(light_list, 0, 100)
|
| 102 |
+
|
| 103 |
+
if len(screen_list) > 0:
|
| 104 |
+
screen_list = min_max_list(screen_list, 1, 11)
|
| 105 |
+
|
| 106 |
+
return draw_lists(title_str, date_list, max=max_list, min=min_list, acc=acc_list, light=light_list, screen=screen_list)
|
| 107 |
|
| 108 |
|
| 109 |
if __name__ == '__main__':
|
|
|
|
| 117 |
|
| 118 |
db_uri = argv[0] if argc >= 1 else ''
|
| 119 |
tb_name = argv[1] if argc >= 2 else ''
|
| 120 |
+
read_section(db_uri, tb_name)
|
|
|
util/__pycache__/date_util.cpython-38.pyc
ADDED
|
Binary file (368 Bytes). View file
|
|
|
util/__pycache__/debug.cpython-38.pyc
ADDED
|
Binary file (353 Bytes). View file
|
|
|