コード例 #1
0
    def fireAlarm(self):
        self._getFiftenMiniutesPhotos()  #get current_value
        cur_hour = datetime.utcfromtimestamp(float(self.cur_time)).hour
        #print 'cur_hour = ',cur_hour, 'time = ',self.cur_time
        mu = self.means[cur_hour] / 4.0
        std = self.stds[cur_hour] / 4.0
        #print 'mu is ',mu, 'std is ',std, 'cur_value = ',self.current_value
        zscore = (self.current_value - mu) * 1.0 / std

        if zscore > 3 and self.current_value >= 8:
            e = Event()
            e.setPredictedValues(mu, std)
            e.setZscore(zscore)
            e.setRegion(self.region)
            e.setCreatedTime(self.cur_time)
            e.setActualValue(self.current_value)

            for p in self.photos:
                e.addPhoto(p)

            ei = EventInterface()
            ei.setCollection(self.candidate_collection)
            #print datetime.utcfromtimestamp(float(e.getEarliestPhotoTime())), datetime.utcfromtimestamp(float(e.getLatestPhotoTime()))
            #print e.getEarliestPhotoTime(),e.getLatestPhotoTime()
            #print e.toJSON()['region']
            ei.addEvent(e)
コード例 #2
0
ファイル: run_alarm.py プロジェクト: oeddyo/CityBeat
    def fireAlarm(self):
        prediction = self.getNearestPrediction()

        self._getFiftenMiniutesPhotos()
        if prediction is None:
            print "None data for this region: details as follow"
            self.region.display()
            print "time:", self.cur_time
            return
        mu = float(prediction["mu"]) / 4.0
        std = float(prediction["std"]) / 4.0
        time_stamp = prediction["time"]

        zscore = (self.current_value - mu) * 1.0 / std

        if zscore > 3:
            e = Event()
            e.setPredictedValues(mu, std)
            e.setZscore(zscore)
            e.setRegion(self.region)
            e.setCreatedTime(self.cur_time)
            e.setActualValue(self.current_value)

            for p in self.photos:
                e.addPhoto(p)
            # print 'current value ',4.0*self.current_value, ' predict = ',mu*4.0,' std = ',std*4.0

            ei = EventInterface()
            ei.setCollection(self.candidate_collection)
            print e.getEarliestPhotoTime(), e.getLatestPhotoTime()
            # print e.toJSON()['region']
            # ei.addEvent(e)
            ei.addEventWithoutMerge(e)
コード例 #3
0
    def fireAlarm(self):
        prediction = self.getNearestPrediction()

        self._getFiftenMiniutesPhotos()
        if prediction is None:
            print 'None data for this region: details as follow'
            self.region.display()
            print 'time:', self.cur_time
            return
        mu = float(prediction['mu']) / 4.0
        std = float(prediction['std']) / 4.0
        time_stamp = prediction['time']

        zscore = (self.current_value - mu) * 1.0 / std

        if zscore > 3:
            e = Event()
            e.setPredictedValues(mu, std)
            e.setZscore(zscore)
            e.setRegion(self.region)
            e.setCreatedTime(self.cur_time)
            e.setActualValue(self.current_value)

            for p in self.photos:
                e.addPhoto(p)
            #print 'current value ',4.0*self.current_value, ' predict = ',mu*4.0,' std = ',std*4.0

            ei = EventInterface()
            ei.setCollection(self.candidate_collection)
            print e.getEarliestPhotoTime(), e.getLatestPhotoTime()
            #print e.toJSON()['region']
            #ei.addEvent(e)
            ei.addEventWithoutMerge(e)
コード例 #4
0
ファイル: run_baseline.py プロジェクト: daifanxiang/CityBeat
    def fireAlarm(self):
        self._getFiftenMiniutesPhotos() #get current_value
        cur_hour = datetime.utcfromtimestamp(float(self.cur_time)).hour
        #print 'cur_hour = ',cur_hour, 'time = ',self.cur_time 
        mu = self.means[cur_hour]/4.0
        std = self.stds[cur_hour]/4.0
        #print 'mu is ',mu, 'std is ',std, 'cur_value = ',self.current_value
        zscore = (self.current_value - mu)*1.0/std

        if zscore > 3 and self.current_value>=8:
            e = Event()
            e.setPredictedValues(mu, std)
            e.setZscore(zscore)
            e.setRegion(self.region)
            e.setCreatedTime(self.cur_time)
            e.setActualValue(self.current_value)

            for p in self.photos:
                e.addPhoto(p)
        
            ei = EventInterface( )
            ei.setCollection(self.candidate_collection)
            #print datetime.utcfromtimestamp(float(e.getEarliestPhotoTime())), datetime.utcfromtimestamp(float(e.getLatestPhotoTime()))
            #print e.getEarliestPhotoTime(),e.getLatestPhotoTime()
            #print e.toJSON()['region']
            ei.addEvent(e)