Generate XDS.INP: Difference between revisions

Jump to navigation Jump to search
→‎The script: Add support for Pilatus 12M, give help if $5 defined, i.e. unquoted frame pattern
m (→‎The script: correct typo)
(→‎The script: Add support for Pilatus 12M, give help if $5 defined, i.e. unquoted frame pattern)
Line 12: Line 12:


<pre>
<pre>
#!/bin/bash
#!/bin/bash
# purpose: generate XDS.INP
# purpose: generate XDS.INP
Line 143: Line 142:
# revision 1.16 . KD 26/05/2023 fix bug on Mac for Pilatus CBF missing two lines
# revision 1.16 . KD 26/05/2023 fix bug on Mac for Pilatus CBF missing two lines
# revision 1.17 . JMK 31/05/2023 fix sed error for Mac, where \| is not supported
# revision 1.17 . JMK 31/05/2023 fix sed error for Mac, where \| is not supported
REVISION="1.17 (31-May-2023)"
# revision 1.18 . JMK 19/08/2023 Pilatus 12M support, give help msg if $5 defined (i.e. unquoted frame pattern)
REVISION="1.18 (19-Aug-2023)"


#
#
Line 160: Line 160:
#
#
# ====== Start of script ======
# ====== Start of script ======
echo generate_XDS.INP version $REVISION . Obtain the latest version from
echo generate_XDS.INP version $REVISION. Obtain the latest version from
echo http://wiki.uni-konstanz.de/xds/index.php/generate_XDS.INP
echo http://wiki.uni-konstanz.de/xds/index.php/generate_XDS.INP
if [ "$1" == "help" ] || [ "$1" == "-help" ] || [ "$1" == "-h" ] || [ "$1" == "" ] || ! [[ "$1" =~ \?\?|_master\.h5 ]]; then
if [ "$1" == "help" ] || [ "$1" == "-help" ] || [ "$1" == "-h" ] || [ "$1" == "" ] || [ "$5" != "" ] || ! [[ "$1" =~ \?\?|_master\.h5 ]]; then
   echo usage: generate_XDS.INP \"/file/system/frms/mydata_1_???.img\"  \(_with_ the quotation marks!\)
   echo usage: generate_XDS.INP \"/file/system/frms/mydata_1_???.img\"  \(_with_ the quotation marks!\)
   echo If the frames are compressed leave out the extension .bz2, .gz, or .xz!
   echo If the frames are compressed leave out the extension .bz2, .gz, or .xz!
Line 736: Line 736:


elif [ "$DET" == "raxis" ]; then
elif [ "$DET" == "raxis" ]; then
   echo Data from a RAXIS detector
   echo Data from an RAXIS detector


   DETECTOR="RAXIS MINIMUM_VALID_PIXEL_VALUE=0  OVERLOAD=2000000"
   DETECTOR="RAXIS MINIMUM_VALID_PIXEL_VALUE=0  OVERLOAD=2000000"
Line 983: Line 983:
fi
fi
if [ "$ROTATION_AXIS" != "" ]; then
if [ "$ROTATION_AXIS" != "" ]; then
  ROTATION_AXIS="$ROTATION_AXIS  ! only read by IDXREF"
  ROTATION_AXIS="$ROTATION_AXIS  ! only read by IDXREF"
elif [ "$REVERSE_PHI" == "no" ]; then
elif [ "$REVERSE_PHI" == "no" ]; then
  ROTATION_AXIS='1 0 0  ! Australian Synchrotron, SERCAT ID-22 (?), APS 19-ID (?), ESRF BM30A, SPring-8, SSRF need -1 0 0. Diamond ID24 needs 0 -1 0'
  ROTATION_AXIS='1 0 0  ! Australian Synchrotron, SERCAT ID-22 (?), APS 19-ID (?), ESRF BM30A, SPring-8, SSRF need -1 0 0. Diamond ID24 needs 0 -1 0'
else
else
  ROTATION_AXIS='-1 0 0  ! Default; if this is wrong, please contact author.'
  ROTATION_AXIS='-1 0 0  ! Default; if this is wrong, please contact author.'
fi
fi


