Project

General

Profile

logging errors and other messages in Leginon

Added by Anonymous over 18 years ago

In Leginon, each of the nodes logs error, warning and other types of messages in a window with a scroll bar. It is possible to scroll through the recent history of messages. It would be useful to have the errors and other messages output to a log file; so the messages can be examined later outside of Leginon either for convenience or if Leginon terminates abnormally. Is it possible to do this in Leginon at present with some option? (I am currently interested in this type of feature because I want to investigate the amount of drift that occurs with two different cold specimen holders - the microscopists think that one cold holder has a lot more problems with drift than the other - and I would like to have the messages coming from the Drift Manager and Focus nodes in a log file so I can examine them after Leginon has been running late at night),

William


Replies (2)

- Added by Jim Pulokas over 18 years ago

There is a way to store all logging into the database, but it has not been tested very much. Rather than using the logging feature, I would suggest getting the raw drift data which is already being stored in the database. This can be done either by writing a python script or by writing a raw mysql query. I'll give an example of a python script below.

The drift measurements are stored in the database in a table called DriftData. This contains all drift measurements, both from Focuser and DriftManager. The raw image shift measured from the cross correlation is stored in this table in pixels, so if you want to convert to meters, you need to multiply these values by the binning you used, and by the pixel size for that magnification.

Here is an example of a python script that does the query, converts to meters/second and outputs to stdout which you could pipe into a file or whatever:

#!/usr/bin/env python

import sys
import math

# these modules are installed as part of Leginon
import data
import dbdatakeeper

# first command line arg is the session name
mysession = sys.argv[1]

# open a connection to the DB
# (this automatically gets config info from your leginon.cfg)
db = dbdatakeeper.DBDataKeeper()

# function to get all drift measurements for a given session name
def getdrift(session_name):

# create a query object

sessionquery = data.SessionData(name=session_name)

driftquery = data.DriftData(session=sessionquery)

# do the query

results = db.query(driftquery)

return results

# function to get the pixelsize for a given drift measurement
def getpixsize(driftdata):

tem = driftdata['scope']['tem']

cam = driftdata['camera']['ccdcamera']

mag = driftdata['scope']['magnification']

pquery = data.PixelSizeCalibrationData(tem=tem, ccdcamera=cam, magnification=mag)

results = db.query(pquery, results=1)

return results[0]['pixelsize']

# query for drift measurements
driftresults = getdrift(mysession)
# they are returned in reverse chronological order, so reverse
driftresults.reverse()

# assuming all drift measurements done at same mag and binning
# we can get them now, instead of inside the loop below
pixelsize = getpixsize(driftresults[0])
binning = driftresults[0]['camera']['binning']['x']

# print out timestamp and drift rate in meters/sec
for drift in driftresults:

isotime = drift.timestamp.isoformat()

driftpixels = math.hypot(drift['rows'], drift['cols'])

interval = drift['interval']

# pixelsize and binning already found before the loop

driftrate = pixelsize * binning * driftpixels / interval

print '%s %s' % (isotime, driftrate)

Store that in a file called getdrift.py, then make it executable:
chmod u+x getdrift.py
then run it with any session name:
getdrift.py 06may03b
That will give you two columns, timestamp and drift rate. There are of course many ways to modify that script to get a personalized output.

timing report in version 1.4.1 - Added by Anonymous almost 17 years ago

I'm not sure how to activate/ use the new feature in Leginon - mentioned in the manual - to save a timing report in the database and also how to access the timing data in the database (or is this just by doing SQL queries on whatever are the relevant tables?)

William

    (1-2/2)