def after_simulation(ctrltree, datfile, opener, mpart_opener, options): print 'comparing measurements' import numpy as np runid = ctrltree.getroot().attrib['runid'] url = options.url + '/transferResultAtLocIDs?worker=%s&runid=%s' % (WORKER_ID, runid) vi = VolumeImage() for i in range(3): try: vi.read(datfile) except Exception: time.sleep(0.5) else: break #~ dbdata = vi.asDecibelData(-130) result = {} print 'all locations: ', ctrltree.getroot().xpath('locations/loc') for e in ctrltree.getroot().xpath('locations/loc'): locid, x, y, z = e.attrib['id'], e.attrib['x'], e.attrib['y'], e.attrib['z'] #estimated = vi.data[vi.translate(float(x), float(y), float(z))] estimated = vi.getPoint(float(x), float(y), float(z)) print 'loc id:', locid, estimated #~ if np.isnan(estimated): #~ result[locid] = -130 #~ else: result[locid] = estimated params = urllib.urlencode({'data': str(result)}) # transfer string repr of dict try: opener.open(url, data=params) except Exception: log.exception('cannot send data to %s' % url) else: log.info('transmitted locid data')