# Append 2-theta comment if defined
# Append 2-theta comment if defined
if (( $(echo "${TWOTHETA}0 != 0"|bc -l) )); then
if (( $(echo "${TWOTHETA}0 != 0"|bc -l) )); then
    COMMENT_ORGXY="$COMMENT_ORGXY
  COMMENT_ORGXY="$COMMENT_ORGXY
! TWOTHETA=$TWOTHETA -- if fails, check DIRECTION_OF_DETECTOR_X-AXIS"
! TWOTHETA=$TWOTHETA -- information only, do not uncomment. If indexing fails, check DIRECTION_OF_DETECTOR_X-AXIS"
fi
 
if [ "$DET" == "pilatus" -a "$NX" == "2463" -a "$NY" == "5071" ] || [ $DETECTOR_DISTANCE -eq 0 ]; then
  SEGMENTED=1
fi
fi


# now we know almost everything that is required to generate XDS.INP
# now we know almost everything that is required to generate XDS.INP
# --------- Generate XDS.INP containing all defined parameters ----------
cat > XDS.INP << eof
cat > XDS.INP << eof
!=============================================================================
!=============================================================================
Line 1,088: Line 1,093:


eof
eof
# --------- Append additional detector-specific parameters ----------
if [ "$DET" == "Bruker-cbf" ]; then
if [ "$DET" == "Bruker-cbf" ]; then
   echo "DELPHI=15 ! refine less often than the default of 5" >> XDS.INP
   echo "DELPHI=15 ! refine less often than the default of 5" >> XDS.INP
Line 1,100: Line 1,106:
!                                                  and does not seem to have any downsides.
!                                                  and does not seem to have any downsides.
eof
eof
# -------- Append known detector untrusted regions ------------------
   if [ "$NX" == "1028"  -a "$NY" == "1062" ]; then
   if [ "$NX" == "1028"  -a "$NY" == "1062" ]; then
# Eiger2 1M ; v0.97 numbers from Andreas Förster
# Eiger2 1M ; v0.97 numbers from Andreas Förster
Line 1,109: Line 1,116:
     cat >> XDS.INP << eof
     cat >> XDS.INP << eof
! the following specifications are for a detector _without_ proper
! the following specifications are for a detector _without_ proper
! flat_field correction; they cut away one additional pixel adjacent
! flat_field correction; they mask one additional pixel adjacent
! to each UNTRUSTED_RECTANGLE
! to each UNTRUSTED_RECTANGLE
!EXCLUSION OF VERTICAL DEAD AREAS OF THE PILATUS 2M DETECTOR
!EXCLUSION OF VERTICAL DEAD AREAS OF THE PILATUS 2M DETECTOR
Line 1,148: Line 1,155:
  UNTRUSTED_RECTANGLE=    0 2069  1612 1651
  UNTRUSTED_RECTANGLE=    0 2069  1612 1651
eof
eof
   elif [ "$NX" == "2463" ]; then
   elif [ "$NX" == "2463" -a "$NY" == "2527" ]; then
# Pilatus 6M
# Pilatus 6M
# FIXME: here we could test if a Flat_field correction was applied like we do for 2M
# FIXME: here we could test if a Flat_field correction was applied like we do for 2M
Line 1,226: Line 1,233:
  UNTRUSTED_RECTANGLE=    0 4149  3812 3851
  UNTRUSTED_RECTANGLE=    0 4149  3812 3851
eof
eof
  elif [ "$NX" == "2463" -a "$NY" == "5071" ]; then
    : # handled above, before writing XDS.INP, untrusted regions come from site file
  else
    echo "**** WARNING ****"
    echo "Unknown Pilatus or Eiger detector, add UNTRUSTED regions and SEGMENT information manually"
   fi
   fi
fi
fi
# Mechanism to append detector-specific parameters without editing this file:
# Mechanism to append detector-specific parameters without editing this file:
# TODO: some detectors don't set DET_SN so this is not always unique
# NOTE: some detectors don't set DET_SN so this is not always unique
test "$DET_SN" != "" && DET="${DET}_$DET_SN"
# If the detector name is present in $DET_SN, then use only $DET_SN
if [ "$DET_SN" != "" ]; then
  echo "$DET_SN" | grep -qi "$DET" && DET="$DET_SN" || DET="${DET}_$DET_SN"
