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)
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)