def midpoint(self): slope, intercept = self.compute() # validate... if slope is None: return None, None # x domain... x_data = [x for x, _ in self.__data] min_x = min(x_data) max_x = max(x_data) mid_x = min_x + ((max_x - min_x) / 2) rec = LocalizedDatetime.construct_from_timestamp(mid_x, self.__tzinfo) # y val... val = slope * float(mid_x) + intercept return rec, val
from scs_host.client.http_client import HTTPClient # -------------------------------------------------------------------------------------------------------------------- org_id = "south-coast-science-dev" print(org_id) api_key = "43308b72-ad41-4555-b075-b4245c1971db" print(api_key) topic = "/orgs/south-coast-science-dev/exhibition/loc/1/climate" print(topic) end_date = LocalizedDatetime.now() start_date = LocalizedDatetime.construct_from_timestamp(end_date.timestamp() - 60) print("start: %s" % start_date) print("end: %s" % end_date) print("-") # -------------------------------------------------------------------------------------------------------------------- # manager... manager = MessageManager(HTTPClient(), api_key) print(manager) print("=") messages = manager.find_for_topic(topic, start_date, end_date)