def insert_table_brightness(brightness_values): colnames = [ "timestamp", "srgb", "vrgb", "vrgb_lin", "intensity", "luminance" ] vals = [] for name in colnames: vals.append(brightness_values[name]) vals_str_list = ["%s"] * len(vals) vals_str = ", ".join(vals_str_list) cols = ', '.join(colnames) sql = """INSERT INTO public.brightness ({cols}) VALUES ({vals_str})""".format( cols=cols, vals_str=vals_str) db_mac.execute((sql, vals))
from _collections import defaultdict import db_mac import matplotlib.pyplot as plt import numpy as np from matplotlib.pyplot import MultipleLocator sql = """select object, img_url from od2 where object is not null and timestamp::time > '07:59:00'::time and timestamp::time <= '16:40:00'::time and weather_status like 'Clouds' """ falses = defaultdict(list) result = db_mac.execute(sql) for row in result: if len(row[0].split(",")) > 5: falses["falses"].append(row[1]) falsepositves = [] for v in falses.values(): falsepositves = v yes_step = defaultdict(int) no_step = defaultdict(int) percentage = defaultdict(int) sql = """ select humidity, count(*) as cnt from od2 where humidity is not null and bound like 'in' and img_url not in """ + str( tuple(falsepositves) ) + """ and timestamp::time > '07:59:00'::time and timestamp::time <= '16:40:00'::time and object is not null group by 1
import matplotlib.pyplot as plt import numpy as np from _collections import defaultdict import db_mac from matplotlib.pyplot import MultipleLocator sql = """select object, img_url from od2 where object is not null """ falses = defaultdict(list) result = db_mac.execute(sql) for row in result: if len(row[0].split(",")) > 5: falses["falses"].append(row[1]) falsepositves = [] for v in falses.values(): falsepositves = v print(falsepositves) sql = """with nn as (select DISTINCT(DATE(timestamp)) as date1, count(*) as count1 from od2 where object is not null and bound = 'in' and img_url not in """ + str( tuple(falsepositves)) + """ group by 1 order by 1 asc), nn2 as (select DISTINCT(DATE(timestamp)) as date2, count(*) as count2
import db_mac import matplotlib.pyplot as plt import numpy as np from matplotlib.ticker import (MultipleLocator) sql = """select det_dist_surf + 4191, altitude from od2 where bound like 'in' """ data = np.array(list(db_mac.execute(sql))).T det_dist = [round(i) for i in data[0, :]] alt = [round(i) for i in data[1, :]] fig, ax = plt.subplots(figsize=(10, 4)) ax.grid(True) ax.set_title('Detektionsentfernung im Geofence') ax.margins(0) ax.axvline(x=4191, color='red') ax.set_ylim(min(alt), 1000) ax.set_xlim(0, 11000) ax.yaxis.set_major_locator(MultipleLocator(100)) ax.xaxis.set_major_locator(MultipleLocator(1000)) ax.set(ylabel="Höhe in Meter") ax.set( xlabel="Distanz zum Zentroid (E:382983 N:5824610 (UTM-33N WGS84) in Meter") ax.scatter(det_dist, alt, 0.1) plt.show() # 1 # 20 # 21
from collections import OrderedDict from collections import defaultdict import db_mac import matplotlib.pyplot as plt import numpy as np from matplotlib.pyplot import MultipleLocator sql = """select object, img_url from od2 where object is not null and timestamp::time > '07:59:00'::time and timestamp::time <= '16:40:00'::time and weather_status like 'Clouds' """ falses = defaultdict(list) result = db_mac.execute(sql) for row in result: if len(row[0].split(",")) > 5: falses["falses"].append(row[1]) falsepositves = [] for v in falses.values(): falsepositves = v false_pos2 = [ "/home/pi/Desktop/project/img/d_c__in_2020_01_08-08_04_53.png", "/home/pi/Desktop/project/img/d_c__in_2020_01_09-17_38_02.png", "/home/pi/Desktop/project/img/d_c__in_2020_01_09-17_40_03.png", "/home/pi/Desktop/project/img/d_c__in_2020_01_09-17_42_49.png", "/home/pi/Desktop/project/img/d_c__in_2020_01_13-16_27_44.png", "/home/pi/Desktop/project/img/d_c__in_2020_01_13-16_36_43.png", "/home/pi/Desktop/project/img/d_c__in_2020_01_09-17_35_53.png", "/home/pi/Desktop/project/img/d_c__in_2020_01_13-16_34_46.png" ]
import db_mac import numpy as np import pandas as pd from matplotlib import pyplot # series = read_csv('daily-minimum-temperatures.csv', header=0, index_col=0, parse_dates=True, squeeze=True) timestamps = [] intensity = [] result = db_mac.execute( "select * from brightness where timestamp > '2020-01-10' and timestamp < '2020-01-11'" ) for row in result: timestamps.append(row[0]) intensity.append(float(row[-1])) print(timestamps) print(intensity) data = np.array(intensity) series = pd.Series(data, index=timestamps) series.plot() pyplot.show() "https://machinelearningmastery.com/time-series-data-visualization-with-python/" "https://www.geeksforgeeks.org/python-pandas-series/"