\documentclass[a4paper, 11pt]{article}
\begin{document}

\section{Introduction}

Running d*TREK from the command line is, I think, relatively simple. The 
commands which are issued by the GUI's dtdisplay \& dtprocess seem to be
fairly simple, so I will record these and use as my baseline.

It looks like ``indexing'' will include 3 steps - spot finding by dtfind,
indexing by dtindex and refinement (against the spots found in step no 1)
in dtrefine. This gives a reasonably accurate orientation matrix, though I 
am not sure that it is completely accurate because some reflections are
midding on the display!

In d*TREK it looks like most of the important information is kept in the 
d*TREK header file, which looks a lot like the ADSC SMV format header. This
has all sorts of goniometry information in (boring) as well as some more
useful stuff for instance the beam centre.

The initial header file can be created from the images with dtextractheader.
This just reads in the image file and writes out an inital d*TREK header - 
this can then be used for the initial stages of the above processes.

\section{Indexing}

Spot picking for the indexing \& refinement can be done off a number of 
images - and this gives a much better result.


\section{Notes}

Running d*TREK from the command line...

{
\small
\begin{verbatim}
[prepare header]
dtextractheader image start.head
[update beam ctr] this is in pixels in start.head

dtfind start.head -seq 1 1 -sigma 3 -min 50 -filter 6 -out find.head
dtindex find.head dtfind.ref -maxresid 3.0 -sigma 5.0 -dps -nodiffs

... gives ...

FIND

dtfind:  Copyright (c) 1996 Molecular Structure Corporation
d*TREK version 9.5L -- Oct  4 2005
Command line:
 dtfind start.head -seq 1 1 -sigma 3 -min 50 -filter 6 -out find.head

     Header of file start.head successfully read.
A4_NONUNF_TYPE: >>Simple_mask<<
INFO in Cnonunf: using
     ../12287/12287_1_E1_001.img
     as the simple mask/nonunf file, was FirstScanImage.

     File ../12287/12287_1_E1_001.img successfully opened.
Min raw image pixel OK value in mask/nonunf/image file: 1


Command line string: >>-seq<<
Command line string: >>-sigma<<
Command line string: >>-min<<
Command line string: >>-filter<<
Command line string: >>-out<<

Resolution limits of an image are 979.65 to 1.37426
Resolution limits of peak search are 979.65 to 1.37426


dtfind: 2D method  used
...reading image ../12287/12287_1_E1_001.img...

     File ../12287/12287_1_E1_001.img successfully opened.
Find object listing:
     Sigma: 3
Resolution: 979.65 to 1.37426
   Minimum: 50
Circle lim: 1024, 1024, 0, 1448
  Rect lim: 20, 20, 2028, 2028
Spot wind.: 0, 0
Peak filt.: 6
Back. tile: 128, 128
 Seq. num.: 1, 1
Image dim.: 2048, 2048
   3D dump: 0
1339 preliminary spots found in 2D search with rotation angle 290.5 degs.

dtfind: There were 1074 spots found.
There were 1074 preliminary spots of which 4 were marked as saturated,
 or  0.37% of them.
Number of reflections written in 'dtfind.ref': 1074
dtfind: Spots written to dtfind.ref
dtfind - Wrote header file find.head

INDEX


dtindex:  Copyright (c) 1998, 1996 Molecular Structure Corporation
d*TREK version 9.5L -- Oct  4 2005
Command line:
 dtindex find.head dtfind.ref -maxresid 3.0 -sigma 5 -dps -nodiffs

     Header of file find.head successfully read.
Reflection list: dtfind.ref
Creflnlist::nRead with filename: dtfind.ref
INFO in Creflnlist::nRead, EOF after 1074 reflections read in
                                    (1074 total now in list).
Command line string: >>-maxresid<<
Command line string: >>-sigma<<
Command line string: >>-dps<<
Command line string: >>-nodiffs<<
INFO: deleted 0 reflns outside of resolution bounds.
      This leaves 1074 reflns for indexing.

INFO: 418 reflns deleted out of 1074 that might be in ice rings.
Max cell length allowed for reciprocal lattice vectors: 256.219


Method:     1D FFT with DPS algorithm
Out header: dtindex.head
Max cell:   256.219
Num vecs:   1000
Spacegroup: 0
Verbose:    1

Performing 1D FFT indexing (not cell reduction) with the DPS algorithm...see
  Steller, Bolotovsky, & Rossmann (1997) J. Appl. Cryst. 30, 1036-1040.

Max cell is:         256.219
Number of reflections/vectors used: 588
.....................................
...refining best 30 directions and lengths...
..............................  done.
Number of vectors used for integer residual calculation: 588

     a      b      c  alpha   beta  gamma   Volume  Remarks #Indexed %Residual
==============================================================================
196.09  52.05  51.42  90.02 122.45 104.58   422661     Okay      435     0.265
 51.42 196.09  52.05 104.58  90.02 122.45   422661     Okay      435     0.265
 52.05  51.42 196.09 122.45 104.58  90.02   422661     Okay      435     0.265
 51.49 187.73  52.08 122.68  90.13  90.69   423682     Okay      432     0.268
187.73  52.08  51.49  90.13  90.69 122.68   423682     Okay      432     0.268
 52.08  51.49 187.73  90.69 122.68  90.13   423682     Okay      432     0.268
 51.42 196.09  73.15 123.80  45.36 122.45   422658     Okay      435     0.265
196.09  73.15  51.42  45.36 122.45 123.80   422661     Okay      435     0.265
 73.15  51.42 196.09 122.45 123.80  45.36   422661     Okay      435     0.265
196.09  52.05  73.15  44.66 123.80 104.58   422661     Okay      435     0.265
 52.05  73.15 196.09 123.80 104.58  44.66   422661     Okay      435     0.265
 73.15 196.09  52.05 104.58  44.66 123.80   422661     Okay      435     0.265
 73.15  51.50 187.74  90.69 113.13  45.40   423887     Okay      428     0.264
187.74  73.15  51.50  45.40  90.69 113.13   423887     Okay      428     0.264
 51.50 187.74  73.15 113.13  45.40  90.69   423887     Okay      428     0.264
187.73 196.09  51.43 122.45  90.70  34.89   422913     Okay      437     0.274
 73.15 187.71  52.06 122.67  44.67 113.16   422954     Okay      433     0.265
187.71  52.06  73.15  44.67 113.16 122.67   422954     Okay      433     0.265
 52.06  73.15 187.71 113.16 122.67  44.67   422954     Okay      433     0.265


Executing beam refinement with
beam search radius, acceptable shift radius: 10 9 ...
A4_NONUNF_TYPE: >>Simple_mask<<
INFO in Cnonunf: using
     ../12287/12287_1_E1_001.img
     as the simple mask/nonunf file, was FirstScanImage.

     File ../12287/12287_1_E1_001.img successfully opened.
Min raw image pixel OK value in mask/nonunf/image file: 1
Original (input header) beam center: [1030.0 1066.0]

First Pass.  Search dim0 in [1020 1040] dim1 in [1056 1076]
.............................................
Second Pass.  Search dim0 in [1036 1038] dim1 in [1061 1063]
Calculated pre-reduced cell solution is in agreement with detector beam center!
Original (input header) beam center: [1030.0 1066.0]
New      (calculated)   beam center: [1036.5 1061.4]
Header updated to reflect beam center change.

WARNING!: Beam position moved more than 5 pixels!
=======
INFO: Restart with adjusted beam center.
Max cell length allowed for reciprocal lattice vectors: 256.219


Method:     1D FFT with DPS algorithm
Out header: dtindex.head
Max cell:   256.219
Num vecs:   1000
Spacegroup: 0
Verbose:    1

Performing 1D FFT indexing (not cell reduction) with the DPS algorithm...see
  Steller, Bolotovsky, & Rossmann (1997) J. Appl. Cryst. 30, 1036-1040.

Max cell is:         256.219
Number of reflections/vectors used: 588
.....................................
...refining best 30 directions and lengths...
..............................  done.
Number of vectors used for integer residual calculation: 588

     a      b      c  alpha   beta  gamma   Volume  Remarks #Indexed %Residual
==============================================================================
174.05 166.20 157.98  18.20  24.83  17.27   423646     Okay      394     0.060
166.20 157.98 174.05  24.83  17.27  18.20   423646     Okay      394     0.060
157.99 166.21 174.09  39.69  24.82  18.19   423539     Okay      392     0.060
158.00 166.21  73.10 102.74  89.98  18.19   423234     Okay      388     0.059
157.98 195.63  73.09  55.96  89.99  36.17   423560     Okay      395     0.061
157.98 166.21  51.67  90.00  90.09  18.20   423833     Okay      389     0.059
166.21  51.67 157.98  90.09  18.20  90.00   423834     Okay      389     0.059
 51.67 157.98 166.21  18.20  90.00  90.09   423834     Okay      389     0.059
 51.64 195.60 157.98  36.17  90.09  58.27   423209     Okay      385     0.059
157.98  51.64 195.60  58.27  36.17  90.09   423209     Okay      385     0.059
195.60 157.98  51.64  90.09  58.27  36.17   423209     Okay      385     0.059
 51.66 157.99 174.06  24.83 107.28  90.08   423467     Okay      396     0.061
174.06  51.66 157.99  90.08  24.83 107.28   423468     Okay      396     0.061
157.99 174.06  51.66 107.28  90.08  24.83   423472     Okay      396     0.061
158.00  51.64 174.09  72.86  24.83  90.07   423231     Okay      383     0.059
174.09 158.00  51.64  90.07  72.86  24.83   423232     Okay      383     0.059
 51.64 174.09 158.00  24.83  90.07  72.86   423231     Okay      383     0.059
 73.09 157.99  51.66  90.08  45.23  89.99   423468     Okay      396     0.061
157.99  51.66  73.09  45.23  89.99  90.08   423468     Okay      396     0.061
 51.66  73.09 157.99  89.99  90.08  45.23   423468     Okay      396     0.061
174.06 166.20  73.09 102.75 114.82  17.26   423434     Okay      396     0.061
174.10 166.21  73.09 102.75  65.16  39.69   423362     Okay      393     0.060
 73.10 166.20  51.64  90.03  45.22 102.75   423344     Okay      393     0.060
166.20  51.64  73.10  45.22 102.75  90.03   423344     Okay      393     0.060
 51.64  73.10 166.20 102.75  90.03  45.22   423345     Okay      393     0.060
 51.66  73.09 195.63  55.96  58.26  45.23   423468     Okay      396     0.061
 73.09 195.63  51.66  58.26  45.23  55.96   423468     Okay      396     0.061
195.63  51.66  73.09  45.23  55.96  58.26   423468     Okay      396     0.061
174.06  51.66  73.09  45.23 114.82 107.28   423468     Okay      396     0.061
 73.09 174.06  51.66 107.28  45.23 114.82   423468     Okay      396     0.061
 51.66  73.09 174.06 114.82 107.28  45.23   423468     Okay      396     0.061
 73.09 174.09  51.65  72.88  45.23  65.16   423432     Okay      396     0.061
 51.65  73.09 174.09  65.16  72.88  45.23   423432     Okay      396     0.061
174.09  51.65  73.09  45.23  65.16  72.88   423432     Okay      396     0.061


Least square fit to lattice characters...see
  Andrews & Bernstein (1988) Acta Cryst. A44, 1009-1018 and
  Paciorek & Bonin (1992) J. Appl. Cryst. 25, 632-637.
............................................................
............................................................
done.

Least-squares fit of reduced primitive cell to 44 lattice characters
sorted on decreasing (highest to lowest) symmetry.
Only solutions with residuals <=   3.0 are listed.
=======================================================================
 Soln  LeastSq Spgrp Cent    Bravais type         a         b         c
  num residual  num* type     Cell volume     alpha      beta     gamma
=======================================================================
   7     0.190    75    P      tetragonal    51.796    51.796   157.982
                                   423844    90.000    90.000    90.000

   9     0.166    21    C    orthorhombic    73.093    73.409   157.982
                                   847680    90.000    90.000    90.000

  11     0.175    16    P    orthorhombic    51.669    51.923   157.982
                                   423839    90.000    90.000    90.000

  12     0.064     5    C      monoclinic    73.691    73.168   157.982
                                   851816    90.000    90.141    90.000

  12b    0.075     5    C      monoclinic    73.409    73.093   157.982
                                   847678    90.000    90.131    90.000

  13     0.092     3    P      monoclinic    51.923    51.669   157.982
                                   423838    90.000    90.100    90.000

  14     0.000     1    P       triclinic    51.669    51.923   157.982
                                   423834    89.900    89.915    89.753

=======================================================================
*Suggested spacegroup number until systematic absences are examined.
...determining orientation angles...
.

Unit cell parameters and orientation angles
======================================================================
      Integer         a         b         c
Num  residual     alpha      beta     gamma     Rot1     Rot2     Rot3
======================================================================
  1     0.001    51.796    51.796   157.982  -75.915   20.479  -78.321
                 90.000    90.000    90.000

  2     0.001    51.796    51.796   157.982   75.915  -20.479  101.679
                 90.000    90.000    90.000

  3     0.001    51.796    51.796   157.982  104.085   20.479  -78.321
                 90.000    90.000    90.000

  4     0.001    51.796    51.796   157.982 -104.085  -20.479  101.679
                 90.000    90.000    90.000

  5     0.001    51.796    51.796   157.982   56.911   65.317   66.033
                 90.000    90.000    90.000

  6     0.001    51.796    51.796   157.982  -56.911  -65.317 -113.967
                 90.000    90.000    90.000

  7     0.001    51.796    51.796   157.982 -123.089   65.317   66.033
                 90.000    90.000    90.000

  8     0.001    51.796    51.796   157.982  123.089  -65.317 -113.967
                 90.000    90.000    90.000

======================================================================
The above table shows symmetry EQUIVALENT crystal orientation angles
for the indexing orientation.  All the solutions are equivalent for
the selected Bravais lattice.  The default selection usually has the
values closest to crystal orientation found in the input .head file or
the one where (|Rot1| + |Rot2| + |Rot3|) is a minimum.
Orientation angles choice 1 selected.

Crystal listing:

 Unit cell lengths:   51.7964   51.7964  157.9819
 Unit cell  angles:   90.0000   90.0000   90.0000
 Unit cell  volume: 423843.915
Orientation angles:  -75.9149   20.4794  -78.3208
         Mosaicity:     0.300
       Description: unknown

Spacegroup number: 75
             name: P4
Num. equiv. posns: 4
dtindex - Wrote header file dtindex.head

This works
----------

#!/bin/bash
export DTREK_PREFIX=infl
dtfind process.head -seq 1 2 -seq 59 60 -sigma 3 -min 50 -filter 6 \
-window 0 0 -out infldtfind.head 

dtindex infldtfind.head infldtfind.ref -spacegroup 96 \
-maxresid 3.0 -sigma 5  

dtrefine infldtindex.head infldtfind.ref -rej 1 1 2 -sigma 1 \
+CrysAll +DetAll -verbose 0 -go -verbose 1  -go 

dtintegrate infldtrefine.head -window 0 0 -pad 1 \
-mosaicitymodel  1.000 0.000 -profit 50 7 -batch 1 4 -prerefine 2 -seq 1 60 

dtscaleaverage infldtintegrate.head infldtprofit.ref \
-reject sigma 5.0 -reso 40 1.65 -scaleanom -errormodel  \
-reject fraction .0075 -batchscale -reqab spherical 4 3 infldtscale.ref 

For the 1VPJ/12287 data set - phases ok. Have the following process.head
file:

{
HEADER_BYTES= 2560;
A4_DETECTOR_DESCRIPTION=A4_ conversion;
A4_DETECTOR_DIMENSIONS=2048 2048;
A4_DETECTOR_SIZE= 209.72  209.72;
A4_DETECTOR_VECTORS=1 0 0 0 1 0;
A4_GONIO_NAMES=RotZ RotX/Swing RotY TransX TransY TransZ/Dist;
A4_GONIO_NUM_VALUES=6;
A4_GONIO_UNITS=deg deg deg mm mm mm;
A4_GONIO_VALUES=0.000 -0.002 0.000 0.000 0.000  170.000;
A4_GONIO_VECTORS=0 0 1 -1 0 0 0 1 0 1 0 0 0 1 0 0 0 -1;
A4_NONUNF_INFO=\$(FirstScanImage);
A4_NONUNF_TYPE=Simple_mask;
A4_OSC_RANGE= 1.0000;
A4_OSC_START= 290.0000;
A4_SPATIAL_BEAM_POSITION=1026.0 1065.0; 
A4_SPATIAL_DISTORTION_INFO=1026.0 1065.0 0.10240 0.10240;
A4_SPATIAL_DISTORTION_TYPE=Simple_spatial;
A4_SPATIAL_DISTORTION_VECTORS=1 0 0 -1;
ADC=slow;
AXIS=phi;
BEAM_CENTER_X=105.10;
BEAM_CENTER_Y=101.05;
BIN=none;
BYTE_ORDER=little_endian;
CCD_IMAGE_SATURATION=65535;
CRYSTAL_GONIO_DESCRIPTION=Eulerian 3-circle;
CRYSTAL_GONIO_NAMES=Omega Chi Phi;
CRYSTAL_GONIO_NUM_VALUES=3;
CRYSTAL_GONIO_UNITS=deg deg deg;
CRYSTAL_GONIO_VALUES=0.000 0.000 0.000;
CRYSTAL_GONIO_VECTORS=1 0 0 0 1 0 1 0 0;
DATE=Sun Sep 26 14:01:35 2004;
DENZO_XBEAM=108.95;
DENZO_YBEAM=105.10;
DETECTOR_NAMES=A4_;
DETECTOR_NUMBER=1;
DETECTOR_SN=445;
DIM=2;
DISTANCE=170.0;
DTDISPLAY_ORIENTATION=-X+Y;
DTREK_DATE_TIME=11-Jul-2006 07:54:56;
DTREK_MODULE=unknown;
DTREK_VERSION=d*TREK version 9.5L -- Oct  4 2005;
PHI=290.000;
PIXEL_SIZE=0.102400;
ROTATION= 290.0000  291.0000  1.0000  5.0000  1.0000 0.0000 0.0000 0.0000 0.0000 0.0000;
ROTATION_AXIS_NAME=Omega;
ROTATION_FIELDS=RotStart RotEnd RotInc RotTime;
ROTATION_VECTOR=1 0 0;
SATURATED_VALUE=65535;
SCAN_FIELDS=RotStart RotEnd RotInc RotTime;
SCAN_ROTATION= 290.0000  291.0000  1.0000  5.0000  1.0000 0.0000 0.0000 0.0000 0.0000 0.0000;
SCAN_ROTATION_AXIS_NAME=Omega;
SCAN_ROTATION_VECTOR=1 0 0;
SCAN_SEQ_INFO=1 1 0;
SCAN_TEMPLATE=../12287/12287_1_E1_???.img;
SIZE1=0;
SIZE2=0;
SOURCE_CROSSFIRE=0.0002 0.0002 0.0 0.0;
SOURCE_INTENSITY=1.0;
SOURCE_POLARZ=0.95 0 1 0;
SOURCE_SIZE=0.0 0.0 0.0 0.0;
SOURCE_SPECTRAL_DISPERSION=0.0002 0.0002;
SOURCE_VALUES=0 0;
SOURCE_VECTORS=0 0 1 0 1 0 1 0 0;
SOURCE_WAVELENGTH= 1.00000 0.97966;
TIME=5.0;
TWOTHETA=-0.002;
TYPE=unsigned_short;
UNIF_PED=1500;
WAVELENGTH=0.97966;
}

Only thing I changed was the beam centre (based on Labelit).

\end{verbatim}
}

