Project

General

Profile

RE: appion failed to generate frame stack ยป getReferences.py

Anchi Cheng, 05/13/2013 09:27 PM

 
#!/usr/bin/env python
import sys
from leginon import leginondata
from leginon import correctorclient

if len(sys.argv) != 2:
print 'getReferences.py filename'
sys.exit()

filename = sys.argv[1]
sessionname = filename.split('_')[0]
if filename[-4:] == '.mrc':
filename = filename[:-4]

sdata = leginondata.SessionData(name=sessionname).query()[0]
results = leginondata.AcquisitionImageData(session=sdata,filename=filename).query()
if not results:
print 'image not found'
sys.exit()

a = results[0]
norm0data = a['norm']
print ''
if not norm0data:
print 'Can not find normalization data from sinedon. See Anchi about this special case'
print sys.exit()
print 'reference session path: %s' % norm0data['session']['image path']

cclient = correctorclient.CorrectorClient()
norm1data = cclient.getAlternativeChannelReference('norm',norm0data)

norms = (norm0data,norm1data)
for normdata in norms:
print ''
print 'CHANNEL %d' % normdata['channel']
darkdata = normdata['dark']
brightdata = normdata['bright']
print 'bright image: %s' % brightdata['filename']

cameraname = a['camera']['ccdcamera']['name']
if cameraname == 'GatanK2Counting' or cameraname == 'GatanK2Super':
print 'dark image values are always zero in counting mode camera'
else:
print 'dark image: %s' % darkdata['filename']
nframes = darkdata['camera']['nframes']
if nframes:
print 'scale dark image down by %d before using it on single frame' % (nframes)
    (1-1/1)