def calculate_latest_coeffs(self):
unit_topic_tmpl = "{campus}/{building}/{unit}/{point}"
unit_points = [self.fan_power_name, self.static_pressure_name, self.air_flow_rate_name]
df = None
for point in unit_points:
unit_topic = unit_topic_tmpl.format(campus=self.site,
building=self.building,
unit=self.unit,
point=point)
result = self.vip.rpc.call('platform.historian',
'query',
topic=unit_topic,
count=self.no_of_recs_needed,
order="LAST_TO_FIRST").get(timeout=1000)
df2 = pd.DataFrame(result['values'], columns=[self.ts_name, point])
self.convert_units_to_SI(df2, point, result['metadata']['units'])
df2[self.ts_name] = pd.to_datetime(df2[self.ts_name])
df2 = df2.groupby([pd.TimeGrouper(key=self.ts_name, freq=self.aggregate_freq)]).mean()
#df2[self.ts_name] = df2[self.ts_name].apply(lambda dt: dt.replace(second=0, microsecond=0))
df = df2 if df is None else pd.merge(df, df2, how='outer', left_index=True, right_index=True)
#print(df)
coeffs = self.calculate_coeffs(df)
# Publish coeffs to store
if coeffs is not None:
self.save_coeffs(coeffs)
评论列表
文章目录