\section{Plans}

The best way to ``wrap'' d*TREK is probably through the header files, for 
instance having the ``index'' method write the initial header as input, then 
read the final header containing the indexing results. The actual text of the
header could then be the ``payload'' of the result (in the same way as the 
mosflm matrix file etc.)

The results of the indexing are in a ``cell'' record in the header file - 
there is also the mosaic spread estimate in there. 

In terms of processing, dtintegrate produces a header file - it may be 
worth recycling this later on to refine the parameters used in integration.

\subsection{Initial Work}

Looks like the input \& output of all of the d*TREK processes will be 
the header files; a standard mechanism for reading, writing the header
files could represent some standard functionality I want in a d*TREK
Decorator - therefore define this.

\subsection{Functionality}

\begin{itemize}
\item{[index] - if just a couple of images are available; use just 
dtfind, dtindex. if more frames are available define this to include
a dtrefine step.}
\item{[integrate] - if we have already refined then this is just integration,
else it will include refinement.}
\item{[scale] - scaling \emph{via} scala or dtscaleaverage - need to find
out how to do the former.}
\end{itemize}

\subsection{Wrappers}

The following programs need wrappers:

\begin{itemize}
\item{dtfind}
\item{dtindex}
\item{dtrefine}
\item{dtintegrate}
\item{dtscaleaverage}
\end{itemize}

