#!/bin/csh -f if ( $#argv < 1 ) then echo "Written up by Yufeng Tong 20070326" echo "Adopted from:" echo " http://structbio.vanderbilt.edu/~sheehan/diffracGallery.html" echo "Tailored for SGC Toronto data naming convention" echo "" echo "This script convert .osc diffraction pattern to jpeg images" echo "and makes a composite jpg file" echo "" echo "Requirement: " echo " ipmosflm -- Usually comes with CCP4" echo " ImageMagick -- Usually installed with your Linux distribution" echo "" echo "Usage: $0 puckname_jobid" echo "Example: $0 hv3_2" exit endif set prefix = `echo $1 | sed -e 's/\(.*\)_\([0-9]\).*/\1/'` set jobid = `echo $1 | sed -e 's/\(.*\)_\([0-9]\).*/\2/'` set curdir = `pwd` set exten01 = "osc" set exten02 = "jpg" set MOSFLM = ipmosflm set oscfiles = `/bin/ls ${prefix}*/Images/*.osc` set imageset = (001 002) set puckset = (1 2 3 4 5 6 7 8 9 10 11 12) set allimages = () foreach ff ($oscfiles) set oscdir = `dirname $ff` # strip off "Images" to have a puck position for each image set puckpos = `dirname $oscdir` cd $oscdir foreach I ($imageset) set imagename = ${puckpos}-${I}.${exten02} if ( -f ${curdir}/${imagename} ) then echo "skip $imagename..." continue endif $MOSFLM << EOF template ${prefix}_screen0###.osc image ${I} xgui on go CREATE_IMAGE BINARY TRUE FILENAME ${imagename} return exit exit EOF mv ${imagename} $curdir end cd $curdir end # combine the images echo "##############################" echo "# Now combining the images #" echo "##############################" foreach I ($imageset) set allimages = () foreach pp ($puckset) set jpgfile = ${prefix}_${jobid}_$pp-$I.${exten02} if (! -f $jpgfile ) then set jpgfile = null: endif set allimages = ($allimages $jpgfile) end montage -geometry 400x400 -label "%f" -tile 3x4 -quality 85 ${allimages} ${prefix}-combined-${I}.jpg end