def get_ts(self, project, tablename, datestring, key): """ get Timeseries object for this particular project/tablename/datestring/key combination parameters: project <str> tablename <str> datestring <str> key <tuple> key to identify particular Timeseries returns: <TimeseriesArray> """ index_keynames = self.get_index_keynames(project, tablename) value_keynames = self.get_value_keynames(project, tablename) ts_keyname = self.get_ts_keyname(project, tablename) tsa = TimeseriesArray(index_keynames, value_keynames, ts_keyname) uri_params = { "project" : project, "tablename" : tablename, "datestring" : datestring, "key" : base64.b64encode(unicode(key)), } query_params = {} data = self.__get_json_chunked("get_ts", uri_params, query_params) for row in data: tsa.add(row) return tsa
def get_tsa(self, project, tablename, datestring): """ get TimeseriesArray object for this particular project/tablename/datestring combination parameters: project <str> tablename <str> datestring <str> returns: <TimeseriesArray> """ index_keynames = self.get_index_keynames(project, tablename) value_keynames = self.get_value_keynames(project, tablename) ts_keyname = self.get_ts_keyname(project, tablename) tsa = TimeseriesArray(index_keynames, value_keynames, ts_keyname) uri_params = { "project" : project, "tablename" : tablename, "datestring" : datestring, } query_params = {} data = self.__get_json_chunked("get_tsa", uri_params, query_params) for row in data: tsa.add(row) return tsa
def get_tsa_adv(self, project, tablename, datestring, groupkeys, group_func_name, index_pattern): """ get TimeseriesArray object for this particular project/tablename/datestring combination parameters: project <str> tablename <str> datestring <str> groupkeys <tuple> group_func_name <str> index_pattern <str> returns: <TimeseriesArray> """ value_keynames = self.get_value_keynames(project, tablename) ts_keyname = self.get_ts_keyname(project, tablename) tsa = None if groupkeys is None: index_keynames = self.get_index_keynames(project, tablename) tsa = TimeseriesArray(index_keynames, value_keynames, ts_keyname) else: tsa = TimeseriesArray(groupkeys, value_keynames, ts_keyname) uri_params = OrderedDict() uri_params["project"] = project uri_params["tablename"] = tablename uri_params["datestring"] = datestring uri_params["groupkey_enc"] = base64.b64encode(unicode(groupkeys)) uri_params["group_func_name"] = group_func_name uri_params["index_pattern"] = base64.b64encode(unicode(index_pattern)) query_params = {} data = self.__get_json_chunked("get_tsa_adv", uri_params, query_params) for row in data: tsa.add(row) return tsa
def read_tsa_full_aligned(datestring, slotlength): tsa = datalogger.read_tsa_full(datestring, force=False) print tsa.index_keys, tsa.value_keys, tsa.ts_key tsa2 = TimeseriesArray(tuple(tsa.index_keys), list(tsa.value_keys), str(tsa.ts_key)) for data in dump_and_align(tsa, slotlength): tsa2.add(data) print "new times" print sorted(tsa2[tsa2.keys()[0]].get_times()) assert tsa != tsa2 assert all(key in tsa2.keys() for key in tsa.keys()) assert len(tsa) == len(tsa2) return tsa2