def getData(self, scanID): """Fetch logged data of a scan :param scanID: ID of scan :return: Data dictionary Example: >>> data = client.getData(id) >>> print data Format of the data:: { 'device1': {'id': [0, 1, 2, 3, 4 ], 'value': [2.0, 3.0, 4.0, 2.0, 4.0], 'time': [1427913270352, 1427913270470, 1427913270528, 1427913270596, 1427913270695] }, 'device2': {'id': [0, 3, 6, 9, 12], 'value': [1.0, 2.0, 3.0, 4.0, 5.0], 'time': [1427913270351, 1427913270595, 1427913270795, 1427913271076, 1427913271393] } } The data dictionary has one entry per logged device. Its value is again a dictionary with entries id: Sample IDs, starting from 0 value: Sample values time: Times in Posix milliseconds """ url = self.__baseURL + self.__scanResource + '/' + str( scanID) + '/data' xml = self.__do_request(url) return parseXMLData(xml)
def getData(self, scanID): """Fetch logged data of a scan :param scanID: ID of scan :return: Data dictionary Example: >>> data = client.getData(id) >>> print data Format of the data:: { 'device1': {'id': [0, 1, 2, 3, 4 ], 'value': [2.0, 3.0, 4.0, 2.0, 4.0], 'time': [1427913270352, 1427913270470, 1427913270528, 1427913270596, 1427913270695] }, 'device2': {'id': [0, 3, 6, 9, 12], 'value': [1.0, 2.0, 3.0, 4.0, 5.0], 'time': [1427913270351, 1427913270595, 1427913270795, 1427913271076, 1427913271393] } } The data dictionary has one entry per logged device. Its value is again a dictionary with entries id: Sample IDs, starting from 0 value: Sample values time: Times in Posix milliseconds """ url = self.__baseURL + self.__scanResource + '/' + str(scanID)+'/data' xml = self.__do_request(url) return parseXMLData(xml)
</sample> <sample id="13"> <time>1427913271459</time> <value>3.0</value> </sample> <sample id="14"> <time>1427913271559</time> <value>4.0</value> </sample> </samples> </device> </data> """ # client.getData(id) calls this to turn the XML data into a data dict: data = parseXMLData(xml_text) print(data) # Direct access to data dict print("Times: ", [str(getDatetime(time)) for time in data['motor_x']['time']]) print("Values: ", data['motor_x']['value']) # Demo of sample iterator for s in iterateSamples(data, 'motor_x'): print("%s (%2d): %s" % (str(getDatetime(s[1])), s[0], str(s[2]))) # Create table, i.e. align samples for different devices by sample ID: table = createTable(data, 'motor_x', 'motor_y') print(table[0]) print(table[1])
</sample> <sample id="13"> <time>1427913271459</time> <value>3.0</value> </sample> <sample id="14"> <time>1427913271559</time> <value>4.0</value> </sample> </samples> </device> </data> """ # client.getData(id) calls this to turn the XML data into a data dict: data = parseXMLData(xml_text) print data # Direct access to data dict print "Times: ", [ str(getDatetime(time)) for time in data['motor_x']['time'] ] print "Values: ", data['motor_x']['value'] # Demo of sample iterator for s in iterateSamples(data, 'motor_x'): print "%s (%2d): %s" % (str(getDatetime(s[1])), s[0], str(s[2])) # Create table, i.e. align samples for different devices by sample ID: table = createTable(data, 'motor_x', 'motor_y') print table[0] print table[1]