#!/bin/csh -f

set verify
set echo

# (c)2011 Rigaku Americas Corporation
# This script was written by 
#
# JW Pflugrath
# Rigaku Americas Corporation
#
# as part of the ACA 2011 session "Data Processing with the Pros"
#
# This script shows how to process the 2QVO diffraction images from
# the APS/ID-?? which has PDB entry 2QVO

#a+b Process 2QVO.  See the *_do_all.csh scripts for notes and comments.
#a+b All this could be done interactively via the dtdisplay & dtprocess
#a+b graphical user interfaces as well.

#a+b Start a dtdisplay so that you can observe some of what is happening

dtdisplay &

#a+b Process the first scan 1 (or call 'a') here:

a_do_all.csh

#a+b Process the second scan 2 (or call 'b') here:

b_do_all.csh

#a+b Combine the processed results of the two scans (a & b or 1 & 2)
#a+b For now assume there are two crystals, so do not apply a common absorption correction
#a+b 

dtreflnmerge a_dtunavg.ref b_dtunavg.ref a+b_merged.ref >&! a+b_merge.log

#a+b Scale & average  the resulting file
#a+b Note that since sigmas were already adjusted, 
#a+b they should NOT be adjust here.  Use "-errormodel 1 0.0001"
#a+b Note that since absorption correct was already applied, 
#a+b absorption correction should NOT be used here (no -reqab option used)

setenv DTREK_PREFIX a+b_

dtscaleaverage a_dtscaleaverage.head a+b_merged.ref -reject sigma 5.0 -batchrestrain 0.002 -anom -ref a+b_dtunavg.ref -errormodel 1 0.0001 -reject fraction .0075 -batchscale ${DTREK_PREFIX}dtscale.ref >& ${DTREK_PREFIX}dtscaleaverage.log

#a+b Plot the log file:
# jdtplot a+b_dtscaleaverage.log


