#!/bin/tcsh -f # # # Set default symbol values # # # ident + [firstimagenumber] + extension -> imagename # # if (${?imagename} == 0) then if (${?ident} && ${?extension}) then if (${?firstimagenumber}) then set imagename = "${ident}_${firstimageext}.${extension}" else set imagename = "${ident}.${extension}" endif endif endif # # # [directory] + imagename -> imagepath # # if (${?imagepath}) then unset imagepath endif if (${?imagename}) then if (${?directory}) then set imagepath = ${directory}/${imagename} else set imagepath = ${imagename} endif if (-e ${imagepath} == 0) then unset imagepath endif endif # # # imagename -> firstimagenumber # # #if (${?firstimagenumber} == 0) then if (${?imagename}) then set tmp = `echo ${imagename:t:r} | sed "s/[^0-9]/ /g"` set num = 1 while (${num} <= ${#tmp}) if (${tmp[${num}]} > 0) then set firstimageext = ${tmp[${num}]} set templateext = `echo ${tmp[${num}]} | sed "s/[0-9]/#/g"` @ firstimagenumber = ${tmp[${num}]} endif @ num = ${num} + 1 end endif #endif # # # imagename -> extension # # if (${?extension} == 0) then if (${?imagename}) then set extension = ${imagename:e} endif endif # # # imagename -> ident # # if (${?ident} == 0) then if (${?imagename}) then set ident = `echo "${imagename:t:r}/" | sed "s/_[0-9]*\///g"` endif endif # set template = ${ident}_${templateext}.${extension} # # ident + [firstimagenumber] -> outputroot # # if (${?outputroot} == 0) then if (${?ident}) then if (${?firstimagenumber}) then set outputroot = "${ident}_${firstimageext}" else set outputroot = "${ident}" endif endif endif # # # merge -> outputroot # # if (${?outputroot} == 0) then if (${?merge}) then set outputroot = "${merge[1]:t:r}" endif endif # # # outputroot -> merge # # if (${?merge} == 0) then if (${?outputroot}) then set merge = ("${outputroot}.mtz") endif endif # # # Where was the image collected? # # set scanner = (0 0) # # if (${?extension}) then # # switch (${extension}) case mar1200: case mar1600: case mar1800: case mar2000: case mar2300: case mar2400: case mar3000: case mar3450: if (${?imagepath}) then set scanner = `head -16 ${imagepath} | grep -E "SCANNER +[0-9]+"` if (${#scanner} >= 2) then set scanner = (MAR345 ${scanner[2]}) else set scanner = (MAR345 0) endif endif breaksw case image: set scanner = (MAR300 0) breaksw case tif: case mccd: if (${?imagepath}) then #set scanner = `head ${imagepath} | grep -E "Serial Number *= *[0-9]+" | sed "s/[=;]/ /g"` set scanner = `head -c 4096 ${imagepath} | grep -aE "Serial Number *= *[0-9]+" | sed "s/[=;]/ /g"` if (${#scanner} >= 4) then set scanner = (MAR325 ${scanner[4]}) endif endif breaksw case img: case dck: if (${?imagepath}) then # modified by QP to make it work under linux #set scanner = `head -32 ${imagepath} | grep -E "DETECTOR_SN *= *[0-9]+" | sed "s/[=;]/ /g"` set scanner = `head -c 512 ${imagepath} | grep -E "DETECTOR_SN *= *[0-9]+" | sed "s/[=;]/ /g"` if (${#scanner} >= 2) then if (${scanner[2]} >= 900) then set scanner = (QUANTUM315 ${scanner[2]}) else set scanner = (QUANTUM4 ${scanner[2]}) endif else set scanner = (QUANTUM4 0) endif endif breaksw endsw # # endif # # # Find the matching defaults file # # set defaults = (${cmd}*.default) # # set num = 1 while (${num} <= ${#defaults}) set default = ${defaults[${num}]} set match = `grep -E "scanner +" ${default}` if (${#match} >= 3) then shift match if (${match[1]} == ${scanner[1]} && \ (${match[2]} == ${scanner[2]} || \ ${match[2]} == 0 || \ ${scanner[2]} == 0)) break endif unset default @ num = ${num} + 1 end # # # Set the defaults # # if (${?default}) then awk '/^[a-zA-Z]/ { args = split ($0, arg); \ printf ("if (${?%s} == 0) then\n", arg[1]); \ printf ("set %s = (", arg[1]); \ for (count = 2; count <= args; count++) \ printf (" %s", arg[count]); \ printf (")\n"); \ printf ("endif\n") }' ${default} > ${tmpfile}.default source ${tmpfile}.default rm -f ${tmpfile}.default endif # # if (${?offset} == 0) then set offset = (0 0) endif # # # How big is the image? # # if (${?imagecenter}) then unset imagecenter endif # # if (${?extension}) then # # switch (${extension}) case mar1800: case mar1200: set imagecenter = (90 90) breaksw case mar2400: case mar1600: set imagecenter = (120 120) breaksw case mar3000: case mar2000: set imagecenter = (150 150) breaksw case mar3450: case mar2300: set imagecenter = (172.5 172.5) breaksw case image: if (${?imagepath}) then set i = `od -x ${imagepath} | head -1` else set i = (0 0 0) endif if (${i[2]} =~ [dD]007 || \ ${i[3]} =~ [dD]007 || \ ${i[2]} =~ 07[dD]0 || \ ${i[3]} =~ 07[dD]0) then set imagecenter = (150 150) else set imagecenter = (90 90) endif breaksw #case img: #case dck: # #set imagecenter = (94 94) # #if (${#scanner} >= 2) then #if (${scanner[2]} >= 900) then # #set imagecenter = (157.5 157.5) # #endif #endif # #breaksw # endsw # # endif # # ## Is the beam center defined? # # #if (${?beamcenter} == 0) then # # ## Add an offset to the image center # # #if (${?imagecenter}) then # # ## Calculate the corrected beamcenter # # #awk '{ print $1 + $2, $3 + $4 }' > ${tmpfile} << eof #$offset[1] $imagecenter[1] $offset[2] $imagecenter[2] #eof #set beamcenter = `cat ${tmpfile}` # # #endif #endif # # # Print out all the defined symbols # # echo "" > ${tmpfile} set num = 1 while (${num} <= ${#symbols}) set symbol = "${symbols[${num}]}" @ num = ${num} + 1 if (${symbols[${num}]} != 0 && \ ${symbols[${num}]} != 4) then cat >> ${tmpfile} << eof if (\${?${symbol}}) then echo "${symbol} = \${${symbol}}" endif eof endif @ num = ${num} + 1 end source ${tmpfile} rm -f ${tmpfile} # #