fi
DET=$(echo $DET | sed 's/ /_/g;s/[^-_A-Za-z0-9]//g;')
DET=$(echo $DET | sed 's/ /_/g;s/[^-_A-Za-z0-9]//g;')
file="$HOME/.xds-site/$DET"
site_file="$HOME/.xds-site/$DET"
if [ -f $file ]; then
if [ -f $site_file ]; then
   echo Appending site parameters from: $file
   echo Appending site parameters from: $site_file
   echo "! Parameters from $file" >> XDS.INP
   echo "! Parameters from $site_file" >> XDS.INP
   echo "Site parameters:"
   echo "Site parameters:"
   cat $file
   cat $site_file | head -20
  [ $(wc -l $site_file | awk '{print $1}') -gt 20 ] && echo "... (truncated)"
   echo
   echo
   # Only FRACTION_POLARIZATION and ROTATION_AXIS are commented out automatically because they
   # Only FRACTION_POLARIZATION and ROTATION_AXIS are commented out automatically because they
   # are the most likely to not match defaults
   # are the most likely to not match defaults.
  # For segmented detectors, also allow origin and distance to be replaced
   # Also likely adjustments are UNTRUSTED regions and maybe SILICON, but those don't replace existing parameters
   # Also likely adjustments are UNTRUSTED regions and maybe SILICON, but those don't replace existing parameters
   # Create a pattern like "XX\|YY" to search overriden parameters.
   # Create a pattern like "XX\|YY" to search overriden parameters.
   pattern=$(grep "POLARIZATION\|ROTATION_AXIS\|TRUSTED_REGION" $file | \
   REDEF_TOKENS="POLARIZATION\|ROTATION_AXIS\|TRUSTED_REGION"
            awk 'match($0,/^ *(\w+) *=/,a){x=x"\\|"a[1];}END{print substr(x,3);}')
  [ "$NEED_SITE_FILE" != "" ] && REDEF_TOKENS=$REDEF"\|ORGX\|ORGY\|DETECTOR_DISTANCE\|"
   if [ "$pattern" != "" ]; then
  echo REDEF=$REDEF_TOKENS
       sed 's/\(^ *\('$pattern'\) *=\)/!!\1/;' XDS.INP >tmp1
  pattern=$(grep "$REDEF_TOKENS" $site_file | grep -v SEGMENT | uniq | awk 'match($0,/^ *(\w+) *=/,a){x=x"\\|"a[1];}END{print substr(x,3);}')
      mv tmp1 XDS.INP
   if [ "$pattern" != "" -a $(grep "^!! *\($pattern\)" XDS.INP) != ""]; then
       sed 's/\(^ *\('$pattern'\) *=\)/!!!\1/;' XDS.INP >tmp1
       echo "Overridden parameters:"
       echo "Overridden parameters:"
       grep "^!!*$pattern" XDS.INP
       grep "^ *\($pattern\)" XDS.INP
       echo
       echo
      mv tmp1 XDS.INP
   fi
   fi
   cat $file >> XDS.INP
   cat $site_file >> XDS.INP
else
else
   echo "Detector specific parameters can be placed in: $file"
  if [ "$SEGMENTED" != "" ]; then
    echo "**** Multi-SEGMENTed detector, site file is mandatory ****"
  fi
   echo "Detector specific parameters can be placed in: $site_file"
   echo "! Detector specific parameters can be placed in:" >> XDS.INP
   echo "! Detector specific parameters can be placed in:" >> XDS.INP
   echo "!    $file" >> XDS.INP
   echo "!    $site_file" >> XDS.INP
   echo "! FRACTION_OF_POLARIZATION, ROTATION_AXIS and TRUSTED_REGION will auto-comment the replaced parameters" >> XDS.INP
   echo "! FRACTION_OF_POLARIZATION, ROTATION_AXIS and TRUSTED_REGION will auto-comment the replaced parameters" >> XDS.INP
  echo "! If the site file defines SEGMENTs then ORGX, ORGY, and DISTANCE may be overridden" >> XDS.INP
fi
fi
echo XDS.INP is ready for use. The file has only the most important keywords.
echo XDS.INP is ready for use. The file has only the most important keywords.
27

edits

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

Navigation menu