def animate_price_bar_graph(i): all_data_map = data_service.get_all_data_map() is_active = data_service.get_active() if is_active == "3_2": data_service.update_all_data_map( data_service.get_date_tab3_interval()[0], data_service.get_date_tab3_interval()[1]) prices_graph_ax.set(xlabel='t ℃ (вісь Х)', ylabel='грн. (вісь У)', title='Затрати на опалення відносно температур') prices_graph_ax.grid() prices_2d_list_of_maps = tab3_service.calc_prices_via_coef( all_data_map) width = 1 for prices in prices_2d_list_of_maps: xs = list(prices.keys()) ys = list(prices.values()) prices_graph_ax.bar(xs, ys, width, color=(random.uniform(0, 1), random.uniform(0, 1), random.uniform(0, 1)), alpha=0.3)
def animate_4_1_graph(i): is_active = data_service.get_active() print("animate active is ", is_active) if is_active == "4_1": map_tab4 = tab4_service.reform_standard_speed_w_map_for_new_h() xs = list(map_tab4.keys()) ys = list(map_tab4.values()) xs = [int(x) for x in xs] ys = [float(y) for y in ys] _4_1_graph_ax.clear() # _4_1_graph_ax.axis('equal') # # make the y ticks integers, not floats # yint = [] # locs, labels = plt.yticks() # for each in locs: # yint.append(int(each)) # plt.yticks(yint) _4_1_graph_ax.set(xlabel='w, (м/с)', ylabel='W, кВт', title='Енергетична характеристика ВЕУ') _4_1_graph_ax.grid() _4_1_graph_ax.plot(xs, ys, linestyle='-', linewidth='1', markersize=5, marker='o', label="t ℃ ") plt.yticks(np.arange(min(ys), max(ys) + 1, 1.0))
def animate_Q_waste_graph(i): all_data_map = data_service.get_all_data_map() is_active = data_service.get_active() print("animate active is ", is_active) if is_active == "3_1": print("dateeee", data_service.get_date_tab3_interval()) data_service.update_all_data_map( data_service.get_date_tab3_interval()[0], data_service.get_date_tab3_interval()[1]) plot_data = tab3_service.get_all_needed_Q_for_warming_less_than_desired( all_data_map) print("3-1 data:", plot_data) xs = my_service.restore_lost_data(plot_data[0]) ys = my_service.restore_lost_data(plot_data[1]) Q_waste_graph_ax.clear() Q_waste_graph_ax.set(xlabel='t ℃ (вісь У)', ylabel='Q, кВт', title='Температурні умови') Q_waste_graph_ax.grid() Q_waste_graph_ax.plot( xs, ys, # linestyle='-', # linewidth='0.8', markersize=5, label="t ℃ ")
def animate_temperature_duration_graph(i): all_data_map=data_service.get_all_data_map() is_active = data_service.get_active() if is_active == "1_2": data_service.update_all_data_map(data_service.get_start_date(), data_service.get_end_date()) map_t_freq = tab1_service.map_temperature_duration(all_data_map) xs = list(map_t_freq.keys()) ys = list(map_t_freq.values()) temperature_regime_duration_graph_ax.clear() final_data = [xs, ys] table = temperature_regime_duration_graph_ax.table(cellText=final_data, loc='top', cellLoc='center', bbox=[0.0, -0.45, 1, .28]) temperature_regime_duration_graph_fig.subplots_adjust(bottom=0.3) table.auto_set_font_size(False) table.set_fontsize(5) # table.auto_set_column_width((-1, 0, 1, 2, 3)) for (row, col), cell in table.get_celld().items(): if row == 0: cell.set_text_props(fontproperties=FontProperties(weight='normal', size=4)) for key, cell in table.get_celld().items(): cell.set_linewidth(0.1) temperature_regime_duration_graph_ax.set(xlabel='t ℃ (вісь Х)', ylabel='год. (вісь У)', title='Тривалість температурних режимів') temperature_regime_duration_graph_ax.grid() temperature_regime_duration_graph_ax.bar(xs, ys)
def animate_solar_activity_duration_graph(i): cut_bank_muni_ap_map=data_service.get_cut_bank_muni_ap_map() is_active = data_service.get_active() if is_active == "1_6": data_service.update_cut_bank_muni_ap_map() map_t_freq = tab1_service.map_solar_activity_duration(cut_bank_muni_ap_map) xs = list(map_t_freq.keys()) ys = list(map_t_freq.values()) solar_duration_graph_ax.clear() solar_duration_graph_ax.set(xlabel='Вт/м² (вісь Х)', ylabel='год. (вісь У)', title='Тривалість режимів сонячної активності') solar_duration_graph_ax.grid() solar_duration_graph_ax.bar(xs, ys)
def animate_insolation_graph(i): cut_bank_muni_ap_map=data_service.get_cut_bank_muni_ap_map() is_active = data_service.get_active() if is_active == "1_5": data_service.update_cut_bank_muni_ap_map() xs = (cut_bank_muni_ap_map['fullDate']) ys = (cut_bank_muni_ap_map['etrn']) # date = [item.date() for item in xs] solar_insolation_graph_ax.clear() solar_insolation_graph_ax.set(xlabel='дата (вісь Х)', ylabel='Вт/м² (вісь У)', title='Інтенсивність сонячної інсоляції ') solar_insolation_graph_ax.grid() solar_insolation_graph_ax.bar(xs, ys, width=0.3)
def animate_wind_duration_graph(i): all_data_map=data_service.get_all_data_map() is_active = data_service.get_active() if is_active == "1_4": data_service.update_all_data_map(data_service.get_start_date(), data_service.get_end_date()) map_t_freq = tab1_service.map_wind_duration(all_data_map) xs = list(map_t_freq.keys()) ys = list(map_t_freq.values()) wind_duration_graph_ax.clear() wind_duration_graph_ax.set(xlabel='м/с (вісь Х)', ylabel='год. (вісь У)', title='Тривалість режимів вітрової активності вітрів ') wind_duration_graph_ax.grid() wind_duration_graph_ax.bar(xs, ys)
def animate_5_1_graph(i): is_active = data_service.get_active() print("animate active is ", is_active) if is_active == "5_1": # map_tab5 = tab5_service.populate_tab5_general_data() map_tab5 = tab5_service.tab5_gen_data Ts = list(map_tab5[0]) Hrs = list(map_tab5[1]) Ps = tab5_service.calc_Ps_by_nasos() # Ps = list(map_tab5[2]) Qs = list(map_tab5[3]) # print("LLL:", len(Ts), len(Hrs), len(Ps), len(Qs)) table_data = [] for row_i in range(len(Ts)): table_data.append([]) table_data[row_i].append(round(Ts[row_i], 3)) table_data[row_i].append(round(Hrs[row_i], 3)) table_data[row_i].append(round(Ps[row_i], 3)) table_data[row_i].append(round(Qs[row_i], 3)) # print(table_data) table = _5_1_graph_ax.table(cellText=table_data, loc='center', colLabels=[ "Темпаратура, ℃", "Сумарна тривалість, год", "Потужність, кВт", "Вироблена Енергія, кВт*год" ]) table.auto_set_font_size(False) table.set_fontsize(8) for (row, col), cell in table.get_celld().items(): if row == 0: cell.set_text_props( fontproperties=FontProperties(weight='normal', size=8)) for key, cell in table.get_celld().items(): cell.set_linewidth(0.5) table_data1 = [["%6.2f" % sum(Qs)]] table1 = _5_1_graph_ax.table( cellText=table_data1, loc='top', cellLoc='center', # bbox=[0.76, 0., 0.14, .05]) bbox=[0.70, -0.13, 0.29, .05]) _5_1_graph_ax.axis('off') _5_1_graph_ax.grid()
def animate_warmer_price_bar_graph(i): # all_data_map = data_service.get_all_data_map() is_active = data_service.get_active() if is_active == "3_3": # data_service.update_all_data_map(data_service.get_date_tab3_interval()[0], # data_service.get_date_tab3_interval()[1]) warmer_price = tab3_service.obtain_map_price_warmers() print(warmer_price) xs = list(warmer_price.keys()) ys = list(warmer_price.values()) warmer_prices_graph_ax.clear() warmer_prices_graph_ax.set( xlabel='t ℃ (вісь Х)', ylabel='грн. (вісь У)', title='Витрати енергії на опалення за визначений період') warmer_prices_graph_ax.grid() warmer_prices_graph_ax.bar(xs, ys)
def animate_temperature_graph(i): all_data_map = data_service.get_all_data_map() is_active = data_service.get_active() print("a", is_active) if is_active == "1_1": data_service.update_all_data_map(data_service.get_start_date(), data_service.get_end_date()) xs = my_service.restore_lost_data(all_data_map['fullDate']) ys = my_service.restore_lost_data(all_data_map['T']) date = [item.date() for item in xs] temperature_graph_ax.clear() temperature_graph_ax.set(xlabel='дата (вісь Х)', ylabel='t ℃ (вісь У)', title='Температурні умови') temperature_graph_ax.grid() temperature_graph_ax.plot_date(date, ys, linestyle='-', linewidth='0.3', markersize=1, label="t ℃ ")
def animate_2_3_graph(i): is_active = data_service.get_active() print("a", is_active) if is_active == "2_3": # map_day_Wt = tab2_service.get_all_devices_sum_of_consumption_for_each_day() map_day_Wt = tab2_service.get_all_devices_sum_of_consumption_for_each_day_by_hrs( ) xs = list(map_day_Wt.keys()) ys = list(map_day_Wt.values()) _2_3_graph_ax.clear() _2_3_graph_ax.set(xlabel='час', ylabel='W, Вт', title='Тижневий графік навантаження ') _2_3_graph_ax.grid() for tick in _2_3_graph_ax.get_xticklabels(): tick.set_rotation(70) tick.set_fontsize(4) _2_3_graph_ax.plot(xs, ys, linestyle='-', linewidth='2', markersize=4)
def animate_2_2_graph(i): is_active = data_service.get_active() print("a", is_active) if is_active == "2_2": all_cons_map = tab2_service.get_all_devices_consumption_that_day() xs = list(all_cons_map.keys()) ys = list(all_cons_map.values()) _2_2_graph_ax.clear() _2_2_graph_ax.set(xlabel='час (вісь Х)', ylabel='W, Вт', title='Сумарний графік навантаження за день') _2_2_graph_ax.grid() width = np.min(np.diff(mdates.date2num(xs))) # Define the date format date_form = DateFormatter("%H:%M") _2_2_graph_ax.xaxis.set_major_formatter(date_form) # Ensure ticks fall once every other week (interval=2) _2_2_graph_ax.xaxis.set_major_locator(mdates.HourLocator(interval=2)) _2_2_graph_ax.bar(xs, ys, width=width, ec="k")
def animate_windrose_graph(i): all_data_map=data_service.get_all_data_map() is_active = data_service.get_active() if is_active == "1_3": data_service.update_all_data_map(data_service.get_start_date(), data_service.get_end_date()) ws = my_service.restore_lost_data(all_data_map['FF']) wd = my_service.restore_lost_data(all_data_map['dd']) ws_scale_1 = tab1_service.map_speed_to_scale_one(ws) wd = tab1_service.map_compass_to_degrees(wd) # hide axes windrose_graph_fig.patch.set_visible(False) windrose_graph_ax.axis('off') windrose_graph_ax.axis('tight') ws_frequency_map = tab1_service.map_ws_by_frequency(ws) final_data = [list(ws_frequency_map.keys()), list(ws_frequency_map.values())] table = windrose_graph_ax.table(cellText=final_data, loc='top', cellLoc='center', rowLabels=[" м/с ", " % "], bbox=[0., 0., 0.23, .28]) windrose_graph_fig.subplots_adjust(bottom=0.6) table.auto_set_font_size(False) table.set_fontsize(7) for (row, col), cell in table.get_celld().items(): if row == 0: cell.set_text_props(fontproperties=FontProperties(weight='normal', size=7)) for key, cell in table.get_celld().items(): cell.set_linewidth(0.5) # windrose_graph_fig.clear() rect = [0.1, 0.1, 0.8, 0.8] wa = WindroseAxes(windrose_graph_fig, rect) windrose_graph_fig.add_axes(wa) windrose_graph_ax.grid() wa.bar(wd, ws_scale_1, normed=True, opening=0.8, edgecolor='white') # wa.set_legend() wa.set_legend(title="інтенсивність", loc="upper right")
def animate_2_1_2_graph(i): is_active = data_service.get_active() print("a", is_active) if is_active == "2_1_2": all_devices = data_service.get_electric_consumption_devices() intersected_map = tab2_service.intersected_map_of_device_usage( all_devices["cooker"]) # date = [item.date() for item in xs] xs = list(intersected_map.keys()) ys = list(intersected_map.values()) _2_1_2_graph_ax.clear() _2_1_2_graph_ax.set(xlabel='час (вісь Х)', ylabel='W, Вт', title='Графік навантаження плити') _2_1_2_graph_ax.grid() width = np.min(np.diff(mdates.date2num(xs))) # Define the date format date_form = DateFormatter("%H:%M") _2_1_2_graph_ax.xaxis.set_major_formatter(date_form) # Ensure ticks fall once every other week (interval=2) _2_1_2_graph_ax.xaxis.set_major_locator(mdates.HourLocator(interval=2)) _2_1_2_graph_ax.bar(xs, ys, width=width, ec="k")
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) is_active = data_service.get_active() if is_active != "1_6": data_service.set_active("1_6") form_tab1_subtab(self, controller, solar_duration_graph_fig)
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) is_active = data_service.get_active() if is_active != "2_1_1": data_service.set_active("2_1_1") form_tab2_subtab_for_1_graph(self, controller, _2_1_1_graph_fig)
def animate_4_2_graph(i): is_active = data_service.get_active() print("animate active is ", is_active) if is_active == "4_2": map_tab4 = tab4_service.reform_standard_speed_w_map_for_new_h() # speed = list(map_tab4.keys()) # dur = list(data_service.get_tab4_map_speed_dur().values()) #todo # P = list(map_tab4.values()) # E = tab4_service.calc_energy_tab4(map_tab4) tab4_data = tab4_service.get_tab4_data_full() speed = list(tab4_data.speed_list) dur = list(tab4_data.duration_list) P = list(tab4_data.p_list) E = list(tab4_data.e_list) print("LLL:", len(speed), len(dur), len(P), len(E)) table_data = [] for row_i in range(len(speed)): table_data.append([]) table_data[row_i].append(round(float(speed[row_i]), 3)) table_data[row_i].append(round(float(dur[row_i]), 3)) table_data[row_i].append(round(float(P[row_i]), 3)) table_data[row_i].append(round(float(E[row_i]), 3)) # print(table_data) table = _4_2_graph_ax.table(cellText=table_data, loc='center', colLabels=[ "швидкість вітру, м/с", "сумарна тривалість, год", "Потужність ВЕУ, кВт", "Вироблена Енергія, кВт*год" ]) table.auto_set_font_size(False) table.set_fontsize(12) for (row, col), cell in table.get_celld().items(): if row == 0: cell.set_text_props( fontproperties=FontProperties(weight='normal', size=10)) for key, cell in table.get_celld().items(): cell.set_linewidth(0.5) table_data1 = [ [ "Всього енергії вироблено", "%6.2f" % tab4_service.calc_sum_energy_tab4(map_tab4) + " кВт*год" ], [ "Дохід від продажу електричної енергії за «зеленим» тарифом", "%.0f" % tab4_service.calc_tab4_income_from_sell_energy(map_tab4) + " €" ], [ "Дохід від продажу одиниць скорочення викидів (ОСВ)", "%.0f" % tab4_service.calc_tab4_income_from_OSV(map_tab4) + " €" ] ] table1 = _4_2_graph_ax.table(cellText=table_data1, loc='bottom', cellLoc='center') # table.set_fontsize(14) # table.scale(1, 4) _4_2_graph_ax.axis('off') _4_2_graph_ax.grid()
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) is_active = data_service.get_active() if is_active != "1_2": data_service.set_active("1_2") form_tab1_subtab(self, controller, temperature_regime_duration_graph_fig)
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) is_active = data_service.get_active() if is_active != "1_3": data_service.set_active("1_3") form_tab1_subtab(self, controller, windrose_graph_fig)
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) is_active = data_service.get_active() if is_active != "3_3": data_service.set_active("3_3") form_tab3_subtab(self, controller, warmer_prices_graph_fig)
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) is_active = data_service.get_active() if is_active != "5_2": data_service.set_active("5_2") form_tab5_subtab(self, controller, _5_2_graph_fig)
def animate_5_2_graph(i): is_active = data_service.get_active() print("animate active is ", is_active) if is_active == "5_2": K_kor_Qtn = tab5_service.calc_K_Qtn_koef() Q_rob_TN = tab5_service.calc_Q_rob_TN() K_kor_ES = tab5_service.calc_K_kor_ES_koef() P_cons_TN = tab5_service.calc_P_consumed_TN() N_blocks = tab5_service.calc_N_blocks() P_aux_warmer = tab5_service.calc_P_aux_warmer() K_zavant = tab5_service.calc_K_zavant() P_cyrcyl_nasos = tab5_service.calc_P_cyrcyl_nasos_for_all() W_cons_TN = tab5_service.calc_W_cons_TN() W_cons_system = tab5_service.calc_W_cons_system() Q_tn = tab5_service.calc_Q_TN() Q_aux_warmer = tab5_service.calc_Q_aux_warmer() table_data = [] for row_i in range(len(K_kor_Qtn)): table_data.append([]) table_data[row_i].append(round(K_kor_Qtn[row_i], 3)) table_data[row_i].append(round(Q_rob_TN[row_i], 3)) table_data[row_i].append(round(K_kor_ES[row_i], 3)) table_data[row_i].append(round(P_cons_TN[row_i], 3)) table_data[row_i].append(round(N_blocks[row_i], 3)) table_data[row_i].append(round(P_aux_warmer[row_i], 3)) table_data[row_i].append(round(K_zavant[row_i], 3)) table_data[row_i].append(round(P_cyrcyl_nasos[row_i], 3)) table_data[row_i].append(round(W_cons_TN[row_i], 3)) table_data[row_i].append(round(W_cons_system[row_i], 3)) table_data[row_i].append(round(Q_tn[row_i], 3)) table_data[row_i].append(round(Q_aux_warmer[row_i], 3)) # print(table_data) table = _5_2_graph_ax.table( cellText=table_data, loc='center', colLabels=[ "K кор. Qтн", "Q роб., кВт", "К кор.ЕС", "Р спож. ТН., кВт", "N блоків", "Р догрівача, кВт", "К завант.", "Р цирк. нас., кВт", "W спож. ТН, кВт*год.", "W спож. сист, кВт*год.", "Q тн, кВт*год.", "Q догр., кВт*год." ]) table.auto_set_font_size(False) table.set_fontsize(8) for (row, col), cell in table.get_celld().items(): if row == 0: cell.set_text_props( fontproperties=FontProperties(weight='normal', size=8)) for key, cell in table.get_celld().items(): cell.set_linewidth(0.5) table_data1 = [[ "%6.2f" % (sum(W_cons_TN)), "%6.2f" % (sum(W_cons_system)), "%6.2f" % (sum(Q_tn)), "%6.2f" % (sum(Q_aux_warmer)) ]] table1 = _5_2_graph_ax.table(cellText=table_data1, loc='top', cellLoc='center', bbox=[0.67, -0.13, 0.33, .05]) # bbox - left bottom angle - x,y,width,height table_data1 = [["COP = " + "%6.2f" % (tab5_service.calc_SOR_syst())]] table1 = _5_2_graph_ax.table(cellText=table_data1, loc='top', cellLoc='center', bbox=[0.0, -0.13, 0.33, .05]) _5_2_graph_ax.axis('off') _5_2_graph_ax.grid()
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) is_active = data_service.get_active() if is_active != "3_1": data_service.set_active("3_1") form_tab3_subtab(self, controller, Q_waste_graph_fig)