Generate XDS.INP: Difference between revisions

rev 0.6.1 (tentative Eiger hdf5 support using h5dump)
(rev 0.6.1 (tentative Eiger hdf5 support using h5dump))
Line 78: Line 78:
# revision 0.59 . KD 04/04/2016 check for ADSC detector _after_ checking for dtrek detector, to correct wrong choice for https://zenodo.org/record/45756
# revision 0.59 . KD 04/04/2016 check for ADSC detector _after_ checking for dtrek detector, to correct wrong choice for https://zenodo.org/record/45756
# revision 0.60 . KD 04/04/2016 ADSC detector SN=458 at APS 19-ID has reverse phi (https://zenodo.org/record/45756)
# revision 0.60 . KD 04/04/2016 ADSC detector SN=458 at APS 19-ID has reverse phi (https://zenodo.org/record/45756)
REVISION="0.60 (04-Apr-2016)"
# revision 0.61 . Keitaro 10/04/2016 Add Eiger hdf5 support (may be incomplete; UNTRUSTED_RECTANGLE=s not set) NEED h5dump.
REVISION="0.61 (10-Apr-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 146: Line 147:
spot_last=`echo "scale=0; $data_first+$data_half-1" | bc -l`
spot_last=`echo "scale=0; $data_first+$data_half-1" | bc -l`
SPOT_RANGE="$data_first $spot_last"
SPOT_RANGE="$data_first $spot_last"
FIRSTFRAME=`head -1 tmp1`
echo $FIRSTFRAME | grep "\.h5$" && is_h5=1 || is_h5=0
if [ "$is_h5" == 1 ]; then
nframes=`h5dump -A -g "/entry/data" $FIRSTFRAME | grep "DATASPACE  SIMPLE" | sed -e "s/,.*//" | awk '{a+=$5}END{print a}'`
DATA_RANGE="1 $nframes"
SPOT_RANGE="1 `echo "scale=0; ${nframes}/2"|bc -l`"
fi


echo DATA_RANGE=$DATA_RANGE
echo DATA_RANGE=$DATA_RANGE
Line 152: Line 162:
DET=XXX               
DET=XXX               
IFS=$'\n'     
IFS=$'\n'     
FIRSTFRAME=`head -1 tmp1`
echo $FIRSTFRAME | grep -q '\.bz2$' && bzcat $FIRSTFRAME > tmp1 && FIRSTFRAME=tmp1
echo $FIRSTFRAME | grep -q '\.bz2$' && bzcat $FIRSTFRAME > tmp1 && FIRSTFRAME=tmp1
# for mac/linux compatibility. zcat foo.gz doesn't work on mac.
# for mac/linux compatibility. zcat foo.gz doesn't work on mac.
Line 158: Line 167:
echo $FIRSTFRAME | grep -q '\.xz$' && xzcat $FIRSTFRAME > tmp1 && FIRSTFRAME=tmp1
echo $FIRSTFRAME | grep -q '\.xz$' && xzcat $FIRSTFRAME > tmp1 && FIRSTFRAME=tmp1


strings $FIRSTFRAME > tmp2 
unset IFS
unset IFS
# TODO: whenever FIRSTFRAME is used below, it should be copied to tmp2 (using IFS as above), and tmp2 should be used instead
if [ "$is_h5" == 0 ]; then
# this was done for "mccd", but still has to be done for the "raxis" detector types
strings $FIRSTFRAME > tmp2 
# the reason is that FIRSTFRAME may contain a blank, which makes some commands fail                                                 
# TODO: whenever FIRSTFRAME is used below, it should be copied to tmp2 (using IFS as above), and tmp2 should be used instead
egrep -qi 'marccd|Corrected' tmp2 && DET=mccd                                 
# this was done for "mccd", but still has to be done for the "raxis" detector types
grep -q PILATUS tmp2            && DET=pilatus                               
# the reason is that FIRSTFRAME may contain a blank, which makes some commands fail                                                 
head -n1 tmp2 | grep -q "^RAXIS" && DET=raxis
egrep -qi 'marccd|Corrected' tmp2 && DET=mccd                                 
head -n1 tmp2 | grep -q "^R-AXIS" && DET=raxis
grep -q PILATUS tmp2            && DET=pilatus                               
grep -q "^SOURCE_WAVELENGTH= *1" tmp2 && DET=dtrek
head -n1 tmp2 | grep -q "^RAXIS" && DET=raxis
grep -q BEAM_CENTER_X tmp2      && DET=adsc                                 
head -n1 tmp2 | grep -q "^R-AXIS" && DET=raxis
grep -q mar345 tmp2 && DET=MAR345                         
grep -q "^SOURCE_WAVELENGTH= *1" tmp2 && DET=dtrek
grep -q BEAM_CENTER_X tmp2      && DET=adsc                                 
grep -q mar345 tmp2 && DET=MAR345                         
else
h5dump -d "/entry/instrument/detector/description" $FIRSTFRAME | grep -i Eiger > /dev/null && DET=eiger
fi


# identify other detector types in the same way  
# identify other detector types in the same way  
Line 375: Line 388:
       fi
       fi


