Generate XDS.INP: Difference between revisions

→‎The script: more work on support of blanks in filenames
(→‎The script: cope with blanks in filename)
(→‎The script: more work on support of blanks in filenames)
Line 123: Line 123:


# find out detector type
# find out detector type
DET=XXX                
DET=XXX            
IFS=$'\n'   
FIRSTFRAME=`head -1 tmp1`
FIRSTFRAME=`head -1 tmp1`
echo $FIRSTFRAME | grep -q bz2 && bzcat $FIRSTFRAME > tmp1 && FIRSTFRAME=tmp1
echo $FIRSTFRAME | grep -q bz2 && bzcat $FIRSTFRAME > tmp1 && FIRSTFRAME=tmp1
strings $FIRSTFRAME > tmp2                                                  
strings $FIRSTFRAME > tmp2  
unset IFS
# TODO: whenever FIRSTFRAME is used below, it should be copied to tmp2 (using IFS as above), and tmp2 should be used instead
# this was done for "mccd", but still has to be done for the "raxis" detector types
# the reason is that FIRSTFRAME may contain a blank, which makes some commands fail                                               
egrep -qi 'marccd|Corrected' tmp2 && DET=mccd                                 
egrep -qi 'marccd|Corrected' tmp2 && DET=mccd                                 
grep -q PILATUS tmp2            && DET=pilatus                               
grep -q PILATUS tmp2            && DET=pilatus                               
Line 167: Line 172:


   # offsets are documented; values can be found in mccd_xdsparams.pl script
   # offsets are documented; values can be found in mccd_xdsparams.pl script
  IFS=$'\n'
  cp $FIRSTFRAME tmp2
  unset IFS
   let SKIP=1024+80                                                         
   let SKIP=1024+80                                                         
   NX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk '{print $2}')
   NX=$(od -t dI -j $SKIP -N 4 tmp2 | head -1 | awk '{print $2}')
   let SKIP=$SKIP+4                                                                         
   let SKIP=$SKIP+4                                                                         
   NY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk '{print $2}')
   NY=$(od -t dI -j $SKIP -N 4 tmp2 | head -1 | awk '{print $2}')


   let SKIP=1720
   let SKIP=1720
   DETECTOR_DISTANCE=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk '{print $2}')
   DETECTOR_DISTANCE=$(od -t dI -j $SKIP -N 4 tmp2 | head -1 | awk '{print $2}')
   DETECTOR_DISTANCE=`echo "scale=3; $DETECTOR_DISTANCE/1000" | bc -l`                                     
   DETECTOR_DISTANCE=`echo "scale=3; $DETECTOR_DISTANCE/1000" | bc -l`                                     
                                                                                                            
                                                                                                            
   let SKIP=1024+256+128+256+4                                                                             
   let SKIP=1024+256+128+256+4                                                                             
   ORGX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk '{print $2}')             
   ORGX=$(od -t dI -j $SKIP -N 4 tmp2 | head -1 | awk '{print $2}')             
   ORGX=`echo "scale=2; $ORGX/1000" | bc -l `                                                               
   ORGX=`echo "scale=2; $ORGX/1000" | bc -l `                                                               
   let SKIP=$SKIP+4                                                                                         
   let SKIP=$SKIP+4                                                                                         
   ORGY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk '{print $2}')             
   ORGY=$(od -t dI -j $SKIP -N 4 tmp2 | head -1 | awk '{print $2}')             
   ORGY=`echo "scale=2; $ORGY/1000" | bc -l `                                                               
   ORGY=`echo "scale=2; $ORGY/1000" | bc -l `                                                               


   let SKIP=1024+736
   let SKIP=1024+736
   OSCILLATION_RANGE=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk '{print $2}')  
   OSCILLATION_RANGE=$(od -t dI -j $SKIP -N 4 tmp2 | head -1 | awk '{print $2}')  
   OSCILLATION_RANGE=`echo "scale=3; $OSCILLATION_RANGE/1000" | bc -l`   
   OSCILLATION_RANGE=`echo "scale=3; $OSCILLATION_RANGE/1000" | bc -l`   
                                                                                                  
                                                                                                  
   let SKIP=1024+256+128+256+128+4                                                                 
   let SKIP=1024+256+128+256+128+4                                                                 
   QX=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk '{print $2}')       
   QX=$(od -t dI -j $SKIP -N 4 tmp2 | head -1 | awk '{print $2}')       
   QX=`echo "scale=10; $QX/1000000" |bc -l `                                                       
   QX=`echo "scale=10; $QX/1000000" |bc -l `                                                       
   let SKIP=$SKIP+4                                                                               
   let SKIP=$SKIP+4                                                                               
   QY=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk '{print $2}')       
   QY=$(od -t dI -j $SKIP -N 4 tmp2 | head -1 | awk '{print $2}')       
   QY=`echo "scale=10; $QY/1000000" |bc -l `                                                       
   QY=`echo "scale=10; $QY/1000000" |bc -l `                                                       


   let SKIP=1024+256+128+256+128+128+12
   let SKIP=1024+256+128+256+128+128+12
   X_RAY_WAVELENGTH=$(od -t dI -j $SKIP -N 4 $FIRSTFRAME | head -1 | awk '{print $2}')
   X_RAY_WAVELENGTH=$(od -t dI -j $SKIP -N 4 tmp2 | head -1 | awk '{print $2}')
   X_RAY_WAVELENGTH=`echo "scale=5; $X_RAY_WAVELENGTH/100000" | bc -l`                                     
   X_RAY_WAVELENGTH=`echo "scale=5; $X_RAY_WAVELENGTH/100000" | bc -l`                                     


2,652

edits