Generate XDS.INP: Difference between revisions

Jump to navigation Jump to search
(rev 0.65)
(→‎The script: fix typo)
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
This script generates XDS.INP based on a list of frame names supplied on the commandline. It currently works for MarCCD, ADSC, Pilatus and a few Rigaku detectors; since this is just a bash script, extension to other detectors is very easy.
This script generates XDS.INP based on a list of frame names supplied on the commandline. It currently works for MarCCD, ADSC, Pilatus, Eiger, some Rigaku and one Bruker detector(s); since this is just a bash script, extension to other detectors should be very easy.
 
The [[Eiger]] detector is not yet implemented in the script, but this will eventually come.


== Usage ==
== Usage ==
Line 17: Line 15:
# purpose: generate XDS.INP                                                   
# purpose: generate XDS.INP                                                   
#                                                                             
#                                                                             
# tested with some datasets from ALS, SSRL, SLS, ESRF, BESSY, SPring-8 and PF; only MAR, ADSC/SMV, PILATUS, RAXIS (in-house) detectors;  
# tested with some datasets from ALS, SSRL, SLS, ESRF, BESSY, SPring-8 and PF; only MAR, ADSC/SMV, PILATUS, Eiger, RAXIS (in-house), Bruker (PHOTON II) detectors;  
# for other detectors, values marked with XXX must be manually filled in.                                   
# for other detectors, values marked with XXX must be manually filled in.                                   
#                                                                                                           
#                                                                                                           
Line 83: Line 81:
# revision 0.64 . KD 16/06/2016 reverse phi @APS 19ID (reported by Wolfram Tempel)
# revision 0.64 . KD 16/06/2016 reverse phi @APS 19ID (reported by Wolfram Tempel)
# revision 0.65 . Keitaro 07/09/2016 Fix for "too many arguments" problem in ls
# revision 0.65 . Keitaro 07/09/2016 Fix for "too many arguments" problem in ls
REVISION="0.65 (07-Sep-2016)"
# revision 0.66 . KD 15/09/2016 add Bruker PHOTON II with .cbf frames
REVISION="0.66 (15-Sep-2016)"
#                                                                                                             
#                                                                                                             
# usage: e.g. generate_XDS.INP "/file/system/frms/mydata_1_???.img"                                                       
# usage: e.g. generate_XDS.INP "/file/system/frms/mydata_1_???.img"                                                       
Line 122: Line 121:
SENSOR_THICKNESS=0   
SENSOR_THICKNESS=0   
TRUSTED_REGION="0.0 1.2 ! partially use corners of detector (0 1.4143: use all pixels)"                                                                                           
TRUSTED_REGION="0.0 1.2 ! partially use corners of detector (0 1.4143: use all pixels)"                                                                                           
# default MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT
MNOPIAS=3
# default DIRECTION_OF_DETECTOR_X-AXIS
DIRECTION_OF_DETECTOR_X_AXIS="1 0 0"
# default FRACTION_OF_POLARIZATION
pol_frac=0.98


dname=`echo "$1" | xargs dirname`
dname=`echo "$1" | xargs dirname`
Line 147: Line 152:
  # Find the first '?' position and the number of '?' to determine DATA_RANGE=.
  # Find the first '?' position and the number of '?' to determine DATA_RANGE=.
  pos1=`echo "$NAME_TEMPLATE_OF_DATA_FRAMES" | awk '{print index($0, "?")}'`
  pos1=`echo "$NAME_TEMPLATE_OF_DATA_FRAMES" | awk '{print index($0, "?")}'`
  pos2=`echo "$NAME_TEMPLATE_OF_DATA_FRAMES" | sed -e "s/[^\?]//g" | awk '{print length+'$pos1' - 1'}`
  pos2=`echo "$NAME_TEMPLATE_OF_DATA_FRAMES" | sed -e "s/[^\?]//g" | awk '{print length+'$pos1' - 1}'`
  data_first=`cat tmp1 | cut -b $pos1-$pos2 | head -n1|bc`
  data_first=`cut -b $pos1-$pos2 tmp1 | head -n1 | bc`
  data_last=`cat tmp1 | cut -b $pos1-$pos2 | tail -n1|bc`
  data_last=`cut -b $pos1-$pos2 tmp1 | tail -n1 | bc`
  DATA_RANGE="$data_first $data_last"
  DATA_RANGE="$data_first $data_last"
   
   