elif [ "$DET" == "eiger" ]; then
  OVERLOAD=`h5dump -d "/entry/instrument/detector/detectorSpecific/countrate_correction_count_cutoff" $FIRSTFRAME | awk '/\(0\):/{print $2}' `
  DETECTOR="EIGER MINIMUM_VALID_PIXEL_VALUE=0 OVERLOAD= $OVERLOAD  !EIGER"
  QX=`h5dump -d "/entry/instrument/detector/x_pixel_size" $FIRSTFRAME | awk '/\(0\): [0-9]/{print $2*1000}'`
  QY=`h5dump -d "/entry/instrument/detector/y_pixel_size" $FIRSTFRAME | awk '/\(0\): [0-9]/{print $2*1000}'`
  echo Data from a Eiger hdf5
      SENSOR_THICKNESS=`h5dump -d "/entry/instrument/detector/sensor_thickness" $FIRSTFRAME | awk '/\(0\): [0-9]/{print $2*1000}'`
      X_RAY_WAVELENGTH=`h5dump -d "/entry/instrument/beam/incident_wavelength" $FIRSTFRAME | awk '/\(0\): [0-9]/{print $2}'`
      NX=`h5dump -d "/entry/instrument/detector/detectorSpecific/x_pixels_in_detector" $FIRSTFRAME | awk '/\(0\): [0-9]/{print $2}'`
      NY=`h5dump -d "/entry/instrument/detector/detectorSpecific/y_pixels_in_detector" $FIRSTFRAME | awk '/\(0\): [0-9]/{print $2}'`
      # find ORGX and ORGY:
      ORGX=`h5dump -d "/entry/instrument/detector/beam_center_x" $FIRSTFRAME | awk '/\(0\): [0-9]/{print $2}'`
      ORGY=`h5dump -d "/entry/instrument/detector/beam_center_y" $FIRSTFRAME | awk '/\(0\): [0-9]/{print $2}'`
      # find DETECTOR_DISTANCE and OSCILLATION_RANGE:
      DETECTOR_DISTANCE=`h5dump -d "/entry/instrument/detector/detector_distance" $FIRSTFRAME | awk '/\(0\): [0-9]/{print $2*1000}'`
      OSCILLATION_RANGE=`h5dump -d "/entry/sample/goniometer/omega_range_average" $FIRSTFRAME | awk '/\(0\): [0-9]/{print $2}'`
      # If rotation vector set (NeXus)
      rotation_axis=`h5dump -a "/entry/sample/transformations/omega/vector" $FIRSTFRAME | grep "(0):" | sed -e "s/^.*://; s/,//g"`
 
elif [ "$DET" == "raxis" ]; then
elif [ "$DET" == "raxis" ]; then
   echo Data from a RAXIS detector
   echo Data from a RAXIS detector
Line 413: Line 450:
     rotx=`echo "scale=6; -1.0*${tmpmat[0]}" | bc -l`
     rotx=`echo "scale=6; -1.0*${tmpmat[0]}" | bc -l`
     roty=`echo "scale=6; -1.0*${tmpmat[1]}" | bc -l`
     roty=`echo "scale=6; -1.0*${tmpmat[1]}" | bc -l`
     dtrek_rotation_axis="$rotx $roty 0"
     rotation_axis="$rotx $roty 0"
   if [ `echo "(${tmpmat[0]}*${tmpmat[3]}-(${tmpmat[1]}*${tmpmat[2]}))/1"|bc` -lt 0 ]; then
   if [ `echo "(${tmpmat[0]}*${tmpmat[3]}-(${tmpmat[1]}*${tmpmat[2]}))/1"|bc` -lt 0 ]; then
     echo ""
     echo ""
Line 561: Line 598:
eof
eof
else
else
  if [ "$dtrek_rotation_axis" != "" ]; then
  if [ "$rotation_axis" != "" ]; then
   echo "ROTATION_AXIS= $dtrek_rotation_axis" >> XDS.INP
   echo "ROTATION_AXIS= $rotation_axis" >> XDS.INP
  elif [ "$REVERSE_PHI" == "no" ]; then
  elif [ "$REVERSE_PHI" == "no" ]; then
   echo 'ROTATION_AXIS=1 0 0  ! Australian Synchrotron, SERCAT ID-22 (?), APS 19-ID (?), ESRF BM30A, SPring-8, SSRF BL17U need -1 0 0. Diamond ID24 needs 0 -1 0' >> XDS.INP
   echo 'ROTATION_AXIS=1 0 0  ! Australian Synchrotron, SERCAT ID-22 (?), APS 19-ID (?), ESRF BM30A, SPring-8, SSRF BL17U need -1 0 0. Diamond ID24 needs 0 -1 0' >> XDS.INP
Line 598: Line 635:
!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" ]; then
if [ "$DET" == "pilatus" -o "$DET" == "eiger" ]; then
cat >> XDS.INP << eof
cat >> XDS.INP << eof
SEPMIN=4 CLUSTER_RADIUS=2
SEPMIN=4 CLUSTER_RADIUS=2
33

edits