class Hour(SeriesNode): span = delta(hours=1) def __init__(self, startdatetime, enddatetime, data, type='json', treeIndex={}): super(Hour, self).__init__(startdatetime, enddatetime, data, type=type) if treeIndex != {}: self.treeIndex = treeIndex self.id = self.startdatetime.strftime("%y%m%d%H") def __str__(self): return 'Hour ' + self.id + ':'
class Weeks(SeriesNode): span = delta(weeks=1) def __init__(self, startdatetime, enddatetime, data, type='json', treeIndex={}): super(Weeks, self).__init__(startdatetime, enddatetime, data, type=type) if treeIndex != {}: self.treeIndex = treeIndex self.id = self.startdatetime.strftime( "%y%V") + "-" + self.enddatetime.strftime("%y%V") def __str__(self): return 'Weeks from ' + self.startdatetime.strftime( "%Y%m%d%H%M") + ' to ' + self.enddatetime.strftime( "%Y%m%d%H%M") + ":" def buildtree(self): self.aggregate(Week, self.up2down, self.left2right) return self # vertical grouping @staticmethod def up2down(self, child): self.add_child(child) ## up2down child.statistic() child.buildtree() # horizontal groupign @staticmethod def left2right(self, child): self.treeIndex['weekly'].append(child)
class Day(SeriesNode): span = delta(hours=1) def __init__(self, startdatetime, enddatetime, data, type='json', treeIndex={}): super(Day, self).__init__(startdatetime, enddatetime, data, type=type) if treeIndex != {}: self.treeIndex = treeIndex self.id = self.startdatetime.strftime("%y%m%d") def __str__(self): return 'Day ' + self.id + ':' def buildtree(self): self.aggregate(Hour, self.up2down, self.left2right) return self # vertical grouping @staticmethod def up2down(self, child): self.add_child(child) ## up2down child.statistic() ## uncomment the following line if it is not leaf ADS #child.buildtree() # horizontal groupign @staticmethod def left2right(self, child): self.treeIndex['hourly'].append(child)