Line 191: Line 196:
  grep -q "^SOURCE_WAVELENGTH= *1" tmp2 && DET=dtrek
  grep -q "^SOURCE_WAVELENGTH= *1" tmp2 && DET=dtrek
  grep -q BEAM_CENTER_X tmp2      && DET=adsc                                 
  grep -q BEAM_CENTER_X tmp2      && DET=adsc                                 
  grep -q mar345 tmp2 && DET=MAR345                        
  grep -q mar345 tmp2 && DET=MAR345    
grep -q BRUKER tmp2 && grep -q CBF tmp2  && DET=Bruker-cbf                   
else
else
  h5dump -d "/entry/instrument/detector/description" $FIRSTFRAME | grep -i Eiger > /dev/null && DET=eiger
  h5dump -d "/entry/instrument/detector/description" $FIRSTFRAME | grep -i Eiger > /dev/null && DET=eiger
Line 500: Line 506:
   GONIO_NAMES=(`grep ${dname}GONIO_NAMES= tmp2 | tail -1 | sed s/.*_GONIO_NAMES=//`)
   GONIO_NAMES=(`grep ${dname}GONIO_NAMES= tmp2 | tail -1 | sed s/.*_GONIO_NAMES=//`)
   GONIO_VALUES=(`grep ${dname}GONIO_VALUES= tmp2 | tail -1 | sed s/.*_GONIO_VALUES=//`)
   GONIO_VALUES=(`grep ${dname}GONIO_VALUES= tmp2 | tail -1 | sed s/.*_GONIO_VALUES=//`)
  GONIO_UNITS=(`grep ${dname}GONIO_UNITS= tmp2 | tail -1 | sed s/.*_GONIO_UNITS=//`)
GONIO_UNITS=(`grep ${dname}GONIO_UNITS= tmp2 | tail -1 | sed s/.*_GONIO_UNITS=//`)
   for i in `seq 1 ${#GONIO_NAMES[*]}`
   for i in `seq 1 ${#GONIO_NAMES[*]}`
   do
   do
Line 535: Line 541:
  OSCILLATION_RANGE=`grep 'PHI' tmp2 | awk '{print $5-$3}'`     
  OSCILLATION_RANGE=`grep 'PHI' tmp2 | awk '{print $5-$3}'`     
  TRUSTED_REGION="0 0.99"         
  TRUSTED_REGION="0 0.99"         
elif [ "$DET" == "Bruker-cbf" ]; then
 
echo  "Data from a Bruker-cbf detector"
# conversion radian / degrees:
DEGTOR=57.2957795
# MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT:
MNOPIAS=6
# use complete detector including corners:
TRUSTED_REGION="0 1.42"       
# polarization
pol_frac=`awk '/polarizn_source_ratio/{print $2}' tmp2`
pol_frac=`echo "${pol_frac}+0.5" | bc -l`
OVERLOAD=`awk '/_array_intensities.overload/{print $2}' tmp2`
DETECTOR="BRUKER MINIMUM_VALID_PIXEL_VALUE=0 OVERLOAD=${OVERLOAD}"
NX=`awk '/X-Binary-Size-Fastest-Dimension/{print $2}' tmp2`
NY=`awk '/X-Binary-Size-Second-Dimension/{print $2}' tmp2`
QX=`awk '/ELEMENT_X ELEMENT_X/{print $4}' tmp2`
QY=`awk '/ELEMENT_Y ELEMENT_Y/{print $4}' tmp2`
# ORGX/Y-offsets relative to center of detector:
ORGX=`grep " 0 0 ? ? ?" tmp2 | awk '/ H /{print $2}'`
ORGY=`grep " 0 0 ? ? ?" tmp2 | awk '/ V /{print $2}'`
# total ORGX/Y
ORGX=`echo "scale=2; ${NX}/2+($ORGX/$QX)" | bc -l`
ORGY=`echo "scale=2; ${NY}/2-($ORGY/$QY)" | bc -l`
DETECTOR_DISTANCE=`grep "0 0 ? ? ?" tmp2 | awk '/DX /{print $2}'`
X_RAY_WAVELENGTH=`awk '/diffrn_radiation_wavelength.wavelength/{print $2}' tmp2`
OMEGA=`awk '/OMEGA \? \? \?/{print $5}' tmp2`
DELTAOMEGA=`awk '/OMEGA \? \? \?/{print $6}' tmp2`
PHI=`awk '/PHI \? \? \?/{print $5}' tmp2`
DELTAPHI=`awk '/PHI \? \? \?/{printf "%5.4f",$6}' tmp2`
KAPPA=`awk '/CHI \? \? \?/{print $5}' tmp2`
echo OMEGA DELTAOMEGA PHI DELTAPHI KAPPA= $OMEGA $DELTAOMEGA $PHI $DELTAPHI $KAPPA
# test whether the absolute value of deltaphi is > absolute value of deltaomega
if (( $(echo "${DELTAPHI}^2 > ${DELTAOMEGA}^2"|bc -l) )); then
    echo PHI scan
    R3=`echo "scale=7; s($KAPPA/$DEGTOR)*s($OMEGA/$DEGTOR)" | bc -l`
    R1=`echo "scale=7; s($KAPPA/$DEGTOR)*c($OMEGA/$DEGTOR)" | bc -l`
    R2=`echo "scale=7; c($KAPPA/$DEGTOR)          " | bc -l`
    rotation_axis="$R1 $R2 $R3"
    OSCILLATION_RANGE=${DELTAPHI}