\subsubsection{dtfind}

\subsubsection{dtindex}


Input: -cell a b c alpha beta gamma -spacegroup 75

Output: get the cell etc. from header file.

\section{Caveats}

I am not sure that the statistics produced by dtscaleaverage are comparable
to those from scala - the $I/\sigma$ overall for 1vpj datasets (60 degree)
was about 7, when the scala output gave the overall value of something like
12. Need to check this...

... however, the map calculated from the dataset looked ok; have not yet 
build into the data to get the final refinement statistics.

{
\small
\begin{verbatim}
                     DTREK2SCALA (CCP4: Supported Program)

NAME

   dtrek2scala  - for conversion of integrated intensity and header files
   from D*TREK into multi-record mtz files

SYNOPSIS

   dtrek2scala hklout foo_out.mtz [Keyworded input]

DESCRIPTION

   The  program  DTREK2SCALA is used for converting reflection data files
   created   by   the  program  D*TREK.  It  uses  the  full  goniometric
   description  of  the  experiment  (encoded  in D*TREK header files) to
   generate  a MTZ orientation blocks in the 'Cambridge' reference frame.
   The  output  is  a multi-record MTZ file containing orientation blocks
   with  the crystal and goniostat information: this file is suitable for
   input to SCALA for scaling
   and is essentially equivalent to the output MTZ of MOSFLM.

   The  input  files  must  be  integrated  or  profile  fitted intensity
   reflection  files  created by dtintegrate/dtprofit (e.g. dtprofit.ref)
   and  the  corresponding  d*trek  header file created by these programs
   (e.g. dtintegrate.head)

KEY WORDED INPUT

   The  various  data control lines are identified by keywords with those
   available being:

  ACCEPT , BATCH , BTITLE , CRYSTAL , FILE , HFILE , UGCB , LIMITS , SYMMETRY ,
  REJECT , REINDEX , SCALE , SPLIT , TITLE , TOOFAR , NAME , PROCESS

  ACCEPT n1 n2 n3 . . . (N.B. NOT WORKING!!!)

   Set  flags  to  accept reflections labelled with error flags n1,n2 etc
   (cf  REJECT command below). MADNES sets a bit flag for each reflection
   for  error  conditions:  this  command (and REJECT) allow selection of
   which classes of reflection to accept. The flags are as follows:-

   Flag   Default        Error
  Number  Setting       Condition

     1    accept      Not found (ie weak)
     2    accept      On YMS edge
     3    accept      On ZMS edge
     4    accept      On Phi edge
     5    reject      Too far from YMS
     6    reject      Too far from ZMS
     7    reject      Too far from Phi
     8    reject      Too big in YMS
     9    reject      Too big in ZMS
    10    reject      Too big in Phi
    11    reject      Background bad
    12    reject      Background sd bad
    13    reject      Negative sd
    14    accept      Fobs <= 0.0
    15    reject      Bad pixels
    16    reject      Overflow

  BATCH <batch number> [ <maximum batch number> ]

   Set  BATCH  number  for output file. If the SPLIT option is used (qv),
   this  will be the first batch number. Remember that batch numbers must
   be  unique for all batches in an MTZ file. When reading multiple DTREK
   data  reflection  files  a  separate BATCH command must be used before
   each  PROCESS  keyword otherwise the program will not give the correct
   performance.  Watch  out  if  using  the  SPLIT  option as well; batch
   numbers  must be unique, and no check is made of this, so the starting
   batch  number  for each group must be sufficiently well separated. The
   optional  maximum  batch  number  may  be used to avoid having a final
   batch with very few reflections in it.

  BTITLE <title>

   Set batch title for output MTZ file (defaults = file title TITLE)

  CRYSTAL <crystal_number>

   Set  crystal  number,  a number defining a crystal which may contain a
   number  of  batches.  This number is not currently used, but may be in
   future. The crystal number defaults to the first batch number.

  FILE <filename>

   Filename for d*trek reflection file. (default = dtprofit.ref).

  HFILE <filename>

   Filename  for  the  d*trek  header  file after the integration/profile
   fitting stage. (default = dtintegrate.head) (see example).

  LIMITS <Ymin> <Ymax> <Zmin> <Zmax>

   Set limits on detector position Y,Z for reflection to be accepted This
   may  be  used to exclude reflections near the edge of the detector The
   default is not to check detector position.

  REINDEX <reindexing_rule>

   Reindex  data,  according  to  a  matrix specified in a similar way to
   symmetry operations
e.g. reindex   k, h, -l
     reindex   h, -k, -h/2-l/2

   Cell  dimensions  will  be  recalculated  for  the  redefined cell. Be
   careful  that the index transformation preserves the hand of the axes,
   ie  that  the  matrix has a positive determinant. The program will not
   allow  you  to  invert  the  hand  (eg  k,h,l  is forbidden, k,h,-l is
   allowed).  If  the transformation leads to fractional indices for some
   cases  (as  in  the  2nd  example  above),  these  reflections will be
   rejected.  If the reindexing operations include translations, then the
   orientation  data  in  the  output  file will not be strictly correct.
   Translations  (eg  h,k,l+1)  can be useful if you have misindexed your
   crystal  by  eg  1  lattice  point  (usually  along the spindle axis).
   However, in this case, you OUGHT to reprocess the data.

  REJECT n1 n2 n3 . . .

   Set  flags  to  reject reflections labelled with error flags n1,n2 etc
   (cf ACCEPT command above).

  SCALE <scale_factor>

   Set  output scale factor (default = 1.0). This can be adjusted to give
   intensities in a suitable range.

  SPLIT <psi_range>

   By default the actual oscillation range per image read from the header
   file  is  used to split the reflection into BATCHes. If <psi-range> is
   set  then BATCHing is performed accordingly based on the requested psi
   range.

  SYMMETRY <space-group name | space-group number | symmetry>

   (compulsory)

   Read  the symmetry operations, specified as the name (eg P212121), the
   International  Tables  number,  or  as  a  series of SYMMETRY commands
   giving the symmetry operations (eg SYMMETRY X,Y,Z * -X,Y+1/2,-Z)

   This  last  option  is not recommended. The symmetry matrices are read
   from  a  standard file (logical name SYMOP), are printed, and are used
   to  reduce the reflections to an asymmetric unit. The column M/ISYM in
   the  output file contains the number of the symmetry operation used to
   do   this,   odd   numbers   correspond   to  +hkl,  even  numbers  to
   Bijvoet-related  reflections  -hkl.  The  asymmetric  unit is selected
   according to the rule printed out with the symmetry

  TITLE <Title>

   Set file title for output MTZ file.

  TOOFAR <Yshift> <Zshift> <Phishift>

   Sets values for the maximum difference between calculated and observed
   position  for  a  reflection  to be accepted. Yshift and Zshift are in
   pixels, Phishift is in degrees. The default is not to do any checks on
   positional differences.

  NAME PROJECT <pname> CRYSTAL <xname> DATASET <dname>

   [Note that the keywords PNAME <pname>, XNAME <xname> and DNAME <dname>
   are also available, but the NAME keyword is preferred.]

   Specify  the  project,  crystal  and  dataset names for the output MTZ
   file.  It  is  strongly  recommended  that  this information is given.
   Otherwise,   the  default  project,  crystal  and  dataset  names  are
   "unknown",   "unknown"   and   "unknown<ddmmyy>"  respectively  (where
   <ddmmyy> is the date, with no spaces).

   The  project-name  specifies  a particular structure solution project,
   the  crystal  name  specifies  a physical crystal contributing to that
   project,  and the dataset-name specifies a particular dataset obtained
   from that crystal. All three should be given.

  UGCB

   If this keyword is present the D*TREK Goniostat matrix formed from the
   DATUM values given in the header keyword CRYSTAL_ORIENT_VALUES will be
   included  into  the  UMAT written in to the mtz file batch header. The
   Goniostat  datum  values  are  consequently  set  to zero. The default
   behaviour  is  for  the  Goniostat orientation to be excluded from the
   UMAT.  Scala  versions  before  scala-3.1.4-beta  (22 April 2002) will
   expect  mtz  files  generated  from  DTREK2SCALA using the UGCB option
   because they make no use of the Datum values.

  PROCESS

   (compulsory)

   Process the currently-defined input file (from FILE command or logical
   name MADHKL).

INPUT_FILES

  D*TREK

   D*TREK ASCII reflection file
   A  d*trek  reflection file created by dtintegrate or dtprofit (usually
   called  dtintegrate.ref  or  dtprofit.ref) must be specified using the
   FILE  command  (see  example).  If  D*TREK  is  set  to produce binary
   reflection  files then you must first convert the binary file to ASCII
   using the D*TREK command

   dtreflnmerge <input-file> <output-file> -text

   The reflection file header provides a description of all the fields of
   the  reflection  file. The header should something like this otherwise
   the program may fail to convert correctly.
4 20 1
nH                  ; miller index
nK                  ; miller index
nL                  ; miller index
nBadFlag
fIntensity          ; profile fitted intensity
fSigmaI             ; sigma of profile fitted intensity
fOtherInt           ; integrated intensity
fOtherSig           ; sigma of integrated intensity
fObs_pixel0         ; vertical detector coordinate of reflection (Y)
fObs_pixel1         ; horizontal detector coordinate of reflection (Z)
fObs_rot_mid        ; observed reflection centroid
fObs_rot_width
fCalc_pixel0
fCalc_pixel1
fCalc_rot_mid
fResolution
fLPfactor           ; Lorentz and polarization correction factor
fCorrelation
sBatch              ; Batch number from integration

   The  relevant  fields  used  by  MADNES  are  described  briefly.  The
   reflections are listed sequentially in free format.

   D*TREK header file
   The  d*trek  header  file  contains  a  whole lot of information which
   allows  you  to  find  out  just  about anything about your experiment
   (assuming  of  course that you and the beamline software remembered to
   write  the  correct  values to the image headers. In principle though,
   the important information about the experiment should be correct as it
   is  necessary  to  correctly analyse your data and should therefore be
   available  for  reading by DTREK2SCALA. The following is a list of the
   d*trek header items used by DTREK2SCALA. If you encounter difficulties
   in converting your data then checking your d*trek header file may be a
   place to start. The d*trek header file can also be specified using the
   HFILE  command.  The file is named dtintegrate.head by default in both
   d*trek and in DTREK2SCALA.
CRYSTAL_GONIO_VALUES        Datum position on MGONAX
                            goniostat axes (degrees)
CRYSTAL_UNIT_CELL           Cell dimensions (A & degrees)
CRYSTAL_SPACEGROUP          space group number
CRYSTAL_ORIENT_VECTORS      Axis permutation from d*trek.
CRYSTAL_ORIENT_ANGLES       "missetting" angles (degrees)
APS1_GONIO_VALUES(6)        Crystal to detector distance (mm)
APS1_GONIO_VALUES(1,2,3)    detector tilts: DTAU(2) = theta
                            detector swing angle (degrees)
SOURCE_ORIENT_ANGLES        beam tilt angles (degrees)
CRYSTAL_MOSAICITY           reflection width (degrees)
SCAN_WAVELENGTH             wavelength (A)
SOURCE_SPECTRAL_DISPERSION  dispersion (delta lambda/lambda)
SOURCE_CROSSFIRE            synchrotron beam parameters:
                            gammaH, gammaV, Delcor, ?syn4?
                            scan axis number (1 -> MGONAX)
SCAN_ROTATION(1,2)          start and stop values of psi
                            (D*trek scan axes - usually Omega)  (degrees)
SCAN_ROTATION(3)            rotation width of each image (degrees)
SCAN_ROTATION(4)            time for each image (seconds)
CRYSTAL_GONIO_NUM_VALUES    number of crystal goniostat axes
CRYSTAL_GONIO_VECTORS       vectors defining the directions
                            of the MGONAX goniostat axes,
                            in the d*trek laboratory frame.
                            GONVEC(I,J),I=1,3 applies to the J'th axis
SOURCE_VECTORS(1,2,3)       idealized main beam vector
                            (anti-parallel to beam!), in d*trek
                            laboratory frame (excluding the
                            tilts parameterized by MU)
SOURCE_VECTORS(1,2,3)       main beam vector (anti-parallel
                            to beam!), in d*trek laboratory frame
                            (including the tilts parameterized by MU)
APS1_DETECTOR_DIMENSIONS    detector limits minimum, maximum Yms, Zms
APS1_GONIO_VECTORS          vectors defining detector rotations
APS1_DETECTOR_VECTORS       vectors defining detector translations
DTREFINE_RMS_MM             rms positional errors from last refinement
DTREFINE_RMS_DEG            rms rotational errors from last refinement
APS1_GONIO_VALUES(4,5)      detector offsets ccx, ccy
DTP_DTINTEGRATE_OPTIONS(11) number of images per batch used in dtintegrate

     New common block for d*trek specific things

SCAXIS                      scan axis
GONAX(3)                    names of the MGONAX goniostat axes
DETAX(3)                    names of the detector rotation angles
COMMENT                     crystal description

   N.B.  The  d*trek laboratory frame has X along the omega axis (towards
   base  plate  of  goniometer),  Z  antiparallel to the X-ray beam and Y
   completing a right-handed system. All rotations are right-handed. This
   information is encoded in GONVEC & S0, so these are used to define the
   frame.

OUTPUT_FILES

   HKLOUT  --  Multi-record MTZ file. Each batch has an orientation block
   as  defined  in  mtzlib.doc  for  area detectors. The columns for each
   reflection are
H K L       indices
M/ISYM      symmetry number, ie number of the Laue-group matrix used to reduce
this reflection to the asymmetric unit
BATCH batch number
I, SIGI intensity and standard deviation
IPR, SIGIPR intensity and standard deviation (in this case same as I, SIGI)
IERROR error flag from D*TREK
XDET,YDET detector coordinates of reflection (pixels)
XDET = Yms, YDET = Zms (ie Mosflm convention)
ROT rotation angle (degrees)
LP Lorentz and polarisation correction (d*trek only) LP

   This  file  must  be sorted on H K L M/ISYM BATCH before processing by
   SCALA. Several files may be sorted together by SORTMTZ.

EXAMPLES

   1. An example which runs on d*trek profile fitted reflection data
############## START EXAMPLE 1 ##################
dtrek2scala    hklout   junk.mtz    plot absplot  << eof
TITLE  Data processed with d*trek to 1.8A
SYMMETRY   20
CRYSTAL 1
BATCH 1
BTITLE  Crystal 1, run 1  # this title is for this batch only
FILE dtprofit_1.8A.ref
HFILE dtintegrate.head
PROCESS
eof
#
sortmtz HKLIN junk.mtz HKLOUT dtrek-data.mtz << EOF-sortmtz
#
# Sort keys since default keys are H K L
#
H K L M/ISYM
EOF-sortmtz
############## END EXAMPLE 1 ##################

   2. An example which reads two reflection files dataset1.ref and
   dataset2.ref with there own header files.
############## START EXAMPLE 2 ##################
#!/bin/csh -f
#
set ident      = mydata
set title      = 'A crystal soaked in lots of alcohol'
set lowres     = 30
set highres    = 1.8
set resol      = "${lowres} ${highres}"
set residues   = 203
set spacegroup = P43212
set symmetry   = 96
set scr        = $HOME/tmp
#
#
dtrek2scala hklout ${ident}.mtz > ${ident}.dtrek2scala.log << EOF
TITLE $title
SYMMETRY $symmetry
CRYSTAL 1
BATCH 1
FILE dataset1.ref
HFILE dataset1.head
BTITLE CHI=0, PHI=0
PROCESS
BATCH 300
FILE dataset2.ref
HFILE dataset2.head
BTITLE CHI=30, PHI=0
PROCESS
EOF
#
sortmtz hklout ${ident}_sort.mtz > ${ident}_sort.log << EOF-sortmtz
H K L M/ISYM BATCH
${ident}.mtz
EOF-sortmtz
############## END EXAMPLE 2 ##################

AUTHOR

   Based  on  the CCP4 program ABSURD. MTZ version May 1991 by Phil Evans
   and revised for use with D*TREK by Gwyndaf Evans.
   DTREK2SCALA by Gwyndaf Evans (1998-2003).
\end{verbatim}
}
\end{document}


