Exemplo n.º 1
0
    def plot(self, name_plot = None, locator = "Day"):

        x = []
        y = []

        fig = plt.figure()
        fig.suptitle("Cluster (" + str(self.__ini_date) + " ~ " + str(self.__end_date) + ")" ,fontsize=14,fontweight='bold')

        ax = fig.add_subplot(111)
        ax.grid(True)
        ax.set_ylabel("kwh ("+str(self.__min_val)+" ~ "+str(self.__max_val)+")")

        string = ''
        legends = []
        #for id_meter,meter_data in self.__m_ids_meters.items():
        for md_obj in self.get_meters_data():
            for nm_obj in Meter_data.get_normalized_measures(md_obj.id_meter_data):
                smd_obj = Smart_meter_date(nm_obj.date)
                x.append(smd_obj.get_datetime())
                y.append(nm_obj.normalized_measure)

            ax.plot(x,y)
            string = string + str(md_obj.id_meter) + '_'
            x = []
            y = []

        plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%d/%m/%Y %H'))
        if (locator == "Day"):
            plt.gca().xaxis.set_major_locator(mdates.DayLocator())
        else:
            plt.gca().xaxis.set_major_locator(mdates.HourLocator(byhour=range(24), interval=4))
        plt.gcf().autofmt_xdate()

        filename = string if name_plot is None else name_plot

        filename = filename + '.png'

        fig.savefig(filename)
Exemplo n.º 2
0
    def get_interval (self,ini,end,meter_id):
        smd_ini = Smart_meter_date()
        smd_ini.set_datetime(ini.year,ini.month,ini.day,ini.hour,ini.minute)
        
        smd_end = Smart_meter_date()
        smd_end.set_datetime(end.year,end.month,end.day,end.hour,end.minute)

        r = Row_data_dec()

        return session.query(Row_data_dec).filter(Row_data_dec.id_meter == meter_id, Row_data_dec.date >= smd_ini.get_integer_time(), Row_data_dec.date <= smd_end.get_integer_time()).all()
Exemplo n.º 3
0
from classes.raw_data import Raw_data
from classes.date import Smart_meter_date

import datetime
import copy

rd = Raw_data()
meters = rd.get_id_meters()

smd_ini_date = Smart_meter_date()
smd_ini_date.set_datetime(year=2009, month=12, day=21, hour=0, minute=0)

smd_end_date = Smart_meter_date()
smd_end_date.set_datetime(year=2010, month=12, day=21, hour=0, minute=0)
i = 0
weekdays = list(range(0, 6))
d = {}
total_meters = 0
for meter in meters:
    rd = Raw_data(id_meter=meter)
    print(meter)
    d[meter] = rd.get_profile(smd_ini_date, smd_end_date)
    print(d[meter])
    total_meters += 1
    if total_meters > 3000:
        break