# here we could check if DELTAPHI is <0, and if so, negate it and rotation_axis
else
    echo OMEGA scan
    rotation_axis="0 -1 0"
    OSCILLATION_RANGE=${DELTAOMEGA}
# here we could check if DELTAOMEGA is <0, and if so, negate it and rotation_axis
fi
# 2theta
  TWOTHETA=`awk '/TWOTHETA \? \? \?/{print $5}' tmp2`
  echo TWOTHETA=$TWOTHETA
  R1=`echo "scale=7; c($TWOTHETA/$DEGTOR)" | bc -l`
  R3=`echo "scale=7; s($TWOTHETA/$DEGTOR)" | bc -l`
  DIRECTION_OF_DETECTOR_X_AXIS="$R1 0 $R3"
# end of Bruker-cbf section
else
else
   echo should never come here
   echo should never come here
Line 584: Line 648:
VALUE_RANGE_FOR_TRUSTED_DETECTOR_PIXELS=6000. 30000. ! often 7000 or 8000 is ok
VALUE_RANGE_FOR_TRUSTED_DETECTOR_PIXELS=6000. 30000. ! often 7000 or 8000 is ok
STRONG_PIXEL=4          ! COLSPOT: only use strong reflections (default is 3)
STRONG_PIXEL=4          ! COLSPOT: only use strong reflections (default is 3)
MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT=3 ! default of 6 is sometimes too high
MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT=$MNOPIAS ! default of 6 is sometimes too high
! close spots/long cell axis: reduce SEPMIN and CLUSTER_RADIUS from their defaults of 6 and 3
! close spots/long cell axis: reduce SEPMIN and CLUSTER_RADIUS from their defaults of 6 and 3
! SEPMIN=4  CLUSTER_RADIUS=2 ! should be default for Pilatus and other detectors with low PSF
! SEPMIN=4  CLUSTER_RADIUS=2 ! should be default for Pilatus and other detectors with low PSF
Line 626: Line 690:
  else
  else
  cat >> XDS.INP << eof
  cat >> XDS.INP << eof
DIRECTION_OF_DETECTOR_X-AXIS=1 0 0
DIRECTION_OF_DETECTOR_X-AXIS=$DIRECTION_OF_DETECTOR_X_AXIS
DIRECTION_OF_DETECTOR_Y-AXIS=0 1 0
DIRECTION_OF_DETECTOR_Y-AXIS=0 1 0
eof
eof
Line 632: Line 696:
  cat >> XDS.INP << eof
  cat >> XDS.INP << eof
INCIDENT_BEAM_DIRECTION=0 0 1
INCIDENT_BEAM_DIRECTION=0 0 1
FRACTION_OF_POLARIZATION=0.98   ! better value is provided by beamline staff!
FRACTION_OF_POLARIZATION=${pol_frac}   ! better value is provided by beamline staff!
POLARIZATION_PLANE_NORMAL=0 1 0
POLARIZATION_PLANE_NORMAL=0 1 0
eof
eof
Line 649: Line 713:
!EXCLUDE_RESOLUTION_RANGE= 1.751 1.691 !ice-ring at 1.721 Angstrom - weak
!EXCLUDE_RESOLUTION_RANGE= 1.751 1.691 !ice-ring at 1.721 Angstrom - weak
eof
eof
if [ "$DET" == "pilatus" -o "$DET" == "eiger" ]; then
if [ "$DET" == "Bruker-cbf" ]; then
  echo "DELPHI=15 ! refine less often than the default of 5" >> XDS.INP
elif [ "$DET" == "pilatus" -o "$DET" == "eiger" ]; then
cat >> XDS.INP << eof
cat >> XDS.INP << eof
SEPMIN=4 CLUSTER_RADIUS=2
SEPMIN=4 CLUSTER_RADIUS=2
2,652

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu