Generate XDS.INP: Difference between revisions

rev 0.51
(→‎The script: for REFINE() keywords, add POSITION to DISTANCE because XDS 01-MAR-2015 changes this)
(rev 0.51)
Line 66: Line 66:
# revision 0.49 . Nobuhisa 2/2015 add  detector serial number for AichiSR BL2S1 to beam center convention 1
# revision 0.49 . Nobuhisa 2/2015 add  detector serial number for AichiSR BL2S1 to beam center convention 1
# revision 0.50 . KD 03/2015 workaround for Mar-1 change of parameter name "DISTANCE" to "POSITION" in REFINE(*) keywords
# revision 0.50 . KD 03/2015 workaround for Mar-1 change of parameter name "DISTANCE" to "POSITION" in REFINE(*) keywords
REVISION="0.50 (01-Mar-2015)"
# revision 0.51 . Keitaro 03/2015 add .gz and .xz support and remove limitation - frame numbers can start with any.
REVISION="0.51 (20-Mar-2015)"
#                                                                                                             
#                                                                                                             
# usage: e.g. generate_XDS.INP "/file/system/frms/mydata_1_???.img"                                                       
# usage: e.g. generate_XDS.INP "/file/system/frms/mydata_1_???.img"                                                       
# make sure to have the two quotation marks !                                                                 
# make sure to have the two quotation marks !                                                                 
# the ? are wildcards for the frame numbers.                                                                 
# the ? are wildcards for the frame numbers.                                                                 
#                                                                                                           
# limitations:                                                                                             
# - frame numbers are assumed to start with 1 and run consecutively                                         
#                                                                                                             
#                                                                                                             
# known problems:                                                                                             
# known problems:                                                                                             
Line 114: Line 112:
# cope with blanks in directory / file name
# cope with blanks in directory / file name
IFS=$'\n'
IFS=$'\n'
/bin/ls -C1 $1 $1.bz2 2>/dev/null | egrep -v "_00000.cbf|_000.img" > tmp1 || exit 1
/bin/ls -C1 $1 $1.bz2 $1.gz $1.xz 2>/dev/null | egrep -v "_00000.cbf|_000.img" > tmp1 || exit 1
unset IFS
unset IFS
# we can continue - the frames are found
# we can continue - the frames are found


# set upper limit of DATA_RANGE to number of frames (see "limitations" above)
# Find the first '?' position and the number of '?' to determine DATA_RANGE=.
DATA_RANGE=`wc -l tmp1 | awk '{print $1}'`                                  
pos1=`echo "$1" | awk '{print index($0, "?")}'`
pos2=`echo "$1" | sed -e "s/[^\?]//g" | awk '{print length+'$pos1' - 1'}`
data_first=`cat tmp1 | cut -b $pos1-$pos2 | head -n1|bc`
data_last=`cat tmp1 | cut -b $pos1-$pos2 | tail -n1|bc`
DATA_RANGE="$data_first $data_last"


# set upper limit of SPOT_RANGE to half of DATA_RANGE, but not less than 1
# set SPOT_RANGE to first half of DATA_RANGE
SPOT_RANGE=`echo "scale=0; $DATA_RANGE/2" | bc -l`                         
data_num=`wc -l tmp1 | awk '{print $1}'`
SPOT_RANGE=`echo "if ($SPOT_RANGE<1) 1;if ($SPOT_RANGE>1) $SPOT_RANGE" | bc -l`
data_half=`echo "scale=0; $data_num/2" | bc -l`                         
data_half=`echo "if ($data_half<=1) 1;if ($data_half>1) $data_half" | bc -l`
spot_last=`echo "scale=0; $data_first+$data_half-1" | bc -l`
SPOT_RANGE="$data_first $spot_last"


echo DATA_RANGE=1 $DATA_RANGE
echo DATA_RANGE=$DATA_RANGE


# find out detector type
# find out detector type
Line 131: Line 136:
IFS=$'\n'     
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
# for mac/linux compatibility. zcat foo.gz doesn't work on mac.
echo $FIRSTFRAME | grep -q '\.gz$' && zcat < $FIRSTFRAME > tmp1 && FIRSTFRAME=tmp1
echo $FIRSTFRAME | grep -q '\.xz$' && xzcat $FIRSTFRAME > tmp1 && FIRSTFRAME=tmp1
 
strings $FIRSTFRAME > tmp2   
strings $FIRSTFRAME > tmp2   
unset IFS
unset IFS
Line 458: Line 467:
NAME_TEMPLATE_OF_DATA_FRAMES=$NAME_TEMPLATE_OF_DATA_FRAMES
NAME_TEMPLATE_OF_DATA_FRAMES=$NAME_TEMPLATE_OF_DATA_FRAMES
! REFERENCE_DATA_SET=xxx/XDS_ASCII.HKL ! e.g. to ensure consistent indexing   
! REFERENCE_DATA_SET=xxx/XDS_ASCII.HKL ! e.g. to ensure consistent indexing   
DATA_RANGE=1 $DATA_RANGE                                                     
DATA_RANGE=$DATA_RANGE                                                     
SPOT_RANGE=1 $SPOT_RANGE                                                     
SPOT_RANGE=$SPOT_RANGE                                                     
! BACKGROUND_RANGE=1 10 ! rather use defaults (first 5 degree of rotation)   
! BACKGROUND_RANGE=1 10 ! rather use defaults (first 5 degree of rotation)   


33

edits