def datum(self, sample): if not sample.has_path(self.__path): return None try: rec_node = sample.node('rec') except KeyError: return None rec = LocalizedDatetime.construct_from_jdict(rec_node) value = sample.node(self.__path) self.__func.append(rec, value) if not self.__func.has_regression(): return None slope, intercept = self.__func.line() if slope is None: return None target = PathDict() if sample.has_path('rec'): target.copy(sample, 'rec') target.append(self.__path + '.src', value) target.append(self.__path + '.slope', round(slope, self.__precision)) target.append(self.__path + '.intercept', round(intercept, self.__precision)) return target.node()
def datum(self, sample): if not sample.has_path(self.__path): return None rec = LocalizedDatetime.construct_from_jdict(sample.node('rec')) value = sample.node(self.__path) self.__func.append(rec, value) if not self.__func.has_tally(): return None mid_rec, mid = self.__func.midpoint() if rec is None: return None target = PathDict() target.append('rec', rec) target.append('mid-rec', mid_rec) target.append(self.__path + '.src', value) target.append(self.__path + '.mid', round(mid, 6)) return target.node()
def datum(self, sample): if not sample.has_path(self.__path): return None try: rec_node = sample.node('rec') except KeyError: return None rec = LocalizedDatetime.construct_from_jdict(rec_node) value = sample.node(self.__path) self.__func.append(rec, value) if not self.__func.has_midpoint(): return None mid_rec, mid = self.__func.midpoint() if rec is None: return None target = PathDict() target.append('rec', rec.as_iso8601()) target.append('mid-rec', mid_rec.as_iso8601()) target.append(self.__path + '.src', value) target.append(self.__path + '.mid', round(mid, self.__precision)) return target.node()
def datum(self, sample): if not sample.has_path(self.__path): return None rec = LocalizedDatetime.construct_from_jdict(sample.node('rec')) value = sample.node(self.__path) self.__func.append(rec, value) if not self.__func.has_tally(): return None slope, intercept = self.__func.compute() if slope is None: return None target = PathDict() target.copy(datum, 'rec') target.append(self.__path + '.src', value) target.append(self.__path + '.slope', round(slope * 60 * 60, 6)) # x-scale is hours target.append(self.__path + '.intercept', round(intercept, 6)) return target.node()
def construct_from_jdict(cls, jdict): if not jdict: return None client_id = jdict.get('client-id') path = jdict.get('path') earliest_publication = LocalizedDatetime.construct_from_jdict(jdict.get('earliest-pub')) client_id = DeviceTopic(client_id, path, earliest_publication) return client_id
def construct_from_message_jdict(cls, jdict): if not jdict: return None client_id = jdict.get('device') path = jdict.get('topic') earliest_publication = LocalizedDatetime.construct_from_jdict(jdict.get('date')) client_id = DeviceTopic(client_id, path, earliest_publication) return client_id
def construct_from_jdict(cls, jdict): if not jdict: return None rec = LocalizedDatetime.construct_from_jdict(jdict.get('rec')) period = jdict.get('per') pm1 = jdict.get('pm1') pm2p5 = jdict.get('pm2.5') pm10 = jdict.get('pm10') bins = jdict.get('bin') bin_1_mtof = jdict.get('mtf1') bin_3_mtof = jdict.get('mtf3') bin_5_mtof = jdict.get('mtf5') bin_7_mtof = jdict.get('mtf7') return OPCDatum(rec, pm1, pm2p5, pm10, period, bins, bin_1_mtof, bin_3_mtof, bin_5_mtof, bin_7_mtof)