def revertTargetListZ(self, targetlistdata): '''use the z position of the target list parent image''' imageref = targetlistdata.special_getitem('image', dereference=False) imageid = imageref.dbid imagedata = self.researchDBID(leginondata.AcquisitionImageData, imageid, readimages=False) # look for a more recent version of this image target = imagedata['target'] imquery = leginondata.AcquisitionImageData(target=target) allversions = imquery.query(readimages=False) imagedata = allversions[0] scope = imagedata['scope'] z = scope['stage position']['z'] tem = scope['tem'] filename = imagedata['filename'] self.logger.info('returning %s to z=%.4e of parent image %s' % ( tem['name'], z, filename, )) self.instrument.setTEM(tem['name']) self.instrument.tem.StagePosition = {'z': z} self.logger.info('z change done')
def insertAcquisitionImageData(self, imagedata): acquisitionimagedata = leginondata.AcquisitionImageData( initializer=imagedata, version=0) self.setImageFilename(acquisitionimagedata) acquisitionimagedata.attachPixelSize() acquisitionimagedata.insert(force=True) return acquisitionimagedata
def monitorDrift(self, driftdata=None): self.setStatus('processing') self.logger.info('DriftManager monitoring drift...') if driftdata is not None: ## use driftdata to set up scope and camera pname = driftdata['presetname'] emtarget = driftdata['emtarget'] threshold = driftdata['threshold'] target = emtarget['target'] self.presetsclient.toScope(pname, emtarget) presetdata = self.presetsclient.getCurrentPreset() else: target = None threshold = None ## acquire images, measure drift self.abortevent.clear() # extra pause to wait for image shift to stabilize self.logger.info('pausing before loop') time.sleep(self.settings['pause time'] / 2.0) self.logger.info('paused before loop') status, final, im = self.acquireLoop(target, threshold=threshold) if status in ('drifted', 'timeout'): ## declare drift above threshold self.declareDrift('threshold') ## Generate DriftMonitorResultData ## only output if this was called from another node if driftdata is not None: self.logger.info('Publishing final drift image...') acqim = leginondata.AcquisitionImageData(initializer=im) acqim['target'] = target acqim['emtarget'] = emtarget acqim['preset'] = presetdata self.publish(acqim, pubevent=True) self.logger.info('Publishing DriftMonitorResultData...') result = leginondata.DriftMonitorResultData() result['status'] = status result['final'] = final self.publish(result, pubevent=True, database=True, dbforce=True) self.logger.info('DriftManager done monitoring drift') self.setStatus('idle')
def fakeImage(self): # need an existing image name imageq = leginondata.AcquisitionImageData( filename='08oct13d_00045ma_1') results = imageq.query() return results[0]