<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://viper.lbl.gov:8080/cctbx.xfel/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Tara</id>
	<title>cctbx_xfel - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://viper.lbl.gov:8080/cctbx.xfel/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Tara"/>
	<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php/Special:Contributions/Tara"/>
	<updated>2026-06-02T14:16:45Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.15</generator>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=889</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=889"/>
		<updated>2014-10-06T21:55:24Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Solve the structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
&lt;br /&gt;
On pslogin, download the reference structure 4etc from the pdb (must be done on pslogin, the only outward-facing host).  4etc.pdb will be used for per-image scaling; 4etc.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme0.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 ./mergeLysozyme0.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymenoamo_4etc.log | Log file with model scaling and no anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymeanom_4etc.log | Log file with model scaling and anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Trying to merge not scaling to a model:&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymeanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymenoanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
 phenix.xtriage GdLysozymenoanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
 phenix.xtriage GdLysozymeanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_anom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.58 no anomalous&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.12 anomalous&lt;br /&gt;
&lt;br /&gt;
Use Gd-Lysozyme anomalous structure to get Gd sites:&lt;br /&gt;
 phenix.fetch_pdb --mtz 4n5r&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags using those generated in the refinement from 4n5r.pdb and extending the resolution from 1.5 -  100 using phenix&lt;br /&gt;
(new R-free-flags file is reflections.mtz) &lt;br /&gt;
generate restraints for the &amp;quot;DO3&amp;quot; ligands using phenix.elbow&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine 4n5r.pdb [[DO3.cif]] refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=GdLysozymeanom_4etc_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=reflections.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=FreeR_flag \&lt;br /&gt;
  main.number_of_macro_cycles=7 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=Iobs unit_cell=&amp;quot;78.033, 78.033, 38.833&amp;quot; \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
RWORK = 20.25% RFREE = 23.7% out to 1.9 Angstrom&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb GdLysozymeanom_4etc_s0_mark0.mtz  \&lt;br /&gt;
  selection=&amp;quot;element GD&amp;quot;&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=001_data.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the two Gd sites:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;GD    GD A 201 &amp;quot; :  17.85 sigma&lt;br /&gt;
pdb=&amp;quot;GD    GD A 202 &amp;quot; :  23.46 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=888</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=888"/>
		<updated>2014-10-06T21:49:07Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Solve the structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
&lt;br /&gt;
On pslogin, download the reference structure 4etc from the pdb (must be done on pslogin, the only outward-facing host).  4etc.pdb will be used for per-image scaling; 4etc.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme0.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 ./mergeLysozyme0.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymenoamo_4etc.log | Log file with model scaling and no anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymeanom_4etc.log | Log file with model scaling and anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Trying to merge not scaling to a model:&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymeanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymenoanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
 phenix.xtriage GdLysozymenoanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
 phenix.xtriage GdLysozymeanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_anom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.58 no anomalous&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.12 anomalous&lt;br /&gt;
&lt;br /&gt;
Use Gd-Lysozyme anomalous structure to get Gd sites:&lt;br /&gt;
 phenix.fetch_pdb --mtz 4n5r&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags using those generated in the refinement from 4n5r.pdb and extending the resolution from 1.5 -  100 using phenix&lt;br /&gt;
(new R-free-flags file is reflections.mtz) &lt;br /&gt;
generate restraints for the &amp;quot;DO3&amp;quot; ligands using phenix.elbow&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine 4n5r.pdb [[DO3.cif]] refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=GdLysozymeanom_4etc_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=reflections.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=FreeR_flag \&lt;br /&gt;
  main.number_of_macro_cycles=7 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=Iobs unit_cell=&amp;quot;78.033, 78.033, 38.833&amp;quot; \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
RWORK = 20.25% RFREE = 23.7% out to 1.9 Angstrom&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  Gd-Lysozyme_mark0_refine_28.pdb GdLysozymeanom_4etc_s0_mark0.mtz  \&lt;br /&gt;
  selection=&amp;quot;element GD&amp;quot;&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=reflections.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=FreeR_flag&lt;br /&gt;
&lt;br /&gt;
Promising results for the two Gd sites:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;GD    GD A 201 &amp;quot; :  19.16 sigma&lt;br /&gt;
pdb=&amp;quot;GD    GD A 202 &amp;quot; :  24.09 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=887</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=887"/>
		<updated>2014-10-06T21:39:18Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Solve the structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
&lt;br /&gt;
On pslogin, download the reference structure 4etc from the pdb (must be done on pslogin, the only outward-facing host).  4etc.pdb will be used for per-image scaling; 4etc.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme0.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 ./mergeLysozyme0.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymenoamo_4etc.log | Log file with model scaling and no anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymeanom_4etc.log | Log file with model scaling and anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Trying to merge not scaling to a model:&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymeanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymenoanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
 phenix.xtriage GdLysozymenoanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
 phenix.xtriage GdLysozymeanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_anom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.58 no anomalous&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.12 anomalous&lt;br /&gt;
&lt;br /&gt;
Use Gd-Lysozyme anomalous structure to get Gd sites:&lt;br /&gt;
 phenix.fetch_pdb --mtz 4n5r&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags using those generated in the refinement from 4n5r.pdb and extending the resolution from 1.5 -  100 using phenix&lt;br /&gt;
(new R-free-flags file is reflections.mtz) &lt;br /&gt;
generate restraints for the &amp;quot;DO3&amp;quot; ligands using phenix.elbow&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine 4n5r.pdb [[DO3.cif]] refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=GdLysozymeanom_4etc_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=reflections.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=FreeR_flag \&lt;br /&gt;
  main.number_of_macro_cycles=7 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=Iobs unit_cell=&amp;quot;78.033, 78.033, 38.833&amp;quot; \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
RWORK = 20.4% RFREE = 25.3% out to 1.9 Angstrom&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  Gd-Lysozyme_mark0_refine_28.pdb GdLysozymeanom_4etc_s0_mark0.mtz  \&lt;br /&gt;
  selection=&amp;quot;element GD&amp;quot;&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=reflections.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=FreeR_flag&lt;br /&gt;
&lt;br /&gt;
Promising results for the two Gd sites:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;GD    GD A 201 &amp;quot; :  19.16 sigma&lt;br /&gt;
pdb=&amp;quot;GD    GD A 202 &amp;quot; :  24.09 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=886</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=886"/>
		<updated>2014-10-06T21:33:23Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Solve the structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
&lt;br /&gt;
On pslogin, download the reference structure 4etc from the pdb (must be done on pslogin, the only outward-facing host).  4etc.pdb will be used for per-image scaling; 4etc.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme0.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 ./mergeLysozyme0.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymenoamo_4etc.log | Log file with model scaling and no anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymeanom_4etc.log | Log file with model scaling and anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Trying to merge not scaling to a model:&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymeanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymenoanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
 phenix.xtriage GdLysozymenoanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
 phenix.xtriage GdLysozymeanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_anom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.58 no anomalous&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.12 anomalous&lt;br /&gt;
&lt;br /&gt;
Use Gd-Lysozyme anomalous structure to get Gd sites:&lt;br /&gt;
 phenix.fetch_pdb --mtz 4n5r&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags using those generated in the refinement from 4n5r.pdb &lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine 4n5r.pdb [[DO3.cif]] refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=GdLysozymeanom_4etc_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=reflections.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=FreeR_flag \&lt;br /&gt;
  main.number_of_macro_cycles=7 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=Iobs unit_cell=&amp;quot;78.033, 78.033, 38.833&amp;quot; \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
RWORK = 20.4% RFREE = 25.3% out to 1.9 Angstrom&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  Gd-Lysozyme_mark0_refine_28.pdb GdLysozymeanom_4etc_s0_mark0.mtz  \&lt;br /&gt;
  selection=&amp;quot;element GD&amp;quot;&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=reflections.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=FreeR_flag&lt;br /&gt;
&lt;br /&gt;
Promising results for the two Gd sites:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;GD    GD A 201 &amp;quot; :  19.16 sigma&lt;br /&gt;
pdb=&amp;quot;GD    GD A 202 &amp;quot; :  24.09 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=885</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=885"/>
		<updated>2014-10-06T20:41:51Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Solve the structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
&lt;br /&gt;
On pslogin, download the reference structure 4etc from the pdb (must be done on pslogin, the only outward-facing host).  4etc.pdb will be used for per-image scaling; 4etc.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme0.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 ./mergeLysozyme0.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymenoamo_4etc.log | Log file with model scaling and no anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymeanom_4etc.log | Log file with model scaling and anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Trying to merge not scaling to a model:&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymeanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymenoanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
 phenix.xtriage GdLysozymenoanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
 phenix.xtriage GdLysozymeanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_anom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.58 no anomalous&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.12 anomalous&lt;br /&gt;
&lt;br /&gt;
Use Gd-Lysozyme anomalous structure to get Gd sites:&lt;br /&gt;
 phenix.fetch_pdb --mtz 4n5r&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags using those generated in the refinement from 4n5r.pdb &lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine 4n5r.pdb [[DO3.cif]] refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=GdLysozymeanom_4etc_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=reflections.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=FreeR_flag \&lt;br /&gt;
  main.number_of_macro_cycles=7 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=Iobs(+),SIGIobs(+),Iobs(-),SIGIobs(-), \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
RWORK = 20.4% RFREE = 25.3% out to 1.9 Angstrom&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  Gd-Lysozyme_mark0_refine_28.pdb GdLysozymeanom_4etc_s0_mark0.mtz  \&lt;br /&gt;
  selection=&amp;quot;element GD&amp;quot;&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=reflections.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=FreeR_flag&lt;br /&gt;
&lt;br /&gt;
Promising results for the two Gd sites:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;GD    GD A 201 &amp;quot; :  19.16 sigma&lt;br /&gt;
pdb=&amp;quot;GD    GD A 202 &amp;quot; :  24.09 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=884</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=884"/>
		<updated>2014-10-06T20:09:59Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Solve the structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
&lt;br /&gt;
On pslogin, download the reference structure 4etc from the pdb (must be done on pslogin, the only outward-facing host).  4etc.pdb will be used for per-image scaling; 4etc.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme0.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 ./mergeLysozyme0.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymenoamo_4etc.log | Log file with model scaling and no anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymeanom_4etc.log | Log file with model scaling and anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Trying to merge not scaling to a model:&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymeanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymenoanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
 phenix.xtriage GdLysozymenoanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
 phenix.xtriage GdLysozymeanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_anom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.58 no anomalous&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.12 anomalous&lt;br /&gt;
&lt;br /&gt;
Use Gd-Lysozyme anomalous structure to get Gd sites:&lt;br /&gt;
 phenix.fetch_pdb --mtz 4n5r&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags using those generated in the refinement from 4n5r.pdb &lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine 4n5r.pdb [[DO3.cif]] refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=GdLysozymeanom_4etc_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=reflections.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=FreeR_flag \&lt;br /&gt;
  main.number_of_macro_cycles=7 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=Iobs(+),SIGIobs(+),Iobs(-),SIGIobs(-), \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
RWORK = 20.4% RFREE = 25.3% out to 1.9 Angstrom&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  Gd-Lysozyme_mark0_refine_28.pdb GdLysozymeanom_4etc_s0_mark0.mtz  \&lt;br /&gt;
  selection=&amp;quot;element GD&amp;quot;&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=reflections.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=FreeR_flag&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=883</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=883"/>
		<updated>2014-10-06T20:08:45Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Solve the structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
&lt;br /&gt;
On pslogin, download the reference structure 4etc from the pdb (must be done on pslogin, the only outward-facing host).  4etc.pdb will be used for per-image scaling; 4etc.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme0.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 ./mergeLysozyme0.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymenoamo_4etc.log | Log file with model scaling and no anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymeanom_4etc.log | Log file with model scaling and anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Trying to merge not scaling to a model:&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymeanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymenoanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
 phenix.xtriage GdLysozymenoanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
 phenix.xtriage GdLysozymeanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_anom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.58 no anomalous&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.12 anomalous&lt;br /&gt;
&lt;br /&gt;
Use Gd-Lysozyme anomalous structure to get Gd sites:&lt;br /&gt;
 phenix.fetch_pdb --mtz 4n5r&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags using those generated in the refinement from 4n5r.pdb &lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine 4n5r.pdb [[DO3.cif]] refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=GdLysozymeanom_4etc_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=reflections.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=FreeR_flag \&lt;br /&gt;
  main.number_of_macro_cycles=7 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=Iobs(+),SIGIobs(+),Iobs(-),SIGIobs(-), \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
RWORK = 20.4% RFREE = 25.3% out to 1.9 Angstrom&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  Gd-Lysozyme_mark0_refine_28.pdb GdLysozymeanom_4etc_s0_mark0.mtz  \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=reflections.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=FreeR_flag&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=DO3.cif&amp;diff=882</id>
		<title>DO3.cif</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=DO3.cif&amp;diff=882"/>
		<updated>2014-10-06T19:59:40Z</updated>

		<summary type="html">&lt;p&gt;Tara: Created page with &amp;quot;&amp;lt;pre&amp;gt;# electronic Ligand Builder and Optimisation Workbench (eLBOW) #   - a module of PHENIX version 1.9-1692 #   - file written: Mon Oct  6 11:54:24 2014 # #   Input file: /U...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;pre&amp;gt;# electronic Ligand Builder and Optimisation Workbench (eLBOW)&lt;br /&gt;
#   - a module of PHENIX version 1.9-1692&lt;br /&gt;
#   - file written: Mon Oct  6 11:54:24 2014&lt;br /&gt;
#&lt;br /&gt;
#   Input file: /Users/Tara/projects/Gd-Lysozyme_mark0/.phenix/tmp/libtbx_run_29.eff&lt;br /&gt;
#   Inital geometry file: a 136 line input string&lt;br /&gt;
#   Ligand name: 2,2&#039;,2&#039;&#039;-{10-[(2R)-2-hydroxypropyl]-1,4,7,10-tetraazacyclododecane-1,4,7-triyl}triacetic acid&lt;br /&gt;
#   Quantum optimisation: True&lt;br /&gt;
#   Method: uhf&lt;br /&gt;
#   Random seed: 3628800&lt;br /&gt;
#   SMILES string: C[C@@H](O)CN1CCN(CCN(CCN(CC1)CC(O)=O)CC(O)=O)CC(O)=O&lt;br /&gt;
#&lt;br /&gt;
data_comp_list&lt;br /&gt;
loop_&lt;br /&gt;
_chem_comp.id&lt;br /&gt;
_chem_comp.three_letter_code&lt;br /&gt;
_chem_comp.name&lt;br /&gt;
_chem_comp.group&lt;br /&gt;
_chem_comp.number_atoms_all&lt;br /&gt;
_chem_comp.number_atoms_nh&lt;br /&gt;
_chem_comp.desc_level&lt;br /&gt;
DO3        DO3 &#039;2,2&#039;,2&#039;&#039;-{10-[(2R)-2-hydroxypropyl]-1,4,7,10-tetraazacyclododecane-1,4,7-triyl}triacetic acid&#039; ligand 57 28 .&lt;br /&gt;
#&lt;br /&gt;
data_comp_DO3&lt;br /&gt;
#&lt;br /&gt;
loop_&lt;br /&gt;
_chem_comp_atom.comp_id&lt;br /&gt;
_chem_comp_atom.atom_id&lt;br /&gt;
_chem_comp_atom.type_symbol&lt;br /&gt;
_chem_comp_atom.type_energy&lt;br /&gt;
_chem_comp_atom.partial_charge&lt;br /&gt;
_chem_comp_atom.x&lt;br /&gt;
_chem_comp_atom.y&lt;br /&gt;
_chem_comp_atom.z&lt;br /&gt;
DO3         N1     N   NT     -0.274    0.0291   -0.0438   -0.0784&lt;br /&gt;
DO3         N2     N   NT     -0.287    2.3565    1.3262    1.9879&lt;br /&gt;
DO3         N3     N   NT     -0.269   -0.1370    3.4156    3.6905&lt;br /&gt;
DO3         N4     N   NT     -0.260   -0.8446    3.2869    0.2136&lt;br /&gt;
DO3         O1     O   OC     -0.631    0.0334   -3.5820   -0.9372&lt;br /&gt;
DO3         O3     O   OC     -0.632    3.0340    3.1965   -1.0894&lt;br /&gt;
DO3         O5     O   OC     -0.631    0.2762    4.5054    7.1382&lt;br /&gt;
DO3         O7     O   OH1    -0.265    0.3395    4.5422   -2.1839&lt;br /&gt;
DO3         C1     C   CH2    -0.025    1.5395   -0.0869    0.0002&lt;br /&gt;
DO3         C2     C   CH2     0.028    2.0489   -0.0357    1.4352&lt;br /&gt;
DO3         C3     C   CH2    -0.020    1.2796    1.4994    3.0164&lt;br /&gt;
DO3         C4     C   CH2    -0.014    1.2692    2.8979    3.5879&lt;br /&gt;
DO3         C5     C   CH2    -0.034   -0.3902    4.2232    2.4544&lt;br /&gt;
DO3         C6     C   CH2    -0.018   -1.3942    3.5027    1.5872&lt;br /&gt;
DO3         C7     C   CH2    -0.013   -1.3922    1.9560   -0.2163&lt;br /&gt;
DO3         C8     C   CH2    -0.045   -0.3510    1.1278   -0.9364&lt;br /&gt;
DO3         C9     C   C       0.388    0.1544   -2.5465   -0.2939&lt;br /&gt;
DO3         C10    C   CH2    -0.103   -0.2942   -1.2312   -0.9132&lt;br /&gt;
DO3         C11    C   C       0.388    3.1731    2.4289   -0.1301&lt;br /&gt;
DO3         C12    C   CH2    -0.130    2.1016    2.3468    0.9335&lt;br /&gt;
DO3         C13    C   C       0.390    0.1454    3.7752    6.1594&lt;br /&gt;
DO3         C14    C   CH2    -0.106   -0.0717    4.4077    4.7918&lt;br /&gt;
DO3         C15    C   CH1     0.091   -1.0025    4.2200   -2.0754&lt;br /&gt;
DO3         C16    C   CH2    -0.067   -1.5194    4.2965   -0.6404&lt;br /&gt;
DO3         C17    C   CH3    -0.219   -1.8633    5.1850   -2.8964&lt;br /&gt;
DO3         O2     O   O      -0.599    0.6617   -2.5116    0.8698&lt;br /&gt;
DO3         O4     O   O      -0.634    4.1827    1.6692    0.0066&lt;br /&gt;
DO3         O6     O   O      -0.594    0.1878    2.5084    6.2117&lt;br /&gt;
DO3         HO7    H   HOH1    0.185    0.4659    5.3919   -1.7532&lt;br /&gt;
DO3        HC11    H   HCH2    0.074    1.9670    0.6504   -0.7133&lt;br /&gt;
DO3        HC12    H   HCH2    0.056    1.9139   -1.0302   -0.4344&lt;br /&gt;
DO3        HC21    H   HCH2    0.054    2.9516   -0.6701    1.5056&lt;br /&gt;
DO3        HC22    H   HCH2    0.078    1.2788   -0.5225    2.0859&lt;br /&gt;
DO3        HC31    H   HCH2    0.060    1.4674    0.7746    3.8353&lt;br /&gt;
DO3        HC32    H   HCH2    0.058    0.2938    1.2326    2.5621&lt;br /&gt;
DO3        HC41    H   HCH2    0.039    1.8720    3.6327    2.9847&lt;br /&gt;
DO3        HC42    H   HCH2    0.079    1.7730    2.8815    4.5685&lt;br /&gt;
DO3        HC51    H   HCH2    0.086    0.5682    4.4283    1.9107&lt;br /&gt;
DO3        HC52    H   HCH2    0.013   -0.8165    5.2100    2.7397&lt;br /&gt;
DO3        HC61    H   HCH2   -0.005   -2.3393    4.0905    1.5177&lt;br /&gt;
DO3        HC62    H   HCH2    0.104   -1.6842    2.5191    2.0268&lt;br /&gt;
DO3        HC71    H   HCH2    0.089   -1.7857    1.4137    0.6757&lt;br /&gt;
DO3        HC72    H   HCH2   -0.006   -2.2754    2.1262   -0.8766&lt;br /&gt;
DO3        HC81    H   HCH2    0.122    0.5492    1.7322   -1.2170&lt;br /&gt;
DO3        HC82    H   HCH2    0.010   -0.7937    0.7730   -1.8940&lt;br /&gt;
DO3        H101    H   HCH2    0.027   -1.3784   -1.2676   -1.1327&lt;br /&gt;
DO3        H102    H   HCH2    0.011    0.2276   -1.1068   -1.9061&lt;br /&gt;
DO3        H121    H   HCH2    0.067    1.1271    2.1425    0.4430&lt;br /&gt;
DO3        H122    H   HCH2    0.050    1.9327    3.3594    1.3624&lt;br /&gt;
DO3        H141    H   HCH2    0.010    0.7691    5.1234    4.5843&lt;br /&gt;
DO3        H142    H   HCH2    0.029   -1.0033    5.0084    4.8005&lt;br /&gt;
DO3         HA     H   HCH1    0.100   -1.1591    3.1718   -2.4402&lt;br /&gt;
DO3        H161    H   HCH2    0.052   -1.3924    5.3154   -0.2260&lt;br /&gt;
DO3        H162    H   HCH2    0.013   -2.6229    4.0763   -0.6347&lt;br /&gt;
DO3        H171    H   HCH3    0.051   -1.5772    5.1968   -3.9526&lt;br /&gt;
DO3        H172    H   HCH3    0.038   -2.9157    4.8898   -2.8349&lt;br /&gt;
DO3        H173    H   HCH3    0.039   -1.8312    6.1936   -2.4665&lt;br /&gt;
#&lt;br /&gt;
loop_&lt;br /&gt;
_chem_comp_bond.comp_id&lt;br /&gt;
_chem_comp_bond.atom_id_1&lt;br /&gt;
_chem_comp_bond.atom_id_2&lt;br /&gt;
_chem_comp_bond.type&lt;br /&gt;
_chem_comp_bond.value_dist&lt;br /&gt;
_chem_comp_bond.value_dist_esd&lt;br /&gt;
DO3   N1      C1    single        1.513 0.038&lt;br /&gt;
DO3   N1      C8    single        1.501 0.038&lt;br /&gt;
DO3   N1      C10   single        1.487 0.038&lt;br /&gt;
DO3   N2      C2    single        1.502 0.037&lt;br /&gt;
DO3   N2      C3    single        1.499 0.038&lt;br /&gt;
DO3   N2      C12   single        1.489 0.038&lt;br /&gt;
DO3   N3      C4    single        1.502 0.037&lt;br /&gt;
DO3   N3      C5    single        1.498 0.038&lt;br /&gt;
DO3   N3      C14   single        1.484 0.037&lt;br /&gt;
DO3   N4      C6    single        1.495 0.037&lt;br /&gt;
DO3   N4      C7    single        1.502 0.037&lt;br /&gt;
DO3   N4      C16   single        1.485 0.036&lt;br /&gt;
DO3   O1      C9    deloc         1.225 0.021&lt;br /&gt;
DO3   O3      C11   deloc         1.236 0.023&lt;br /&gt;
DO3   O5      C13   deloc         1.228 0.022&lt;br /&gt;
DO3   O7      C15   single        1.384 0.032&lt;br /&gt;
DO3   O7      HO7   single        0.961 0.036&lt;br /&gt;
DO3   C1      C2    single        1.524 0.034&lt;br /&gt;
DO3   C1     HC11   single        1.111 0.039&lt;br /&gt;
DO3   C1     HC12   single        1.104 0.037&lt;br /&gt;
DO3   C2     HC21   single        1.106 0.038&lt;br /&gt;
DO3   C2     HC22   single        1.120 0.039&lt;br /&gt;
DO3   C3      C4    single        1.511 0.033&lt;br /&gt;
DO3   C3     HC31   single        1.110 0.038&lt;br /&gt;
DO3   C3     HC32   single        1.118 0.039&lt;br /&gt;
DO3   C4     HC41   single        1.126 0.040&lt;br /&gt;
DO3   C4     HC42   single        1.103 0.037&lt;br /&gt;
DO3   C5      C6    single        1.510 0.033&lt;br /&gt;
DO3   C5     HC51   single        1.121 0.039&lt;br /&gt;
DO3   C5     HC52   single        1.112 0.038&lt;br /&gt;
DO3   C6     HC61   single        1.115 0.039&lt;br /&gt;
DO3   C6     HC62   single        1.116 0.039&lt;br /&gt;
DO3   C7      C8    single        1.513 0.033&lt;br /&gt;
DO3   C7     HC71   single        1.116 0.039&lt;br /&gt;
DO3   C7     HC72   single        1.116 0.039&lt;br /&gt;
DO3   C8     HC81   single        1.120 0.039&lt;br /&gt;
DO3   C8     HC82   single        1.113 0.038&lt;br /&gt;
DO3   C9      C10   single        1.521 0.035&lt;br /&gt;
DO3   C9      O2    deloc         1.270 0.015&lt;br /&gt;
DO3   C10    H101   single        1.107 0.037&lt;br /&gt;
DO3   C10    H102   single        1.129 0.039&lt;br /&gt;
DO3   C11     C12   single        1.512 0.034&lt;br /&gt;
DO3   C11     O4    deloc         1.271 0.017&lt;br /&gt;
DO3   C12    H121   single        1.110 0.038&lt;br /&gt;
DO3   C12    H122   single        1.113 0.038&lt;br /&gt;
DO3   C13     C14   single        1.522 0.035&lt;br /&gt;
DO3   C13     O6    deloc         1.269 0.016&lt;br /&gt;
DO3   C14    H141   single        1.124 0.039&lt;br /&gt;
DO3   C14    H142   single        1.109 0.037&lt;br /&gt;
DO3   C15     C16   single        1.527 0.034&lt;br /&gt;
DO3   C15     C17   single        1.532 0.035&lt;br /&gt;
DO3   C15     HA    single        1.121 0.039&lt;br /&gt;
DO3   C16    H161   single        1.107 0.038&lt;br /&gt;
DO3   C16    H162   single        1.125 0.039&lt;br /&gt;
DO3   C17    H171   single        1.094 0.037&lt;br /&gt;
DO3   C17    H172   single        1.095 0.037&lt;br /&gt;
DO3   C17    H173   single        1.097 0.037&lt;br /&gt;
#&lt;br /&gt;
loop_&lt;br /&gt;
_chem_comp_angle.comp_id&lt;br /&gt;
_chem_comp_angle.atom_id_1&lt;br /&gt;
_chem_comp_angle.atom_id_2&lt;br /&gt;
_chem_comp_angle.atom_id_3&lt;br /&gt;
_chem_comp_angle.value_angle&lt;br /&gt;
_chem_comp_angle.value_angle_esd&lt;br /&gt;
DO3   C10     N1      C8          104.32 2.582&lt;br /&gt;
DO3   C10     N1      C1          102.91 2.657&lt;br /&gt;
DO3   C8      N1      C1          107.74 2.670&lt;br /&gt;
DO3   C12     N2      C3          106.48 2.561&lt;br /&gt;
DO3   C12     N2      C2          109.02 2.744&lt;br /&gt;
DO3   C3      N2      C2          102.13 2.649&lt;br /&gt;
DO3   C14     N3      C5          105.04 2.585&lt;br /&gt;
DO3   C14     N3      C4          103.89 2.174&lt;br /&gt;
DO3   C5      N3      C4          106.72 2.368&lt;br /&gt;
DO3   C16     N4      C7          105.80 2.579&lt;br /&gt;
DO3   C16     N4      C6          105.27 2.444&lt;br /&gt;
DO3   C7      N4      C6          104.88 2.581&lt;br /&gt;
DO3   HO7     O7      C15         107.35 2.565&lt;br /&gt;
DO3  HC12     C1     HC11         100.58 2.873&lt;br /&gt;
DO3  HC12     C1      C2          106.62 2.586&lt;br /&gt;
DO3  HC11     C1      C2          116.99 2.658&lt;br /&gt;
DO3  HC12     C1      N1          110.02 2.443&lt;br /&gt;
DO3  HC11     C1      N1          109.37 2.377&lt;br /&gt;
DO3   C2      C1      N1          112.44 2.382&lt;br /&gt;
DO3  HC22     C2     HC21         105.97 2.878&lt;br /&gt;
DO3  HC22     C2      C1          107.63 2.663&lt;br /&gt;
DO3  HC21     C2      C1          108.28 2.655&lt;br /&gt;
DO3  HC22     C2      N2          108.75 2.445&lt;br /&gt;
DO3  HC21     C2      N2          109.25 2.451&lt;br /&gt;
DO3   C1      C2      N2          116.46 2.449&lt;br /&gt;
DO3  HC32     C3     HC31         107.06 2.882&lt;br /&gt;
DO3  HC32     C3      C4          111.64 2.177&lt;br /&gt;
DO3  HC31     C3      C4          109.07 2.183&lt;br /&gt;
DO3  HC32     C3      N2          109.09 2.238&lt;br /&gt;
DO3  HC31     C3      N2          108.01 2.424&lt;br /&gt;
DO3   C4      C3      N2          111.80 2.440&lt;br /&gt;
DO3  HC42     C4     HC41         103.98 2.884&lt;br /&gt;
DO3  HC42     C4      C3          108.63 2.370&lt;br /&gt;
DO3  HC41     C4      C3          113.45 2.590&lt;br /&gt;
DO3  HC42     C4      N3          111.85 2.690&lt;br /&gt;
DO3  HC41     C4      N3          108.23 2.347&lt;br /&gt;
DO3  HC41     C4      N3          108.23 2.347&lt;br /&gt;
DO3   C3      C4      N3          110.57 2.361&lt;br /&gt;
DO3  HC52     C5     HC51         106.85 2.885&lt;br /&gt;
DO3  HC52     C5      C6          108.41 2.570&lt;br /&gt;
DO3  HC51     C5      C6          112.17 2.595&lt;br /&gt;
DO3  HC52     C5      N3          109.36 2.028&lt;br /&gt;
DO3  HC51     C5      N3          110.76 2.080&lt;br /&gt;
DO3   C6      C5      N3          109.21 2.002&lt;br /&gt;
DO3  HC62     C6     HC61         105.60 2.886&lt;br /&gt;
DO3  HC62     C6      C5          111.55 2.596&lt;br /&gt;
DO3  HC61     C6      C5          110.35 2.598&lt;br /&gt;
DO3  HC62     C6      N4          109.29 2.650&lt;br /&gt;
DO3  HC61     C6      N4          109.29 2.667&lt;br /&gt;
DO3   C5      C6      N4          110.62 2.662&lt;br /&gt;
DO3  HC72     C7     HC71         105.55 2.886&lt;br /&gt;
DO3  HC72     C7      C8          110.28 2.588&lt;br /&gt;
DO3  HC71     C7      C8          110.93 2.581&lt;br /&gt;
DO3  HC72     C7      N4          108.83 2.657&lt;br /&gt;
DO3  HC71     C7      N4          109.29 2.664&lt;br /&gt;
DO3   C8      C7      N4          111.75 2.649&lt;br /&gt;
DO3  HC82     C8     HC81         106.03 2.885&lt;br /&gt;
DO3  HC82     C8      C7          108.08 2.443&lt;br /&gt;
DO3  HC81     C8      C7          112.15 2.585&lt;br /&gt;
DO3  HC82     C8      N1          110.10 2.440&lt;br /&gt;
DO3  HC81     C8      N1          111.15 2.364&lt;br /&gt;
DO3   C7      C8      N1          109.24 2.368&lt;br /&gt;
DO3   O2      C9      C10         117.84 2.590&lt;br /&gt;
DO3   O2      C9      O1          122.95 2.656&lt;br /&gt;
DO3   C10     C9      O1          119.20 2.669&lt;br /&gt;
DO3  H102     C10    H101         106.38 2.860&lt;br /&gt;
DO3  H102     C10     C9          108.49 2.426&lt;br /&gt;
DO3  H101     C10     C9          109.95 2.574&lt;br /&gt;
DO3  H102     C10     N1          107.78 2.433&lt;br /&gt;
DO3  H101     C10     N1          110.52 2.360&lt;br /&gt;
DO3   C9      C10     N1          113.44 2.367&lt;br /&gt;
DO3   O4      C11     C12         117.06 2.583&lt;br /&gt;
DO3   O4      C11     O3          122.94 2.653&lt;br /&gt;
DO3   C12     C11     O3          119.99 2.657&lt;br /&gt;
DO3  H122     C12    H121         101.80 2.859&lt;br /&gt;
DO3  H122     C12     C11         109.23 2.447&lt;br /&gt;
DO3  H121     C12     C11         108.75 2.577&lt;br /&gt;
DO3  H122     C12     N2          112.14 2.403&lt;br /&gt;
DO3  H121     C12     N2          109.69 2.253&lt;br /&gt;
DO3   C11     C12     N2          114.46 2.283&lt;br /&gt;
DO3   O6      C13     C14         117.17 2.581&lt;br /&gt;
DO3   O6      C13     O5          123.87 2.663&lt;br /&gt;
DO3   C14     C13     O5          118.96 2.662&lt;br /&gt;
DO3  H142     C14    H141         106.56 2.860&lt;br /&gt;
DO3  H142     C14     C13         109.75 2.563&lt;br /&gt;
DO3  H141     C14     C13         108.90 2.584&lt;br /&gt;
DO3  H142     C14     N3          109.34 2.025&lt;br /&gt;
DO3  H141     C14     N3          108.77 2.080&lt;br /&gt;
DO3   C13     C14     N3          113.29 1.989&lt;br /&gt;
DO3   HA      C15     C17         109.64 2.718&lt;br /&gt;
DO3   HA      C15     C16         107.78 2.607&lt;br /&gt;
DO3   C17     C15     C16         106.37 2.350&lt;br /&gt;
DO3   HA      C15     O7          109.12 2.651&lt;br /&gt;
DO3   C17     C15     O7          110.87 2.658&lt;br /&gt;
DO3   C16     C15     O7          112.96 2.669&lt;br /&gt;
DO3  H162     C16    H161         106.90 3.000&lt;br /&gt;
DO3  H162     C16     C15         109.08 2.582&lt;br /&gt;
DO3  H161     C16     C15         111.04 2.562&lt;br /&gt;
DO3  H162     C16     N4          108.04 2.644&lt;br /&gt;
DO3  H161     C16     N4          111.00 2.670&lt;br /&gt;
DO3   C15     C16     N4          110.65 2.665&lt;br /&gt;
DO3  H173     C17    H172         104.72 2.854&lt;br /&gt;
DO3  H173     C17    H171         111.14 2.826&lt;br /&gt;
DO3  H172     C17    H171         107.96 2.851&lt;br /&gt;
DO3  H173     C17     C15         110.66 2.632&lt;br /&gt;
DO3  H172     C17     C15         109.89 2.609&lt;br /&gt;
DO3  H171     C17     C15         112.16 2.564&lt;br /&gt;
#&lt;br /&gt;
loop_&lt;br /&gt;
_chem_comp_tor.comp_id&lt;br /&gt;
_chem_comp_tor.id&lt;br /&gt;
_chem_comp_tor.atom_id_1&lt;br /&gt;
_chem_comp_tor.atom_id_2&lt;br /&gt;
_chem_comp_tor.atom_id_3&lt;br /&gt;
_chem_comp_tor.atom_id_4&lt;br /&gt;
_chem_comp_tor.value_angle&lt;br /&gt;
_chem_comp_tor.value_angle_esd&lt;br /&gt;
_chem_comp_tor.period&lt;br /&gt;
DO3 Var_01         N2      C2      C1      N1          -91.92  30.0 1&lt;br /&gt;
DO3 Var_02         N4      C7      C8      N1          110.95  30.0 1&lt;br /&gt;
DO3 Var_03         N3      C4      C3      N2          136.32  30.0 1&lt;br /&gt;
DO3 Var_04         N4      C6      C5      N3         -124.63  30.0 1&lt;br /&gt;
DO3 Var_05         C7      C8      N1      C1         -129.96  30.0 1&lt;br /&gt;
DO3 Var_06         C3      N2      C2      C1          111.18  30.0 1&lt;br /&gt;
DO3 Var_07         C4      C3      N2      C2         -172.19  30.0 1&lt;br /&gt;
DO3 Var_08         C8      N1      C1      C2          123.08  30.0 1&lt;br /&gt;
DO3 Var_09         C5      N3      C4      C3          -95.57  30.0 1&lt;br /&gt;
DO3 Var_10         C6      C5      N3      C4          111.01  30.0 1&lt;br /&gt;
DO3 Var_11         C8      C7      N4      C6         -138.68  30.0 1&lt;br /&gt;
DO3 Var_12         C9      C10     N1      C1           61.34  30.0 3&lt;br /&gt;
DO3 Var_13         C11     C12     N2      C2          -76.60  30.0 3&lt;br /&gt;
DO3 Var_14         C13     C14     N3      C4          -69.64  30.0 3&lt;br /&gt;
DO3 Var_15         C15     C16     N4      C6          177.79  30.0 3&lt;br /&gt;
DO3 Var_16         O1      C9      C10     N1         -174.46  30.0 2&lt;br /&gt;
DO3 Var_17         O3      C11     C12     N2          176.53  30.0 2&lt;br /&gt;
DO3 Var_18         O5      C13     C14     N3          176.74  30.0 2&lt;br /&gt;
#&lt;br /&gt;
loop_&lt;br /&gt;
_chem_comp_chir.comp_id&lt;br /&gt;
_chem_comp_chir.id&lt;br /&gt;
_chem_comp_chir.atom_id_centre&lt;br /&gt;
_chem_comp_chir.atom_id_1&lt;br /&gt;
_chem_comp_chir.atom_id_2&lt;br /&gt;
_chem_comp_chir.atom_id_3&lt;br /&gt;
_chem_comp_chir.volume_sign&lt;br /&gt;
DO3 chir_01   C15     O7      C16     C17   negativ&lt;br /&gt;
#&lt;br /&gt;
loop_&lt;br /&gt;
_chem_comp_plane_atom.comp_id&lt;br /&gt;
_chem_comp_plane_atom.plane_id&lt;br /&gt;
_chem_comp_plane_atom.atom_id&lt;br /&gt;
_chem_comp_plane_atom.dist_esd&lt;br /&gt;
DO3 plan-1     O1 0.020&lt;br /&gt;
DO3 plan-1     C9 0.020&lt;br /&gt;
DO3 plan-1    C10 0.020&lt;br /&gt;
DO3 plan-1     O2 0.020&lt;br /&gt;
DO3 plan-2     O3 0.020&lt;br /&gt;
DO3 plan-2    C11 0.020&lt;br /&gt;
DO3 plan-2    C12 0.020&lt;br /&gt;
DO3 plan-2     O4 0.020&lt;br /&gt;
DO3 plan-3     O5 0.020&lt;br /&gt;
DO3 plan-3    C13 0.020&lt;br /&gt;
DO3 plan-3    C14 0.020&lt;br /&gt;
DO3 plan-3     O6 0.020&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=881</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=881"/>
		<updated>2014-10-06T19:54:41Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Solve the structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
&lt;br /&gt;
On pslogin, download the reference structure 4etc from the pdb (must be done on pslogin, the only outward-facing host).  4etc.pdb will be used for per-image scaling; 4etc.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme0.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 ./mergeLysozyme0.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymenoamo_4etc.log | Log file with model scaling and no anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymeanom_4etc.log | Log file with model scaling and anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Trying to merge not scaling to a model:&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymeanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymenoanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
 phenix.xtriage GdLysozymenoanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
 phenix.xtriage GdLysozymeanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_anom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.58 no anomalous&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.12 anomalous&lt;br /&gt;
&lt;br /&gt;
Use Gd-Lysozyme anomalous structure to get Gd sites:&lt;br /&gt;
 phenix.fetch_pdb --mtz 4n5r&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags using those generated in the refinement from 4n5r.pdb &lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine 4n5r.pdb [[DO3.cif]] refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=GdLysozymeanom_4etc_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=reflections.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=FreeR_flag \&lt;br /&gt;
  main.number_of_macro_cycles=7 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=Iobs(+),SIGIobs(+),Iobs(-),SIGIobs(-), \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
RWORK = 20.4% RFREE = 25.3% out to 1.9 Angstrom&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=880</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=880"/>
		<updated>2014-10-06T18:16:32Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Solve the structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
&lt;br /&gt;
On pslogin, download the reference structure 4etc from the pdb (must be done on pslogin, the only outward-facing host).  4etc.pdb will be used for per-image scaling; 4etc.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme0.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 ./mergeLysozyme0.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymenoamo_4etc.log | Log file with model scaling and no anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymeanom_4etc.log | Log file with model scaling and anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Trying to merge not scaling to a model:&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymeanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymenoanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
 phenix.xtriage GdLysozymenoanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
 phenix.xtriage GdLysozymeanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_anom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.58 no anomalous&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.12 anomalous&lt;br /&gt;
&lt;br /&gt;
Use Gd-Lysozyme anomalous structure to get Gd sites:&lt;br /&gt;
 phenix.fetch_pdb --mtz 4n5r&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags using those generated in the refinement from 4n5r.pdb &lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine 4n5r.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=GdLysozymeanom_4etc_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=reflections.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=FreeR_flag \&lt;br /&gt;
  main.number_of_macro_cycles=7 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
RWORK = 21.2% RFREE = 25.7% out to 1.9 Angstrom&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=879</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=879"/>
		<updated>2014-10-06T18:10:42Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Solve the structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
&lt;br /&gt;
On pslogin, download the reference structure 4etc from the pdb (must be done on pslogin, the only outward-facing host).  4etc.pdb will be used for per-image scaling; 4etc.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme0.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 ./mergeLysozyme0.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymenoamo_4etc.log | Log file with model scaling and no anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymeanom_4etc.log | Log file with model scaling and anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Trying to merge not scaling to a model:&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymeanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymenoanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
 phenix.xtriage GdLysozymenoanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
 phenix.xtriage GdLysozymeanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_anom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.58 no anomalous&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.12 anomalous&lt;br /&gt;
&lt;br /&gt;
Use Gd-Lysozyme anomalous structure to get Gd sites:&lt;br /&gt;
 phenix.fetch_pdb --mtz 4n5r&lt;br /&gt;
 phenix.automr 4n5r.pdb GdLysozymeanom_4etc_s0_mark0.mtz seq_file=4n5r.fa identity=100 copies=1 build=False&lt;br /&gt;
&lt;br /&gt;
The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags using those generated in the refinement from 4n5r.pdb&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine 4n5r.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=GdLysozymeanom_4etc_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=reflections.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=FreeR_flag \&lt;br /&gt;
  main.number_of_macro_cycles=7 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
RWORK = 21.2% RFREE = 25.7% out to 1.9 Angstrom&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=GdLysozymeanom_4etc.log&amp;diff=878</id>
		<title>GdLysozymeanom 4etc.log</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=GdLysozymeanom_4etc.log&amp;diff=878"/>
		<updated>2014-10-06T18:09:42Z</updated>

		<summary type="html">&lt;p&gt;Tara: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Statistics for all reflections&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
                                      &amp;lt;asu    &amp;lt;obs&lt;br /&gt;
Bin  Resolution Range  Completeness  redun&amp;gt;  redun&amp;gt;  n_meas    &amp;lt;I&amp;gt;    &amp;lt;I/sig(I)&amp;gt;&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
  1 -1.0000 -  4.0934   [1828/1833] 2298.15 2304.44 4212517     39447   252.595&lt;br /&gt;
  2  4.0934 -  3.2490   [1830/1830] 1939.05 1939.05 3548462     32453   189.212&lt;br /&gt;
  3  3.2490 -  2.8382   [1824/1824] 1537.52 1537.52 2804431     21477   126.067&lt;br /&gt;
  4  2.8382 -  2.5787   [1840/1840] 1154.65 1154.65 2124556     15258    90.629&lt;br /&gt;
  5  2.5787 -  2.3938   [1828/1828]  806.92  806.92 1475042     10813    64.383&lt;br /&gt;
  6  2.3938 -  2.2527   [1829/1829]  490.95  490.95  897951      8109    44.146&lt;br /&gt;
  7  2.2527 -  2.1399   [1834/1834]  348.67  348.67  639455      6556    33.991&lt;br /&gt;
  8  2.1399 -  2.0467   [1825/1825]  248.58  248.58  453659      5487    27.376&lt;br /&gt;
  9  2.0467 -  1.9679   [1833/1833]  125.82  125.82  230635      3959    15.990&lt;br /&gt;
 10  1.9679 -  1.9000   [1828/1828]   40.39   40.39   73838      3177     8.017&lt;br /&gt;
&lt;br /&gt;
All                   [18299/18304]  899.29  899.53 16460546    14670    85.218&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
SUMMARY: For 20145 reflections, got slope 1.158594, correlation 0.736066&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Statistics for reflections where I &amp;gt; 0&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
                                      &amp;lt;asu    &amp;lt;obs&lt;br /&gt;
Bin  Resolution Range  Completeness  redun&amp;gt;  redun&amp;gt;  n_meas    &amp;lt;I&amp;gt;    &amp;lt;I/sig(I)&amp;gt;&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
  1 -1.0000 -  4.0934   [1828/1833] 1959.11 1964.47 3591049     39447   252.595&lt;br /&gt;
  2  4.0934 -  3.2490   [1830/1830] 1532.67 1532.67 2804794     32453   189.212&lt;br /&gt;
  3  3.2490 -  2.8382   [1824/1824] 1141.61 1141.61 2082298     21477   126.067&lt;br /&gt;
  4  2.8382 -  2.5787   [1840/1840]  830.67  830.67 1528427     15258    90.629&lt;br /&gt;
  5  2.5787 -  2.3938   [1828/1828]  573.73  573.73 1048772     10813    64.383&lt;br /&gt;
  6  2.3938 -  2.2527   [1829/1829]  345.94  345.94  632721      8109    44.146&lt;br /&gt;
  7  2.2527 -  2.1399   [1834/1834]  242.94  242.94  445557      6556    33.991&lt;br /&gt;
  8  2.1399 -  2.0467   [1825/1825]  170.84  170.84  311776      5487    27.376&lt;br /&gt;
  9  2.0467 -  1.9679   [1833/1833]   86.30   86.30  158183      3959    15.990&lt;br /&gt;
 10  1.9679 -  1.9000   [1828/1828]   28.32   28.32   51775      3177     8.017&lt;br /&gt;
&lt;br /&gt;
All                   [18299/18304]  691.40  691.59 12655352    14670    85.218&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
################################################################################&lt;br /&gt;
OUTPUT FILES&lt;br /&gt;
  (will use final unit cell edges 78.0333 78.0333 38.833)&lt;br /&gt;
  Anomalous and mean data:&lt;br /&gt;
    /reg/data/ana04/cxi/cxi84914/scratch/tmmclark/merge/GdLysozymeanom_4etc_s0_mark0.mtz&lt;br /&gt;
&lt;br /&gt;
Final data:&lt;br /&gt;
  Miller array info: None&lt;br /&gt;
  Observation type: xray.intensity&lt;br /&gt;
  Type of data: double, size=18057&lt;br /&gt;
  Type of sigmas: double, size=18057&lt;br /&gt;
  Number of Miller indices: 18057&lt;br /&gt;
  Anomalous flag: True&lt;br /&gt;
  Unit cell: (78.0333, 78.0333, 38.833, 90, 90, 90)&lt;br /&gt;
  Space group: P 43 21 2 (No. 96)&lt;br /&gt;
&lt;br /&gt;
------------------------------&lt;br /&gt;
Bin  Resolution Range # images&lt;br /&gt;
------------------------------&lt;br /&gt;
  1 -1.0000 -  4.0934    95023&lt;br /&gt;
  2  4.0934 -  3.2490    92995&lt;br /&gt;
  3  3.2490 -  2.8382    88713&lt;br /&gt;
  4  2.8382 -  2.5787    79466&lt;br /&gt;
  5  2.5787 -  2.3938    69426&lt;br /&gt;
  6  2.3938 -  2.2527    57933&lt;br /&gt;
  7  2.2527 -  2.1399    47604&lt;br /&gt;
  8  2.1399 -  2.0467    38206&lt;br /&gt;
  9  2.0467 -  1.9679    28624&lt;br /&gt;
 10  1.9679 -  1.9000    17771&lt;br /&gt;
&lt;br /&gt;
All                      95042&lt;br /&gt;
------------------------------&lt;br /&gt;
-------------------------------&lt;br /&gt;
iobs,sigiobs xray.intensity&lt;br /&gt;
-------------------------------&lt;br /&gt;
iobs(+),sigiobs(+),iobs(-),sigiobs(-) xray.intensity&lt;br /&gt;
-------------------------------&lt;br /&gt;
iobs(+),sigiobs(+),iobs(-),sigiobs(-) xray.intensity&lt;br /&gt;
-------------------------------&lt;br /&gt;
iobs(+),sigiobs(+),iobs(-),sigiobs(-) xray.intensity&lt;br /&gt;
16916&lt;br /&gt;
18062&lt;br /&gt;
18057&lt;br /&gt;
18062&lt;br /&gt;
18057&lt;br /&gt;
18062&lt;br /&gt;
18057&lt;br /&gt;
18062&lt;br /&gt;
-------------------------------&lt;br /&gt;
C.C. iso is 78.6% on 16189 indices&lt;br /&gt;
C.C. int is 96.2% on 18057 indices&lt;br /&gt;
&lt;br /&gt;
Table of Scaling Results:&lt;br /&gt;
&lt;br /&gt;
---------------------------------------------------------------------------------------&lt;br /&gt;
                                      CC            CC            R     R   Scale Scale&lt;br /&gt;
Bin  Resolution Range  Completeness  int     N     iso     N     int   iso   int   iso&lt;br /&gt;
---------------------------------------------------------------------------------------&lt;br /&gt;
  1 -1.0000 -  4.0934   [1809/1814] 97.3%    1809 75.4%    1588 13.7% 45.9% 0.990 0.189&lt;br /&gt;
  2  4.0934 -  3.2490   [1789/1789] 92.1%    1789 71.3%    1611 17.4% 49.4% 0.931 0.156&lt;br /&gt;
  3  3.2490 -  2.8382   [1824/1824] 90.9%    1824 54.0%    1655 17.5% 57.6% 0.956 0.193&lt;br /&gt;
  4  2.8382 -  2.5787   [1802/1802] 88.9%    1802 42.2%    1650 18.5% 59.6% 0.972 0.221&lt;br /&gt;
  5  2.5787 -  2.3938   [1807/1807] 87.3%    1807 39.1%    1664 21.2% 60.2% 0.938 0.232&lt;br /&gt;
  6  2.3938 -  2.2527   [1804/1804] 79.5%    1804 36.6%    1659 25.7% 62.5% 0.940 0.194&lt;br /&gt;
  7  2.2527 -  2.1399   [1819/1819] 72.0%    1819 38.9%    1661 29.4% 64.7% 0.871 0.192&lt;br /&gt;
  8  2.1399 -  2.0467   [1792/1792] 64.9%    1792 24.2%    1641 38.2% 67.1% 0.723 0.214&lt;br /&gt;
  9  2.0467 -  1.9679   [1811/1811] 50.6%    1811 27.6%    1641 39.9% 66.6% 0.848 0.210&lt;br /&gt;
 10  1.9679 -  1.9000   [1800/1800] 49.1%    1800 21.3%    1419 53.3% 69.1% 0.768 0.208&lt;br /&gt;
&lt;br /&gt;
All                                 96.2%   18057 78.6%   16189 19.9% 55.4% 0.963 0.180&lt;br /&gt;
---------------------------------------------------------------------------------------&lt;br /&gt;
CCint is the CC-1/2 defined by Diedrichs; correlation between odd/even images.&lt;br /&gt;
  Similarly, Scale int and R int are the scaling factor and scaling R factor between odd/even images.&lt;br /&gt;
  &amp;quot;iso&amp;quot; columns compare the whole XFEL dataset to the isomorphous reference.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=GdLysozymenoamo_4etc.log&amp;diff=877</id>
		<title>GdLysozymenoamo 4etc.log</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=GdLysozymenoamo_4etc.log&amp;diff=877"/>
		<updated>2014-10-06T17:50:39Z</updated>

		<summary type="html">&lt;p&gt;Tara: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Statistics for all reflections&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
                                      &amp;lt;asu    &amp;lt;obs&lt;br /&gt;
Bin  Resolution Range  Completeness  redun&amp;gt;  redun&amp;gt;  n_meas    &amp;lt;I&amp;gt;    &amp;lt;I/sig(I)&amp;gt;&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
  1 -1.0000 -  4.0934   [1098/1103] 3819.15 3836.54 4212517     39386   322.007&lt;br /&gt;
  2  4.0934 -  3.2490   [1027/1027] 3455.17 3455.17 3548462     32098   248.654&lt;br /&gt;
  3  3.2490 -  2.8382   [1005/1005] 2790.48 2790.48 2804431     21080   167.468&lt;br /&gt;
  4  2.8382 -  2.5787   [1004/1004] 2116.09 2116.09 2124556     15102   121.452&lt;br /&gt;
  5  2.5787 -  2.3938     [992/992] 1486.94 1486.94 1475042     10649    86.519&lt;br /&gt;
  6  2.3938 -  2.2527     [986/986]  910.70  910.70  897951      8042    59.687&lt;br /&gt;
  7  2.2527 -  2.1399     [987/987]  647.88  647.88  639455      6462    45.941&lt;br /&gt;
  8  2.1399 -  2.0467     [978/978]  463.86  463.86  453659      5459    37.341&lt;br /&gt;
  9  2.0467 -  1.9679     [981/981]  235.10  235.10  230635      3904    21.732&lt;br /&gt;
 10  1.9679 -  1.9000     [974/974]   75.81   75.81   73838      3101    10.993&lt;br /&gt;
&lt;br /&gt;
All                   [10032/10037] 1639.99 1640.80 16460546    14914   115.405&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
SUMMARY: For 11015 reflections, got slope 1.128181, correlation 0.721862&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Statistics for reflections where I &amp;gt; 0&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
                                      &amp;lt;asu    &amp;lt;obs&lt;br /&gt;
Bin  Resolution Range  Completeness  redun&amp;gt;  redun&amp;gt;  n_meas    &amp;lt;I&amp;gt;    &amp;lt;I/sig(I)&amp;gt;&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
  1 -1.0000 -  4.0934   [1098/1103] 3255.71 3270.54 3591049     39386   322.007&lt;br /&gt;
  2  4.0934 -  3.2490   [1027/1027] 2731.06 2731.06 2804794     32098   248.654&lt;br /&gt;
  3  3.2490 -  2.8382   [1005/1005] 2071.94 2071.94 2082298     21080   167.468&lt;br /&gt;
  4  2.8382 -  2.5787   [1004/1004] 1522.34 1522.34 1528427     15102   121.452&lt;br /&gt;
  5  2.5787 -  2.3938     [992/992] 1057.23 1057.23 1048772     10649    86.519&lt;br /&gt;
  6  2.3938 -  2.2527     [986/986]  641.70  641.70  632721      8042    59.687&lt;br /&gt;
  7  2.2527 -  2.1399     [987/987]  451.43  451.43  445557      6462    45.941&lt;br /&gt;
  8  2.1399 -  2.0467     [978/978]  318.79  318.79  311776      5459    37.341&lt;br /&gt;
  9  2.0467 -  1.9679     [981/981]  161.25  161.25  158183      3904    21.732&lt;br /&gt;
 10  1.9679 -  1.9000     [974/974]   53.16   53.16   51775      3101    10.993&lt;br /&gt;
&lt;br /&gt;
All                   [10032/10037] 1260.87 1261.50 12655352    14914   115.405&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
################################################################################&lt;br /&gt;
OUTPUT FILES&lt;br /&gt;
  (will use final unit cell edges 78.0333 78.0333 38.833)&lt;br /&gt;
  Anomalous and mean data:&lt;br /&gt;
    /reg/data/ana04/cxi/cxi84914/scratch/tmmclark/merge/GdLysozymenoanom_4etc_s0_mark0.mtz&lt;br /&gt;
&lt;br /&gt;
Final data:&lt;br /&gt;
  Miller array info: None&lt;br /&gt;
  Observation type: xray.intensity&lt;br /&gt;
  Type of data: double, size=9902&lt;br /&gt;
  Type of sigmas: double, size=9902&lt;br /&gt;
  Number of Miller indices: 9902&lt;br /&gt;
  Anomalous flag: False&lt;br /&gt;
  Unit cell: (78.0333, 78.0333, 38.833, 90, 90, 90)&lt;br /&gt;
  Space group: P 43 21 2 (No. 96)&lt;br /&gt;
&lt;br /&gt;
------------------------------&lt;br /&gt;
Bin  Resolution Range # images&lt;br /&gt;
------------------------------&lt;br /&gt;
  1 -1.0000 -  4.0934    95023&lt;br /&gt;
  2  4.0934 -  3.2490    92995&lt;br /&gt;
  3  3.2490 -  2.8382    88713&lt;br /&gt;
  4  2.8382 -  2.5787    79466&lt;br /&gt;
  5  2.5787 -  2.3938    69426&lt;br /&gt;
  6  2.3938 -  2.2527    57933&lt;br /&gt;
  7  2.2527 -  2.1399    47604&lt;br /&gt;
  8  2.1399 -  2.0467    38206&lt;br /&gt;
  9  2.0467 -  1.9679    28624&lt;br /&gt;
 10  1.9679 -  1.9000    17771&lt;br /&gt;
&lt;br /&gt;
All                      95042&lt;br /&gt;
------------------------------&lt;br /&gt;
-------------------------------&lt;br /&gt;
iobs,sigiobs xray.intensity&lt;br /&gt;
-------------------------------&lt;br /&gt;
iobs,sigiobs xray.intensity&lt;br /&gt;
-------------------------------&lt;br /&gt;
iobs,sigiobs xray.intensity&lt;br /&gt;
-------------------------------&lt;br /&gt;
iobs,sigiobs xray.intensity&lt;br /&gt;
9193&lt;br /&gt;
9907&lt;br /&gt;
9902&lt;br /&gt;
9907&lt;br /&gt;
9902&lt;br /&gt;
9907&lt;br /&gt;
9902&lt;br /&gt;
9907&lt;br /&gt;
-------------------------------&lt;br /&gt;
C.C. iso is 78.2% on 8766 indices&lt;br /&gt;
C.C. int is 97.3% on 9902 indices&lt;br /&gt;
&lt;br /&gt;
Table of Scaling Results:&lt;br /&gt;
&lt;br /&gt;
---------------------------------------------------------------------------------------&lt;br /&gt;
                                      CC            CC            R     R   Scale Scale&lt;br /&gt;
Bin  Resolution Range  Completeness  int     N     iso     N     int   iso   int   iso&lt;br /&gt;
---------------------------------------------------------------------------------------&lt;br /&gt;
  1 -1.0000 -  4.0934   [1087/1092] 98.0%    1087 74.4%     935 11.8% 47.1% 0.995 0.189&lt;br /&gt;
  2  4.0934 -  3.2490   [1001/1001] 94.6%    1001 72.6%     889 14.6% 49.7% 0.942 0.156&lt;br /&gt;
  3  3.2490 -  2.8382   [1009/1009] 93.2%    1009 54.1%     905 14.9% 58.2% 0.967 0.193&lt;br /&gt;
  4  2.8382 -  2.5787   [ 983/983 ] 92.5%     983 41.4%     890 15.1% 60.2% 0.984 0.221&lt;br /&gt;
  5  2.5787 -  2.3938   [ 983/983 ] 91.5%     983 41.0%     894 17.1% 60.4% 0.951 0.232&lt;br /&gt;
  6  2.3938 -  2.2527   [ 973/973 ] 85.1%     973 37.4%     884 21.1% 62.4% 0.958 0.194&lt;br /&gt;
  7  2.2527 -  2.1399   [ 979/979 ] 77.1%     979 39.3%     883 25.2% 64.9% 0.896 0.192&lt;br /&gt;
  8  2.1399 -  2.0467   [ 957/957 ] 68.3%     957 25.2%     871 34.5% 67.4% 0.754 0.214&lt;br /&gt;
  9  2.0467 -  1.9679   [ 970/970 ] 56.2%     970 27.5%     868 33.6% 67.0% 0.939 0.210&lt;br /&gt;
 10  1.9679 -  1.9000   [ 960/960 ] 59.5%     960 23.0%     747 45.8% 69.0% 0.832 0.208&lt;br /&gt;
&lt;br /&gt;
All                                 97.3%    9902 78.2%    8766 16.6% 55.6% 0.972 0.180&lt;br /&gt;
---------------------------------------------------------------------------------------&lt;br /&gt;
CCint is the CC-1/2 defined by Diedrichs; correlation between odd/even images.&lt;br /&gt;
  Similarly, Scale int and R int are the scaling factor and scaling R factor between odd/even images.&lt;br /&gt;
  &amp;quot;iso&amp;quot; columns compare the whole XFEL dataset to the isomorphous reference.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=876</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=876"/>
		<updated>2014-10-06T16:39:09Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Solve the structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
&lt;br /&gt;
On pslogin, download the reference structure 4etc from the pdb (must be done on pslogin, the only outward-facing host).  4etc.pdb will be used for per-image scaling; 4etc.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme0.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 ./mergeLysozyme0.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymenoamo_4etc.log | Log file with model scaling and no anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymeanom_4etc.log | Log file with model scaling and anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Trying to merge not scaling to a model:&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymeanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymenoanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
 phenix.xtriage GdLysozymenoanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
 phenix.xtriage GdLysozymeanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_anom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.58 no anomalous&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.12 anomalous&lt;br /&gt;
&lt;br /&gt;
Use Gd-Lysozyme anomalous structure to get Gd sites:&lt;br /&gt;
 phenix.fetch_pdb --mtz 4n5r&lt;br /&gt;
 phenix.automr 4n5r.pdb GdLysozymeanom_4etc_s0_mark0.mtz seq_file=4n5r.fa identity=100 copies=1 build=False&lt;br /&gt;
&lt;br /&gt;
The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags using those generated in the refinement from 4n5r.pdb&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine 4n5r.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=GdLysozymeanom_4etc_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4etc_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=FreeR_flag \&lt;br /&gt;
  main.number_of_macro_cycles=6 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
RWORK = 21.2% RFREE = 25.7% out to 1.9 Angstrom&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=875</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=875"/>
		<updated>2014-10-06T00:08:49Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Solve the structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
&lt;br /&gt;
On pslogin, download the reference structure 4etc from the pdb (must be done on pslogin, the only outward-facing host).  4etc.pdb will be used for per-image scaling; 4etc.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme0.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 ./mergeLysozyme0.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymenoamo_4etc.log | Log file with model scaling and no anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymeanom_4etc.log | Log file with model scaling and anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Trying to merge not scaling to a model:&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymeanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymenoanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
 phenix.xtriage GdLysozymenoanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
 phenix.xtriage GdLysozymeanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_anom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.58 no anomalous&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.12 anomalous&lt;br /&gt;
&lt;br /&gt;
Use Gd-Lysozyme anomalous structure to get Gd sites:&lt;br /&gt;
 phenix.fetch_pdb --mtz 4n5r&lt;br /&gt;
 phenix.automr 4n5r.pdb GdLysozymeanom_4etc_s0_mark0.mtz seq_file=4n5r.fa identity=100 copies=1 build=False&lt;br /&gt;
&lt;br /&gt;
The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags using those generated in the refinement from 4n5r.pdb&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine ./AutoMR_run_1_/MR.1.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=GdLysozymeanom_4etc_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4etc_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags \&lt;br /&gt;
  main.number_of_macro_cycles=6 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
RWORK = 21.2% RFREE = 25.7% out to 1.9 Angstrom&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=874</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=874"/>
		<updated>2014-10-05T22:57:09Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Solve the structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
&lt;br /&gt;
On pslogin, download the reference structure 4etc from the pdb (must be done on pslogin, the only outward-facing host).  4etc.pdb will be used for per-image scaling; 4etc.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme0.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 ./mergeLysozyme0.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymenoamo_4etc.log | Log file with model scaling and no anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymeanom_4etc.log | Log file with model scaling and anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Trying to merge not scaling to a model:&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymeanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymenoanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
 phenix.xtriage GdLysozymenoanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
 phenix.xtriage GdLysozymeanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_anom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.58 no anomalous&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.12 anomalous&lt;br /&gt;
&lt;br /&gt;
Use Gd-Lysozyme anomalous structure to get Gd sites:&lt;br /&gt;
 phenix.fetch_pdb --mtz 4n5r&lt;br /&gt;
 phenix.automr 4n5r.pdb GdLysozymenoanom_4etc_s0_mark0.mtz seq_file=4n5r.fa identity=100 copies=1 build=False&lt;br /&gt;
&lt;br /&gt;
The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags using those generated in the refinement from 4n5r.pdb&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine ./AutoMR_run_1_/MR.1.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=GdLysozymeanom_4etc_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4etc_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags \&lt;br /&gt;
  main.number_of_macro_cycles=6 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
RWORK = 21.2% RFREE = 25.7% out to 1.9 Angstrom&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=873</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=873"/>
		<updated>2014-10-05T22:16:47Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Solve the structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
&lt;br /&gt;
On pslogin, download the reference structure 4etc from the pdb (must be done on pslogin, the only outward-facing host).  4etc.pdb will be used for per-image scaling; 4etc.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme0.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 ./mergeLysozyme0.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymenoamo_4etc.log | Log file with model scaling and no anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymeanom_4etc.log | Log file with model scaling and anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Trying to merge not scaling to a model:&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymeanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymenoanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
 phenix.xtriage GdLysozymenoanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
 phenix.xtriage GdLysozymeanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_anom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.58 no anomalous&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.12 anomalous&lt;br /&gt;
&lt;br /&gt;
Use Gd-Lysozyme anomalous structure to get Gd sites:&lt;br /&gt;
 phenix.fetch_pdb --mtz 4n5r&lt;br /&gt;
 phenix.automr 4n5r.pdb GdLysozymenoanom_4etc_s0_mark0.mtz seq_file=4n5r.fa identity=100 copies=1 build=False&lt;br /&gt;
&lt;br /&gt;
The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags &lt;br /&gt;
 wget http://cci.lbl.gov/publications/download/4ow3_original_iobs_flags.mtz&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine ./AutoMR_run_1_/MR.1.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=thermonoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags \&lt;br /&gt;
  main.number_of_macro_cycles=6 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
RWORK = 23.1% RFREE = 26.5% out to 2.1 Angstrom&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=872</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=872"/>
		<updated>2014-10-05T22:01:35Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Solve the structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
&lt;br /&gt;
On pslogin, download the reference structure 4etc from the pdb (must be done on pslogin, the only outward-facing host).  4etc.pdb will be used for per-image scaling; 4etc.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme0.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 ./mergeLysozyme0.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymenoamo_4etc.log | Log file with model scaling and no anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymeanom_4etc.log | Log file with model scaling and anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Trying to merge not scaling to a model:&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymeanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymenoanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
 phenix.xtriage GdLysozymenoanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
 phenix.xtriage GdLysozymeanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_anom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.58 no anomalous&lt;br /&gt;
Wilson B factor: 15.12 anomalous&lt;br /&gt;
&lt;br /&gt;
Use Gd-Lysozyme anomalous structure to get Gd sites:&lt;br /&gt;
 phenix.fetch_pdb --mtz 4n5r&lt;br /&gt;
 phenix.automr 4n5r.pdb GdLysozymenoanom_4etc_s0_mark0.mtz seq_file=4n5r.fa identity=100 copies=1 build=False&lt;br /&gt;
&lt;br /&gt;
The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags used in the Barends 2013 Nature paper:&lt;br /&gt;
 wget http://cci.lbl.gov/publications/download/4ow3_original_iobs_flags.mtz&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine ./AutoMR_run_1_/MR.1.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=thermonoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags \&lt;br /&gt;
  main.number_of_macro_cycles=6 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
trial 003: RWORK = 23.1% RFREE = 26.5% out to 2.1 Angstrom&lt;br /&gt;
&lt;br /&gt;
trial 005: RWORK = 22.0% RFREE = 26.3% out to 2.1 Angstrom (taking untrusted pixels into account)&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=871</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=871"/>
		<updated>2014-10-05T21:27:39Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Solve the structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
&lt;br /&gt;
On pslogin, download the reference structure 4etc from the pdb (must be done on pslogin, the only outward-facing host).  4etc.pdb will be used for per-image scaling; 4etc.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme0.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 ./mergeLysozyme0.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymenoamo_4etc.log | Log file with model scaling and no anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymeanom_4etc.log | Log file with model scaling and anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Trying to merge not scaling to a model:&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymeanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymenoanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
 phenix.xtriage GdLysozymenoanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.58&lt;br /&gt;
&lt;br /&gt;
Use Gd-Lysozyme anomalous structure to get Gd sites:&lt;br /&gt;
 phenix.fetch_pdb --mtz 4n5r&lt;br /&gt;
 phenix.automr 4n5r.pdb GdLysozymenoanom_4etc_s0_mark0.mtz seq_file=4n5r.fa identity=100 copies=1 build=False&lt;br /&gt;
&lt;br /&gt;
The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags used in the Barends 2013 Nature paper:&lt;br /&gt;
 wget http://cci.lbl.gov/publications/download/4ow3_original_iobs_flags.mtz&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine ./AutoMR_run_1_/MR.1.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=thermonoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags \&lt;br /&gt;
  main.number_of_macro_cycles=6 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
trial 003: RWORK = 23.1% RFREE = 26.5% out to 2.1 Angstrom&lt;br /&gt;
&lt;br /&gt;
trial 005: RWORK = 22.0% RFREE = 26.3% out to 2.1 Angstrom (taking untrusted pixels into account)&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=870</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=870"/>
		<updated>2014-10-05T21:26:11Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Solve the structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
&lt;br /&gt;
On pslogin, download the reference structure 4etc from the pdb (must be done on pslogin, the only outward-facing host).  4etc.pdb will be used for per-image scaling; 4etc.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme0.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 ./mergeLysozyme0.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymenoamo_4etc.log | Log file with model scaling and no anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymeanom_4etc.log | Log file with model scaling and anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Trying to merge not scaling to a model:&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymeanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymenoanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
 phenix.xtriage GdLysozymenoanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.58&lt;br /&gt;
&lt;br /&gt;
Use Gd-Lysozyme anomalous structure to get Gd sites:&lt;br /&gt;
 phenix.fetch_pdb --mtz 4n5r&lt;br /&gt;
 phenix.automr 4n5r.pdb GdLysozymenoanom_4etc_s0_mark0.mtz seq_file=4n5r.fa identity=100 copies=1 build=False&lt;br /&gt;
&lt;br /&gt;
The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags used in nature paper&lt;br /&gt;
 wget http://cci.lbl.gov/publications/download/4ow3_original_iobs_flags.mtz&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine ./AutoMR_run_1_/MR.1.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=thermonoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags \&lt;br /&gt;
  main.number_of_macro_cycles=6 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
trial 003: RWORK = 23.1% RFREE = 26.5% out to 2.1 Angstrom&lt;br /&gt;
&lt;br /&gt;
trial 005: RWORK = 22.0% RFREE = 26.3% out to 2.1 Angstrom (taking untrusted pixels into account)&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=869</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=869"/>
		<updated>2014-10-05T21:16:53Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Solve the structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
&lt;br /&gt;
On pslogin, download the reference structure 4etc from the pdb (must be done on pslogin, the only outward-facing host).  4etc.pdb will be used for per-image scaling; 4etc.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme0.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 ./mergeLysozyme0.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymenoamo_4etc.log | Log file with model scaling and no anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymeanom_4etc.log | Log file with model scaling and anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Trying to merge not scaling to a model:&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymeanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymenoanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
 phenix.xtriage GdLysozymenoanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.58&lt;br /&gt;
&lt;br /&gt;
Use Gd-Lysozyme anomalous structure to get Gd sites:&lt;br /&gt;
 phenix.fetch_pdb --mtz 4n5r&lt;br /&gt;
 phenix.automr 4n5r.pdb GdLysozymenoanom_4etc_s0_mark0.mtz seq_file=4n5r.fa identity=100 copies=1 build=False&lt;br /&gt;
&lt;br /&gt;
The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags used in the Nature Methods paper&lt;br /&gt;
 wget http://cci.lbl.gov/publications/download/4ow3_original_iobs_flags.mtz&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine ./AutoMR_run_1_/MR.1.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=thermonoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags \&lt;br /&gt;
  main.number_of_macro_cycles=6 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
trial 003: RWORK = 23.1% RFREE = 26.5% out to 2.1 Angstrom&lt;br /&gt;
&lt;br /&gt;
trial 005: RWORK = 22.0% RFREE = 26.3% out to 2.1 Angstrom (taking untrusted pixels into account)&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=868</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=868"/>
		<updated>2014-10-05T21:12:20Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Solve the structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
&lt;br /&gt;
On pslogin, download the reference structure 4etc from the pdb (must be done on pslogin, the only outward-facing host).  4etc.pdb will be used for per-image scaling; 4etc.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme0.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 ./mergeLysozyme0.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymenoamo_4etc.log | Log file with model scaling and no anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymeanom_4etc.log | Log file with model scaling and anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Trying to merge not scaling to a model:&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymeanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymenoanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
 phenix.xtriage GdLysozymenoanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor: 15.58&lt;br /&gt;
&lt;br /&gt;
Use Gd-Lysozyme anomalous structure to get Gd sites:&lt;br /&gt;
 phenix.fetch_pdb --mtz 4n5r&lt;br /&gt;
 phenix.automr 4n5r.pdb thermonoanom_4etc_s0_mark0.mtz seq_file=4n5ri.fa identity=100 copies=1 build=False&lt;br /&gt;
&lt;br /&gt;
The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags used in the Nature Methods paper&lt;br /&gt;
 wget http://cci.lbl.gov/publications/download/4ow3_original_iobs_flags.mtz&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine ./AutoMR_run_1_/MR.1.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=thermonoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags \&lt;br /&gt;
  main.number_of_macro_cycles=6 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
trial 003: RWORK = 23.1% RFREE = 26.5% out to 2.1 Angstrom&lt;br /&gt;
&lt;br /&gt;
trial 005: RWORK = 22.0% RFREE = 26.3% out to 2.1 Angstrom (taking untrusted pixels into account)&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=867</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=867"/>
		<updated>2014-10-05T21:10:07Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Solve the structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
&lt;br /&gt;
On pslogin, download the reference structure 4etc from the pdb (must be done on pslogin, the only outward-facing host).  4etc.pdb will be used for per-image scaling; 4etc.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme0.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 ./mergeLysozyme0.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymenoamo_4etc.log | Log file with model scaling and no anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymeanom_4etc.log | Log file with model scaling and anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Trying to merge not scaling to a model:&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymeanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymenoanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
 phenix.xtriage GdLysozymenoanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor:14.8&lt;br /&gt;
&lt;br /&gt;
Use Gd-Lysozyme anomalous structure to get Gd sites:&lt;br /&gt;
 phenix.fetch_pdb --mtz 4n5r&lt;br /&gt;
 phenix.automr 4n5r.pdb thermonoanom_4etc_s0_mark0.mtz seq_file=4n5ri.fa identity=100 copies=1 build=False&lt;br /&gt;
&lt;br /&gt;
The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags used in the Nature Methods paper&lt;br /&gt;
 wget http://cci.lbl.gov/publications/download/4ow3_original_iobs_flags.mtz&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine ./AutoMR_run_1_/MR.1.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=thermonoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags \&lt;br /&gt;
  main.number_of_macro_cycles=6 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
trial 003: RWORK = 23.1% RFREE = 26.5% out to 2.1 Angstrom&lt;br /&gt;
&lt;br /&gt;
trial 005: RWORK = 22.0% RFREE = 26.3% out to 2.1 Angstrom (taking untrusted pixels into account)&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=866</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=866"/>
		<updated>2014-10-05T20:59:37Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Solve the structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
&lt;br /&gt;
On pslogin, download the reference structure 4etc from the pdb (must be done on pslogin, the only outward-facing host).  4etc.pdb will be used for per-image scaling; 4etc.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme0.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 ./mergeLysozyme0.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymenoamo_4etc.log | Log file with model scaling and no anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymeanom_4etc.log | Log file with model scaling and anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Trying to merge not scaling to a model:&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymeanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/GdLysozymenoanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
 phenix.xtriage Lysozymenoanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor:14.8&lt;br /&gt;
&lt;br /&gt;
Use Gd-Lysozyme anomalous structure to get Gd sites:&lt;br /&gt;
 phenix.fetch_pdb --mtz 4n5r&lt;br /&gt;
 phenix.automr 4n5r.pdb thermonoanom_4etc_s0_mark0.mtz seq_file=4n5ri.fa identity=100 copies=1 build=False&lt;br /&gt;
&lt;br /&gt;
The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags used in the Nature Methods paper&lt;br /&gt;
 wget http://cci.lbl.gov/publications/download/4ow3_original_iobs_flags.mtz&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine ./AutoMR_run_1_/MR.1.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=thermonoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags \&lt;br /&gt;
  main.number_of_macro_cycles=6 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
trial 003: RWORK = 23.1% RFREE = 26.5% out to 2.1 Angstrom&lt;br /&gt;
&lt;br /&gt;
trial 005: RWORK = 22.0% RFREE = 26.3% out to 2.1 Angstrom (taking untrusted pixels into account)&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=GdLysozymenoamo_4etc.log&amp;diff=865</id>
		<title>GdLysozymenoamo 4etc.log</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=GdLysozymenoamo_4etc.log&amp;diff=865"/>
		<updated>2014-10-05T20:46:52Z</updated>

		<summary type="html">&lt;p&gt;Tara: Created page with &amp;quot;&amp;lt;pre&amp;gt; Statistics for all reflections -------------------------------------------------------------------------------------                                       &amp;lt;asu    &amp;lt;obs B...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Statistics for all reflections&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
                                      &amp;lt;asu    &amp;lt;obs&lt;br /&gt;
Bin  Resolution Range  Completeness  redun&amp;gt;  redun&amp;gt;  n_meas    &amp;lt;I&amp;gt;    &amp;lt;I/sig(I)&amp;gt;&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
  1 -1.0000 -  4.0934   [1098/1103] 3819.15 3836.54 4212517     39386   322.007&lt;br /&gt;
  2  4.0934 -  3.2490   [1027/1027] 3455.17 3455.17 3548462     32098   248.654&lt;br /&gt;
  3  3.2490 -  2.8382   [1005/1005] 2790.48 2790.48 2804431     21080   167.468&lt;br /&gt;
  4  2.8382 -  2.5787   [1004/1004] 2116.09 2116.09 2124556     15102   121.452&lt;br /&gt;
  5  2.5787 -  2.3938     [992/992] 1486.94 1486.94 1475042     10649    86.519&lt;br /&gt;
  6  2.3938 -  2.2527     [986/986]  910.70  910.70  897951      8042    59.687&lt;br /&gt;
  7  2.2527 -  2.1399     [987/987]  647.88  647.88  639455      6462    45.941&lt;br /&gt;
  8  2.1399 -  2.0467     [978/978]  463.86  463.86  453659      5459    37.341&lt;br /&gt;
  9  2.0467 -  1.9679     [981/981]  235.10  235.10  230635      3904    21.732&lt;br /&gt;
 10  1.9679 -  1.9000     [974/974]   75.81   75.81   73838      3101    10.993&lt;br /&gt;
&lt;br /&gt;
All                   [10032/10037] 1639.99 1640.80 16460546    14914   115.405&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
SUMMARY: For 11015 reflections, got slope 1.128181, correlation 0.721862&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Statistics for reflections where I &amp;gt; 0&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
                                      &amp;lt;asu    &amp;lt;obs&lt;br /&gt;
Bin  Resolution Range  Completeness  redun&amp;gt;  redun&amp;gt;  n_meas    &amp;lt;I&amp;gt;    &amp;lt;I/sig(I)&amp;gt;&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
  1 -1.0000 -  4.0934   [1098/1103] 3255.71 3270.54 3591049     39386   322.007&lt;br /&gt;
  2  4.0934 -  3.2490   [1027/1027] 2731.06 2731.06 2804794     32098   248.654&lt;br /&gt;
  3  3.2490 -  2.8382   [1005/1005] 2071.94 2071.94 2082298     21080   167.468&lt;br /&gt;
  4  2.8382 -  2.5787   [1004/1004] 1522.34 1522.34 1528427     15102   121.452&lt;br /&gt;
  5  2.5787 -  2.3938     [992/992] 1057.23 1057.23 1048772     10649    86.519&lt;br /&gt;
  6  2.3938 -  2.2527     [986/986]  641.70  641.70  632721      8042    59.687&lt;br /&gt;
  7  2.2527 -  2.1399     [987/987]  451.43  451.43  445557      6462    45.941&lt;br /&gt;
  8  2.1399 -  2.0467     [978/978]  318.79  318.79  311776      5459    37.341&lt;br /&gt;
  9  2.0467 -  1.9679     [981/981]  161.25  161.25  158183      3904    21.732&lt;br /&gt;
 10  1.9679 -  1.9000     [974/974]   53.16   53.16   51775      3101    10.993&lt;br /&gt;
&lt;br /&gt;
All                   [10032/10037] 1260.87 1261.50 12655352    14914   115.405&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
################################################################################&lt;br /&gt;
OUTPUT FILES&lt;br /&gt;
  (will use final unit cell edges 78.0333 78.0333 38.833)&lt;br /&gt;
  Anomalous and mean data:&lt;br /&gt;
    /reg/data/ana04/cxi/cxi84914/scratch/tmmclark/merge/GdLysozymenoanom_4etc.mtz&lt;br /&gt;
&lt;br /&gt;
Final data:&lt;br /&gt;
  Miller array info: None&lt;br /&gt;
  Observation type: xray.intensity&lt;br /&gt;
  Type of data: double, size=9902&lt;br /&gt;
  Type of sigmas: double, size=9902&lt;br /&gt;
  Number of Miller indices: 9902&lt;br /&gt;
  Anomalous flag: False&lt;br /&gt;
  Unit cell: (78.0333, 78.0333, 38.833, 90, 90, 90)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=GdLysozymeanom_4etc.log&amp;diff=864</id>
		<title>GdLysozymeanom 4etc.log</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=GdLysozymeanom_4etc.log&amp;diff=864"/>
		<updated>2014-10-05T20:45:58Z</updated>

		<summary type="html">&lt;p&gt;Tara: Created page with &amp;quot;&amp;lt;pre&amp;gt;  Statistics for all reflections -------------------------------------------------------------------------------------                                       &amp;lt;asu    &amp;lt;obs...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Statistics for all reflections&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
                                      &amp;lt;asu    &amp;lt;obs&lt;br /&gt;
Bin  Resolution Range  Completeness  redun&amp;gt;  redun&amp;gt;  n_meas    &amp;lt;I&amp;gt;    &amp;lt;I/sig(I)&amp;gt;&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
  1 -1.0000 -  4.0934   [1828/1833] 2298.15 2304.44 4212517     39447   252.595&lt;br /&gt;
  2  4.0934 -  3.2490   [1830/1830] 1939.05 1939.05 3548462     32453   189.212&lt;br /&gt;
  3  3.2490 -  2.8382   [1824/1824] 1537.52 1537.52 2804431     21477   126.067&lt;br /&gt;
  4  2.8382 -  2.5787   [1840/1840] 1154.65 1154.65 2124556     15258    90.629&lt;br /&gt;
  5  2.5787 -  2.3938   [1828/1828]  806.92  806.92 1475042     10813    64.383&lt;br /&gt;
  6  2.3938 -  2.2527   [1829/1829]  490.95  490.95  897951      8109    44.146&lt;br /&gt;
  7  2.2527 -  2.1399   [1834/1834]  348.67  348.67  639455      6556    33.991&lt;br /&gt;
  8  2.1399 -  2.0467   [1825/1825]  248.58  248.58  453659      5487    27.376&lt;br /&gt;
  9  2.0467 -  1.9679   [1833/1833]  125.82  125.82  230635      3959    15.990&lt;br /&gt;
 10  1.9679 -  1.9000   [1828/1828]   40.39   40.39   73838      3177     8.017&lt;br /&gt;
&lt;br /&gt;
All                   [18299/18304]  899.29  899.53 16460546    14670    85.218&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
SUMMARY: For 20145 reflections, got slope 1.158594, correlation 0.736066&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Statistics for reflections where I &amp;gt; 0&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
                                      &amp;lt;asu    &amp;lt;obs&lt;br /&gt;
Bin  Resolution Range  Completeness  redun&amp;gt;  redun&amp;gt;  n_meas    &amp;lt;I&amp;gt;    &amp;lt;I/sig(I)&amp;gt;&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
  1 -1.0000 -  4.0934   [1828/1833] 1959.11 1964.47 3591049     39447   252.595&lt;br /&gt;
  2  4.0934 -  3.2490   [1830/1830] 1532.67 1532.67 2804794     32453   189.212&lt;br /&gt;
  3  3.2490 -  2.8382   [1824/1824] 1141.61 1141.61 2082298     21477   126.067&lt;br /&gt;
  4  2.8382 -  2.5787   [1840/1840]  830.67  830.67 1528427     15258    90.629&lt;br /&gt;
  5  2.5787 -  2.3938   [1828/1828]  573.73  573.73 1048772     10813    64.383&lt;br /&gt;
  6  2.3938 -  2.2527   [1829/1829]  345.94  345.94  632721      8109    44.146&lt;br /&gt;
  7  2.2527 -  2.1399   [1834/1834]  242.94  242.94  445557      6556    33.991&lt;br /&gt;
  8  2.1399 -  2.0467   [1825/1825]  170.84  170.84  311776      5487    27.376&lt;br /&gt;
  9  2.0467 -  1.9679   [1833/1833]   86.30   86.30  158183      3959    15.990&lt;br /&gt;
 10  1.9679 -  1.9000   [1828/1828]   28.32   28.32   51775      3177     8.017&lt;br /&gt;
&lt;br /&gt;
All                   [18299/18304]  691.40  691.59 12655352    14670    85.218&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
################################################################################&lt;br /&gt;
OUTPUT FILES&lt;br /&gt;
  (will use final unit cell edges 78.0333 78.0333 38.833)&lt;br /&gt;
  Anomalous and mean data:&lt;br /&gt;
    /reg/data/ana04/cxi/cxi84914/scratch/tmmclark/merge/GdLysozymeanom_4etc.mtz&lt;br /&gt;
&lt;br /&gt;
Final data:&lt;br /&gt;
  Miller array info: None&lt;br /&gt;
  Observation type: xray.intensity&lt;br /&gt;
  Type of data: double, size=18057&lt;br /&gt;
  Type of sigmas: double, size=18057&lt;br /&gt;
  Number of Miller indices: 18057&lt;br /&gt;
  Anomalous flag: True&lt;br /&gt;
  Unit cell: (78.0333, 78.0333, 38.833, 90, 90, 90)&lt;br /&gt;
  Space group: P 43 21 2 (No. 96)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=863</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=863"/>
		<updated>2014-10-05T20:45:17Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Merge the data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
&lt;br /&gt;
On pslogin, download the reference structure 4etc from the pdb (must be done on pslogin, the only outward-facing host).  4etc.pdb will be used for per-image scaling; 4etc.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme0.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 ./mergeLysozyme0.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymenoamo_4etc.log | Log file with model scaling and no anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymeanom_4etc.log | Log file with model scaling and anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Trying to merge not scaling to a model:&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/Lysozymeanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/Lysozymenoanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
 phenix.xtriage Lysozymenoanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor:14.8&lt;br /&gt;
&lt;br /&gt;
Use Gd-Lysozyme anomalous structure to get Gd sites:&lt;br /&gt;
 phenix.fetch_pdb --mtz 4n5r&lt;br /&gt;
 phenix.automr 4n5r.pdb thermonoanom_4etc_s0_mark0.mtz seq_file=4n5ri.fa identity=100 copies=1 build=False&lt;br /&gt;
&lt;br /&gt;
The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags used in the Nature Methods paper&lt;br /&gt;
 wget http://cci.lbl.gov/publications/download/4ow3_original_iobs_flags.mtz&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine ./AutoMR_run_1_/MR.1.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=thermonoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags \&lt;br /&gt;
  main.number_of_macro_cycles=6 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
trial 003: RWORK = 23.1% RFREE = 26.5% out to 2.1 Angstrom&lt;br /&gt;
&lt;br /&gt;
trial 005: RWORK = 22.0% RFREE = 26.3% out to 2.1 Angstrom (taking untrusted pixels into account)&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=862</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=862"/>
		<updated>2014-10-05T20:45:00Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Merge the data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
&lt;br /&gt;
On pslogin, download the reference structure 4etc from the pdb (must be done on pslogin, the only outward-facing host).  4etc.pdb will be used for per-image scaling; 4etc.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme0.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 ./mergeLysozyme0.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
[GdLysozymenoamo_4etc.log | Log file with model scaling and no anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
[[GdLysozymeanom_4etc.log | Log file with model scaling and anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Trying to merge not scaling to a model:&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/Lysozymeanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/Lysozymenoanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
 phenix.xtriage Lysozymenoanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor:14.8&lt;br /&gt;
&lt;br /&gt;
Use Gd-Lysozyme anomalous structure to get Gd sites:&lt;br /&gt;
 phenix.fetch_pdb --mtz 4n5r&lt;br /&gt;
 phenix.automr 4n5r.pdb thermonoanom_4etc_s0_mark0.mtz seq_file=4n5ri.fa identity=100 copies=1 build=False&lt;br /&gt;
&lt;br /&gt;
The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags used in the Nature Methods paper&lt;br /&gt;
 wget http://cci.lbl.gov/publications/download/4ow3_original_iobs_flags.mtz&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine ./AutoMR_run_1_/MR.1.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=thermonoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags \&lt;br /&gt;
  main.number_of_macro_cycles=6 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
trial 003: RWORK = 23.1% RFREE = 26.5% out to 2.1 Angstrom&lt;br /&gt;
&lt;br /&gt;
trial 005: RWORK = 22.0% RFREE = 26.3% out to 2.1 Angstrom (taking untrusted pixels into account)&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=861</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=861"/>
		<updated>2014-10-05T20:41:45Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Merge the data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
&lt;br /&gt;
On pslogin, download the reference structure 4etc from the pdb (must be done on pslogin, the only outward-facing host).  4etc.pdb will be used for per-image scaling; 4etc.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme0.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 ./mergeLysozyme0.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
[[mergeLysozyme0.log | Log file with model scaling and no anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
[[mergeLysozyme0.log | Log file with model scaling and anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Trying to merge not scaling to a model:&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/Lysozymeanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/Lysozymenoanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
 phenix.xtriage Lysozymenoanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor:14.8&lt;br /&gt;
&lt;br /&gt;
Use Gd-Lysozyme anomalous structure to get Gd sites:&lt;br /&gt;
 phenix.fetch_pdb --mtz 4n5r&lt;br /&gt;
 phenix.automr 4n5r.pdb thermonoanom_4etc_s0_mark0.mtz seq_file=4n5ri.fa identity=100 copies=1 build=False&lt;br /&gt;
&lt;br /&gt;
The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags used in the Nature Methods paper&lt;br /&gt;
 wget http://cci.lbl.gov/publications/download/4ow3_original_iobs_flags.mtz&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine ./AutoMR_run_1_/MR.1.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=thermonoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags \&lt;br /&gt;
  main.number_of_macro_cycles=6 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
trial 003: RWORK = 23.1% RFREE = 26.5% out to 2.1 Angstrom&lt;br /&gt;
&lt;br /&gt;
trial 005: RWORK = 22.0% RFREE = 26.3% out to 2.1 Angstrom (taking untrusted pixels into account)&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=MergeLysozyme0.log&amp;diff=860</id>
		<title>MergeLysozyme0.log</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=MergeLysozyme0.log&amp;diff=860"/>
		<updated>2014-10-05T20:40:45Z</updated>

		<summary type="html">&lt;p&gt;Tara: Created page with &amp;quot;&amp;lt;pre&amp;gt; Statistics for all reflections -------------------------------------------------------------------------------------                                       &amp;lt;asu    &amp;lt;obs B...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Statistics for all reflections&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
                                      &amp;lt;asu    &amp;lt;obs&lt;br /&gt;
Bin  Resolution Range  Completeness  redun&amp;gt;  redun&amp;gt;  n_meas    &amp;lt;I&amp;gt;    &amp;lt;I/sig(I)&amp;gt;&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
  1 -1.0000 -  4.0934   [1098/1103] 3819.15 3836.54 4212517     39386   322.007&lt;br /&gt;
  2  4.0934 -  3.2490   [1027/1027] 3455.17 3455.17 3548462     32098   248.654&lt;br /&gt;
  3  3.2490 -  2.8382   [1005/1005] 2790.48 2790.48 2804431     21080   167.468&lt;br /&gt;
  4  2.8382 -  2.5787   [1004/1004] 2116.09 2116.09 2124556     15102   121.452&lt;br /&gt;
  5  2.5787 -  2.3938     [992/992] 1486.94 1486.94 1475042     10649    86.519&lt;br /&gt;
  6  2.3938 -  2.2527     [986/986]  910.70  910.70  897951      8042    59.687&lt;br /&gt;
  7  2.2527 -  2.1399     [987/987]  647.88  647.88  639455      6462    45.941&lt;br /&gt;
  8  2.1399 -  2.0467     [978/978]  463.86  463.86  453659      5459    37.341&lt;br /&gt;
  9  2.0467 -  1.9679     [981/981]  235.10  235.10  230635      3904    21.732&lt;br /&gt;
 10  1.9679 -  1.9000     [974/974]   75.81   75.81   73838      3101    10.993&lt;br /&gt;
&lt;br /&gt;
All                   [10032/10037] 1639.99 1640.80 16460546    14914   115.405&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
SUMMARY: For 11015 reflections, got slope 1.128181, correlation 0.721862&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Statistics for reflections where I &amp;gt; 0&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
                                      &amp;lt;asu    &amp;lt;obs&lt;br /&gt;
Bin  Resolution Range  Completeness  redun&amp;gt;  redun&amp;gt;  n_meas    &amp;lt;I&amp;gt;    &amp;lt;I/sig(I)&amp;gt;&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
  1 -1.0000 -  4.0934   [1098/1103] 3255.71 3270.54 3591049     39386   322.007&lt;br /&gt;
  2  4.0934 -  3.2490   [1027/1027] 2731.06 2731.06 2804794     32098   248.654&lt;br /&gt;
  3  3.2490 -  2.8382   [1005/1005] 2071.94 2071.94 2082298     21080   167.468&lt;br /&gt;
  4  2.8382 -  2.5787   [1004/1004] 1522.34 1522.34 1528427     15102   121.452&lt;br /&gt;
  5  2.5787 -  2.3938     [992/992] 1057.23 1057.23 1048772     10649    86.519&lt;br /&gt;
  6  2.3938 -  2.2527     [986/986]  641.70  641.70  632721      8042    59.687&lt;br /&gt;
  7  2.2527 -  2.1399     [987/987]  451.43  451.43  445557      6462    45.941&lt;br /&gt;
  8  2.1399 -  2.0467     [978/978]  318.79  318.79  311776      5459    37.341&lt;br /&gt;
  9  2.0467 -  1.9679     [981/981]  161.25  161.25  158183      3904    21.732&lt;br /&gt;
 10  1.9679 -  1.9000     [974/974]   53.16   53.16   51775      3101    10.993&lt;br /&gt;
&lt;br /&gt;
All                   [10032/10037] 1260.87 1261.50 12655352    14914   115.405&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
################################################################################&lt;br /&gt;
OUTPUT FILES&lt;br /&gt;
  (will use final unit cell edges 78.0333 78.0333 38.833)&lt;br /&gt;
  Anomalous and mean data:&lt;br /&gt;
    /reg/data/ana04/cxi/cxi84914/scratch/tmmclark/merge/GdLysozymenoanom_4etc.mtz&lt;br /&gt;
&lt;br /&gt;
Final data:&lt;br /&gt;
  Miller array info: None&lt;br /&gt;
  Observation type: xray.intensity&lt;br /&gt;
  Type of data: double, size=9902&lt;br /&gt;
  Type of sigmas: double, size=9902&lt;br /&gt;
  Number of Miller indices: 9902&lt;br /&gt;
  Anomalous flag: False&lt;br /&gt;
  Unit cell: (78.0333, 78.0333, 38.833, 90, 90, 90)&lt;br /&gt;
  Space group: P 43 21 2 (No. 96)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=859</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=859"/>
		<updated>2014-10-05T20:39:57Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Merge the data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
&lt;br /&gt;
On pslogin, download the reference structure 4etc from the pdb (must be done on pslogin, the only outward-facing host).  4etc.pdb will be used for per-image scaling; 4etc.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme0.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 ./mergeLysozyme0.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
[[mergeLysozyme0.log | Log file with model scaling and no anomalous flag]]&lt;br /&gt;
[[mergeLysozyme0.log | Log file with model scaling and anomalous flag]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Trying to merge not scaling to a model:&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/Lysozymeanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/Lysozymenoanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
 phenix.xtriage Lysozymenoanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor:14.8&lt;br /&gt;
&lt;br /&gt;
Use Gd-Lysozyme anomalous structure to get Gd sites:&lt;br /&gt;
 phenix.fetch_pdb --mtz 4n5r&lt;br /&gt;
 phenix.automr 4n5r.pdb thermonoanom_4etc_s0_mark0.mtz seq_file=4n5ri.fa identity=100 copies=1 build=False&lt;br /&gt;
&lt;br /&gt;
The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags used in the Nature Methods paper&lt;br /&gt;
 wget http://cci.lbl.gov/publications/download/4ow3_original_iobs_flags.mtz&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine ./AutoMR_run_1_/MR.1.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=thermonoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags \&lt;br /&gt;
  main.number_of_macro_cycles=6 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
trial 003: RWORK = 23.1% RFREE = 26.5% out to 2.1 Angstrom&lt;br /&gt;
&lt;br /&gt;
trial 005: RWORK = 22.0% RFREE = 26.3% out to 2.1 Angstrom (taking untrusted pixels into account)&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=858</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=858"/>
		<updated>2014-10-01T22:18:06Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Solve the structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
&lt;br /&gt;
On pslogin, download the reference structure 4etc from the pdb (must be done on pslogin, the only outward-facing host).  4etc.pdb will be used for per-image scaling; 4etc.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme0.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 ./mergeLysozyme0.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
[[mergeLysozyme0.log | Log file with model scaling]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Trying to merge not scaling to a model:&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/Lysozymeanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/Lysozymenoanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
 phenix.xtriage Lysozymenoanom_4etc_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor:14.8&lt;br /&gt;
&lt;br /&gt;
Use Gd-Lysozyme anomalous structure to get Gd sites:&lt;br /&gt;
 phenix.fetch_pdb --mtz 4n5r&lt;br /&gt;
 phenix.automr 4n5r.pdb thermonoanom_4etc_s0_mark0.mtz seq_file=4n5ri.fa identity=100 copies=1 build=False&lt;br /&gt;
&lt;br /&gt;
The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags used in the Nature Methods paper&lt;br /&gt;
 wget http://cci.lbl.gov/publications/download/4ow3_original_iobs_flags.mtz&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine ./AutoMR_run_1_/MR.1.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=thermonoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags \&lt;br /&gt;
  main.number_of_macro_cycles=6 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
trial 003: RWORK = 23.1% RFREE = 26.5% out to 2.1 Angstrom&lt;br /&gt;
&lt;br /&gt;
trial 005: RWORK = 22.0% RFREE = 26.3% out to 2.1 Angstrom (taking untrusted pixels into account)&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=857</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=857"/>
		<updated>2014-10-01T22:13:58Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Solve the structure */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
&lt;br /&gt;
On pslogin, download the reference structure 4etc from the pdb (must be done on pslogin, the only outward-facing host).  4etc.pdb will be used for per-image scaling; 4etc.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme0.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 ./mergeLysozyme0.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
[[mergeLysozyme0.log | Log file with model scaling]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Trying to merge not scaling to a model:&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/Lysozymeanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/Lysozymenoanom_4etc_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 2tli&lt;br /&gt;
 phenix.xtriage thermonoanom_2tli_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor:14.8&lt;br /&gt;
&lt;br /&gt;
 phenix.automr 2tli.pdb thermonoanom_2tli_s0_mark0.mtz seq_file=2tli.fa identity=100 copies=1 build=False&lt;br /&gt;
&lt;br /&gt;
The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags used in the Nature Methods paper&lt;br /&gt;
 wget http://cci.lbl.gov/publications/download/4ow3_original_iobs_flags.mtz&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine ./AutoMR_run_1_/MR.1.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=thermonoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags \&lt;br /&gt;
  main.number_of_macro_cycles=6 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
trial 003: RWORK = 23.1% RFREE = 26.5% out to 2.1 Angstrom&lt;br /&gt;
&lt;br /&gt;
trial 005: RWORK = 22.0% RFREE = 26.3% out to 2.1 Angstrom (taking untrusted pixels into account)&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=856</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=856"/>
		<updated>2014-10-01T22:09:26Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Merge the data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
&lt;br /&gt;
On pslogin, download the reference structure 4etc from the pdb (must be done on pslogin, the only outward-facing host).  4etc.pdb will be used for per-image scaling; 4etc.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme0.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 ./mergeLysozyme0.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
[[mergeLysozyme0.log | Log file with model scaling]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Trying to merge not scaling to a model:&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/e157/thermoanom_2tli_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/e157/thermonoanom_2tli_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 2tli&lt;br /&gt;
 phenix.xtriage thermonoanom_2tli_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor:14.8&lt;br /&gt;
&lt;br /&gt;
 phenix.automr 2tli.pdb thermonoanom_2tli_s0_mark0.mtz seq_file=2tli.fa identity=100 copies=1 build=False&lt;br /&gt;
&lt;br /&gt;
The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags used in the Nature Methods paper&lt;br /&gt;
 wget http://cci.lbl.gov/publications/download/4ow3_original_iobs_flags.mtz&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine ./AutoMR_run_1_/MR.1.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=thermonoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags \&lt;br /&gt;
  main.number_of_macro_cycles=6 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
trial 003: RWORK = 23.1% RFREE = 26.5% out to 2.1 Angstrom&lt;br /&gt;
&lt;br /&gt;
trial 005: RWORK = 22.0% RFREE = 26.3% out to 2.1 Angstrom (taking untrusted pixels into account)&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=855</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=855"/>
		<updated>2014-10-01T22:08:46Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Merge the data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
&lt;br /&gt;
On pslogin, download the reference structure 4etc from the pdb (must be done on pslogin, the only outward-facing host).  4etc.pdb will be used for per-image scaling; 4etc.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme0.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 ./mergeLysozyme0.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
[[mergeLysozyme0.log | Log file with model scaling]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Trying to merge not scaling to a model:&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/e157/thermoanom_2tli_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/e157/thermonoanom_2tli_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 2tli&lt;br /&gt;
 phenix.xtriage thermonoanom_2tli_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor:14.8&lt;br /&gt;
&lt;br /&gt;
 phenix.automr 2tli.pdb thermonoanom_2tli_s0_mark0.mtz seq_file=2tli.fa identity=100 copies=1 build=False&lt;br /&gt;
&lt;br /&gt;
The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags used in the Nature Methods paper&lt;br /&gt;
 wget http://cci.lbl.gov/publications/download/4ow3_original_iobs_flags.mtz&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine ./AutoMR_run_1_/MR.1.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=thermonoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags \&lt;br /&gt;
  main.number_of_macro_cycles=6 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
trial 003: RWORK = 23.1% RFREE = 26.5% out to 2.1 Angstrom&lt;br /&gt;
&lt;br /&gt;
trial 005: RWORK = 22.0% RFREE = 26.3% out to 2.1 Angstrom (taking untrusted pixels into account)&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=MergeLysozyme0.csh&amp;diff=854</id>
		<title>MergeLysozyme0.csh</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=MergeLysozyme0.csh&amp;diff=854"/>
		<updated>2014-10-01T20:57:49Z</updated>

		<summary type="html">&lt;p&gt;Tara: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/csh -f&lt;br /&gt;
&lt;br /&gt;
set trial1=${1}&lt;br /&gt;
set trial2=${2}&lt;br /&gt;
set datadir1 = /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239&lt;br /&gt;
set datadir2 = /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240&lt;br /&gt;
set runs1 = 27,28,29,31&lt;br /&gt;
set runs2 = 3,4,5,6,7,10,12,14,16,17,18,19,21,24,25,26,27,28,29,30,32,33,34,35,36,37,38,39,40&lt;br /&gt;
set datastring1=`python -c &amp;quot;print&#039; &#039;.join([&#039;data=${datadir1}/r%04d/${trial1}/integration&#039;%i for i in [${runs1}]])&amp;quot;`&lt;br /&gt;
set datastring2=`python -c &amp;quot;print&#039; &#039;.join([&#039;data=${datadir2}/r%04d/${trial2}/integration&#039;%i for i in [${runs2}]])&amp;quot;`&lt;br /&gt;
set tag=last_BT_${trial1}_${trial2}_2.1_&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
set tag = &amp;quot;4etc&amp;quot;&lt;br /&gt;
&lt;br /&gt;
set effective_params = &amp;quot;d_min=2.1 \&lt;br /&gt;
output.n_bins=10 \&lt;br /&gt;
${datastring1} \&lt;br /&gt;
${datastring2} \&lt;br /&gt;
model=(path to user home)/USERNAME/myrelease/cxi84914/${tag}.pdb \&lt;br /&gt;
backend=FS \&lt;br /&gt;
pixel_size=0.11 \&lt;br /&gt;
nproc=16 \&lt;br /&gt;
merge_anomalous=False \&lt;br /&gt;
plot_single_index_histograms=False \&lt;br /&gt;
raw_data.sdfac_auto=True \&lt;br /&gt;
scaling.mtz_file=(path to user home)/USERNAME/myrelease/cxi84914/${tag}.mtz \&lt;br /&gt;
scaling.mtz_column_F=iobs \&lt;br /&gt;
scaling.show_plots=False \&lt;br /&gt;
scaling.algorithm=mark0 \&lt;br /&gt;
scaling.log_cutoff=2. \&lt;br /&gt;
scaling.show_plots=True \&lt;br /&gt;
scaling.report_ML=True \&lt;br /&gt;
postrefinement.enable=False \&lt;br /&gt;
set_average_unit_cell=True \&lt;br /&gt;
rescale_with_average_cell=False \&lt;br /&gt;
significance_filter.sigma=0.5 \&lt;br /&gt;
min_corr=0.1 \&lt;br /&gt;
output.prefix=GdLysozymeanom_${tag}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
set eff_params2 = `echo $effective_params|sed -e &amp;quot;s/anomalous=False/anomalous=True/g&amp;quot;|sed -e &amp;quot;s/anom_/noanom_/g&amp;quot;`&lt;br /&gt;
&lt;br /&gt;
cxi.merge ${effective_params}&lt;br /&gt;
cxi.xmerge ${effective_params}&lt;br /&gt;
&lt;br /&gt;
cxi.merge ${eff_params2}&lt;br /&gt;
cxi.xmerge ${eff_params2}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=MergeLysozyme0.csh&amp;diff=853</id>
		<title>MergeLysozyme0.csh</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=MergeLysozyme0.csh&amp;diff=853"/>
		<updated>2014-10-01T20:50:39Z</updated>

		<summary type="html">&lt;p&gt;Tara: Created page with &amp;quot;&amp;lt;pre&amp;gt; #!/bin/csh -f  set runs = 21,22,23,24,25,26,27   set datastring  = `python -c &amp;quot;print &amp;#039; &amp;#039;.join([&amp;#039;data=../../results/e157/r%04d/003/integration&amp;#039;%i for i in [${runs}]])&amp;quot;`...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/csh -f&lt;br /&gt;
&lt;br /&gt;
set runs = 21,22,23,24,25,26,27&lt;br /&gt;
 &lt;br /&gt;
set datastring  = `python -c &amp;quot;print &#039; &#039;.join([&#039;data=../../results/e157/r%04d/003/integration&#039;%i for i in [${runs}]])&amp;quot;`&lt;br /&gt;
&lt;br /&gt;
set tag = &amp;quot;2tli&amp;quot;&lt;br /&gt;
&lt;br /&gt;
set effective_params = &amp;quot;d_min=2.1 \&lt;br /&gt;
output.n_bins=10 \&lt;br /&gt;
${datastring} \&lt;br /&gt;
model=/reg/neh/home3/USERNAME/myrelease/cxi84914/${tag}.pdb \&lt;br /&gt;
backend=FS \&lt;br /&gt;
pixel_size=0.11 \&lt;br /&gt;
nproc=16 \&lt;br /&gt;
merge_anomalous=False \&lt;br /&gt;
plot_single_index_histograms=False \&lt;br /&gt;
raw_data.sdfac_auto=True \&lt;br /&gt;
scaling.mtz_file=/reg/neh/home3/USERNAME/myrelease/cxi84914/${tag}.mtz \&lt;br /&gt;
scaling.mtz_column_F=iobs \&lt;br /&gt;
scaling.show_plots=False \&lt;br /&gt;
scaling.algorithm=mark0 \&lt;br /&gt;
scaling.log_cutoff=2. \&lt;br /&gt;
scaling.show_plots=True \&lt;br /&gt;
scaling.report_ML=True \&lt;br /&gt;
postrefinement.enable=False \&lt;br /&gt;
set_average_unit_cell=True \&lt;br /&gt;
rescale_with_average_cell=False \&lt;br /&gt;
significance_filter.sigma=0.5 \&lt;br /&gt;
min_corr=0.1 \&lt;br /&gt;
output.prefix=thermoanom_${tag}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
set eff_params2 = `echo $effective_params|sed -e &amp;quot;s/anomalous=False/anomalous=True/g&amp;quot;|sed -e &amp;quot;s/anom_/noanom_/g&amp;quot;`&lt;br /&gt;
&lt;br /&gt;
cxi.merge ${effective_params}&lt;br /&gt;
cxi.xmerge ${effective_params}&lt;br /&gt;
&lt;br /&gt;
cxi.merge ${eff_params2}&lt;br /&gt;
cxi.xmerge ${eff_params2}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=852</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=852"/>
		<updated>2014-10-01T20:47:38Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Merge the data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
&lt;br /&gt;
On pslogin, download the reference structure 4etc from the pdb (must be done on pslogin, the only outward-facing host).  4etc.pdb will be used for per-image scaling; 4etc.mtz will be used for reporting correlation to isomorphous synchrotron data.&lt;br /&gt;
&lt;br /&gt;
 phenix.fetch_pdb --mtz 4etc&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme0.csh]]. &lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/&lt;br /&gt;
 ./mergeLysozyme0.csh&lt;br /&gt;
&lt;br /&gt;
[[mergethermo.log | Log file]]&lt;br /&gt;
&lt;br /&gt;
[[mergethermo005.log | Better log file from trial 005--using untrusted pixel mask]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Trying to merge not scaling to a model:&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/e157/thermoanom_2tli_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/e157/thermonoanom_2tli_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 2tli&lt;br /&gt;
 phenix.xtriage thermonoanom_2tli_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor:14.8&lt;br /&gt;
&lt;br /&gt;
 phenix.automr 2tli.pdb thermonoanom_2tli_s0_mark0.mtz seq_file=2tli.fa identity=100 copies=1 build=False&lt;br /&gt;
&lt;br /&gt;
The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags used in the Nature Methods paper&lt;br /&gt;
 wget http://cci.lbl.gov/publications/download/4ow3_original_iobs_flags.mtz&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine ./AutoMR_run_1_/MR.1.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=thermonoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags \&lt;br /&gt;
  main.number_of_macro_cycles=6 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
trial 003: RWORK = 23.1% RFREE = 26.5% out to 2.1 Angstrom&lt;br /&gt;
&lt;br /&gt;
trial 005: RWORK = 22.0% RFREE = 26.3% out to 2.1 Angstrom (taking untrusted pixels into account)&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=851</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=851"/>
		<updated>2014-10-01T14:27:41Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Merge the data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
In summary, out of 105,912 indexed images there were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/e157/thermoanom_2tli_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/e157/thermonoanom_2tli_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 2tli&lt;br /&gt;
 phenix.xtriage thermonoanom_2tli_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor:14.8&lt;br /&gt;
&lt;br /&gt;
 phenix.automr 2tli.pdb thermonoanom_2tli_s0_mark0.mtz seq_file=2tli.fa identity=100 copies=1 build=False&lt;br /&gt;
&lt;br /&gt;
The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags used in the Nature Methods paper&lt;br /&gt;
 wget http://cci.lbl.gov/publications/download/4ow3_original_iobs_flags.mtz&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine ./AutoMR_run_1_/MR.1.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=thermonoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags \&lt;br /&gt;
  main.number_of_macro_cycles=6 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
trial 003: RWORK = 23.1% RFREE = 26.5% out to 2.1 Angstrom&lt;br /&gt;
&lt;br /&gt;
trial 005: RWORK = 22.0% RFREE = 26.3% out to 2.1 Angstrom (taking untrusted pixels into account)&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=850</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=850"/>
		<updated>2014-10-01T14:25:24Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Data Discovery Phase */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  Note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz_offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Repeating this Test for the detz_offset of e240 using the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
There were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/e157/thermoanom_2tli_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/e157/thermonoanom_2tli_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 2tli&lt;br /&gt;
 phenix.xtriage thermonoanom_2tli_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor:14.8&lt;br /&gt;
&lt;br /&gt;
 phenix.automr 2tli.pdb thermonoanom_2tli_s0_mark0.mtz seq_file=2tli.fa identity=100 copies=1 build=False&lt;br /&gt;
&lt;br /&gt;
The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags used in the Nature Methods paper&lt;br /&gt;
 wget http://cci.lbl.gov/publications/download/4ow3_original_iobs_flags.mtz&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine ./AutoMR_run_1_/MR.1.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=thermonoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags \&lt;br /&gt;
  main.number_of_macro_cycles=6 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
trial 003: RWORK = 23.1% RFREE = 26.5% out to 2.1 Angstrom&lt;br /&gt;
&lt;br /&gt;
trial 005: RWORK = 22.0% RFREE = 26.3% out to 2.1 Angstrom (taking untrusted pixels into account)&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=849</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=849"/>
		<updated>2014-09-30T22:45:37Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Merge the data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  If this seems like a poor window to search, note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Testing the detz_offset for e240 for the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging over 105,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
There were:&lt;br /&gt;
  105526 of 105912 integration files were accepted&lt;br /&gt;
  284 rejected due to wrong Bravais group&lt;br /&gt;
  3 rejected for unit cell outliers&lt;br /&gt;
  99 rejected for low signal&lt;br /&gt;
  0 rejected due to poor correlation&lt;br /&gt;
  0 rejected for file errors or no reindex matrix&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/e157/thermoanom_2tli_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/e157/thermonoanom_2tli_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 2tli&lt;br /&gt;
 phenix.xtriage thermonoanom_2tli_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor:14.8&lt;br /&gt;
&lt;br /&gt;
 phenix.automr 2tli.pdb thermonoanom_2tli_s0_mark0.mtz seq_file=2tli.fa identity=100 copies=1 build=False&lt;br /&gt;
&lt;br /&gt;
The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags used in the Nature Methods paper&lt;br /&gt;
 wget http://cci.lbl.gov/publications/download/4ow3_original_iobs_flags.mtz&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine ./AutoMR_run_1_/MR.1.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=thermonoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags \&lt;br /&gt;
  main.number_of_macro_cycles=6 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
trial 003: RWORK = 23.1% RFREE = 26.5% out to 2.1 Angstrom&lt;br /&gt;
&lt;br /&gt;
trial 005: RWORK = 22.0% RFREE = 26.3% out to 2.1 Angstrom (taking untrusted pixels into account)&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=848</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=848"/>
		<updated>2014-09-30T22:43:38Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Merge the data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  If this seems like a poor window to search, note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Testing the detz_offset for e240 for the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
The statistics resulting from merging ~106,000 images are contained here in the [[mergeLysozyme.log | Log file]].&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/e157/thermoanom_2tli_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/e157/thermonoanom_2tli_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 2tli&lt;br /&gt;
 phenix.xtriage thermonoanom_2tli_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor:14.8&lt;br /&gt;
&lt;br /&gt;
 phenix.automr 2tli.pdb thermonoanom_2tli_s0_mark0.mtz seq_file=2tli.fa identity=100 copies=1 build=False&lt;br /&gt;
&lt;br /&gt;
The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags used in the Nature Methods paper&lt;br /&gt;
 wget http://cci.lbl.gov/publications/download/4ow3_original_iobs_flags.mtz&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine ./AutoMR_run_1_/MR.1.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=thermonoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags \&lt;br /&gt;
  main.number_of_macro_cycles=6 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
trial 003: RWORK = 23.1% RFREE = 26.5% out to 2.1 Angstrom&lt;br /&gt;
&lt;br /&gt;
trial 005: RWORK = 22.0% RFREE = 26.3% out to 2.1 Angstrom (taking untrusted pixels into account)&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=MergeLysozyme.log&amp;diff=847</id>
		<title>MergeLysozyme.log</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=MergeLysozyme.log&amp;diff=847"/>
		<updated>2014-09-30T22:42:23Z</updated>

		<summary type="html">&lt;p&gt;Tara: Created page with &amp;quot;&amp;lt;pre&amp;gt; Statistics for all reflections -------------------------------------------------------------------------------------                                       &amp;lt;asu    &amp;lt;obs B...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
Statistics for all reflections&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
                                      &amp;lt;asu    &amp;lt;obs&lt;br /&gt;
Bin  Resolution Range  Completeness  redun&amp;gt;  redun&amp;gt;  n_meas    &amp;lt;I&amp;gt;    &amp;lt;I/sig(I)&amp;gt;&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
  1 -1.0000 -  4.8859   [1056/1061] 2955.33 2969.32 3135607       261   264.662&lt;br /&gt;
  2  4.8859 -  3.8780   [1063/1063] 2182.08 2182.08 2319546       237   195.531&lt;br /&gt;
  3  3.8780 -  3.3877   [1076/1076] 2186.61 2186.61 2352793       238   184.017&lt;br /&gt;
  4  3.3877 -  3.0780   [1053/1053] 1915.53 1915.53 2017054       203   146.743&lt;br /&gt;
  5  3.0780 -  2.8573   [1073/1073] 1596.03 1596.03 1712539       169   116.168&lt;br /&gt;
  6  2.8573 -  2.6888   [1047/1047] 1270.25 1270.25 1329948       156    97.816&lt;br /&gt;
  7  2.6888 -  2.5542   [1055/1055] 1160.72 1160.72 1224562       136    86.977&lt;br /&gt;
  8  2.5542 -  2.4430   [1061/1061]  936.46  936.46  993587       116    70.595&lt;br /&gt;
  9  2.4430 -  2.3489   [1079/1079]  640.39  640.39  690978        98    53.040&lt;br /&gt;
 10  2.3489 -  2.2679   [1067/1067]  509.43  509.43  543562        91    46.092&lt;br /&gt;
 11  2.2679 -  2.1969   [1069/1069]  412.24  412.24  440689        80    38.121&lt;br /&gt;
 12  2.1969 -  2.1341   [1050/1050]  337.32  337.32  354181        79    34.521&lt;br /&gt;
 13  2.1341 -  2.0779   [1048/1048]  291.37  291.37  305354        77    32.820&lt;br /&gt;
 14  2.0779 -  2.0272   [1067/1067]  222.09  222.09  236975        64    25.062&lt;br /&gt;
 15  2.0272 -  1.9812   [1060/1060]  141.55  141.55  150038        56    18.291&lt;br /&gt;
 16  1.9812 -  1.9390   [1061/1061]   75.59   75.59   80206        47    11.615&lt;br /&gt;
 17  1.9390 -  1.9002   [1058/1058]   34.54   34.54   36540        44     7.614&lt;br /&gt;
 18  1.9002 -  1.8643   [1080/1080]   22.34   22.34   24126        41     6.208&lt;br /&gt;
 19  1.8643 -  1.8310   [1062/1062]   13.05   13.05   13857        38     4.149&lt;br /&gt;
 20  1.8310 -  1.8000   [1032/1048]    5.26    5.34    5513        41     2.629&lt;br /&gt;
&lt;br /&gt;
All                   [21217/21238]  846.01  846.85 17967655      114    72.275&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Statistics for reflections where I &amp;gt; 0&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
                                      &amp;lt;asu    &amp;lt;obs&lt;br /&gt;
Bin  Resolution Range  Completeness  redun&amp;gt;  redun&amp;gt;  n_meas    &amp;lt;I&amp;gt;    &amp;lt;I/sig(I)&amp;gt;&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
  1 -1.0000 -  4.8859   [1056/1061] 2523.10 2535.05 2677013       261   264.662&lt;br /&gt;
  2  4.8859 -  3.8780   [1063/1063] 1788.99 1788.99 1901701       237   195.531&lt;br /&gt;
  3  3.8780 -  3.3877   [1076/1076] 1716.85 1716.85 1847328       238   184.017&lt;br /&gt;
  4  3.3877 -  3.0780   [1053/1053] 1436.20 1436.20 1512318       203   146.743&lt;br /&gt;
  5  3.0780 -  2.8573   [1073/1073] 1166.53 1166.53 1251685       169   116.168&lt;br /&gt;
  6  2.8573 -  2.6888   [1047/1047]  916.51  916.51  959581       156    97.816&lt;br /&gt;
  7  2.6888 -  2.5542   [1055/1055]  830.95  830.95  876650       136    86.977&lt;br /&gt;
  8  2.5542 -  2.4430   [1061/1061]  663.09  663.09  703540       116    70.595&lt;br /&gt;
  9  2.4430 -  2.3489   [1079/1079]  451.49  451.49  487153        98    53.040&lt;br /&gt;
 10  2.3489 -  2.2679   [1067/1067]  359.57  359.57  383661        91    46.092&lt;br /&gt;
 11  2.2679 -  2.1969   [1069/1069]  287.45  287.45  307285        80    38.121&lt;br /&gt;
 12  2.1969 -  2.1341   [1050/1050]  234.51  234.51  246238        79    34.521&lt;br /&gt;
 13  2.1341 -  2.0779   [1048/1048]  201.82  201.82  211512        77    32.820&lt;br /&gt;
 14  2.0779 -  2.0272   [1067/1067]  151.59  151.59  161746        64    25.062&lt;br /&gt;
 15  2.0272 -  1.9812   [1060/1060]   96.83   96.83  102639        56    18.291&lt;br /&gt;
 16  1.9812 -  1.9390   [1061/1061]   52.13   52.13   55313        47    11.615&lt;br /&gt;
 17  1.9390 -  1.9002   [1058/1058]   24.37   24.37   25782        44     7.614&lt;br /&gt;
 18  1.9002 -  1.8643   [1080/1080]   15.98   15.98   17263        41     6.208&lt;br /&gt;
 19  1.8643 -  1.8310   [1061/1062]    9.45    9.46   10035        38     4.149&lt;br /&gt;
 20  1.8310 -  1.8000   [1008/1048]    3.85    4.00    4033        41     2.629&lt;br /&gt;
&lt;br /&gt;
All                   [21192/21238]  647.07  648.47 13742476      114    72.275&lt;br /&gt;
-------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
################################################################################&lt;br /&gt;
OUTPUT FILES&lt;br /&gt;
  (will use final unit cell edges 78.0369 78.0369 38.8313)&lt;br /&gt;
  Anomalous and mean data:&lt;br /&gt;
    /reg/data/ana04/cxi/cxi84914/scratch/tmmclark/merge/last_BT_011_004_1.8_.mtz&lt;br /&gt;
&lt;br /&gt;
Final data:&lt;br /&gt;
  Miller array info: None&lt;br /&gt;
  Observation type: xray.intensity&lt;br /&gt;
  Type of data: double, size=21192&lt;br /&gt;
  Type of sigmas: double, size=21192&lt;br /&gt;
  Number of Miller indices: 21192&lt;br /&gt;
  Anomalous flag: True&lt;br /&gt;
  Unit cell: (78.0369, 78.0369, 38.8313, 90, 90, 90)&lt;br /&gt;
  Space group: P 43 21 2 (No. 96)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=MergeLysozyme.csh&amp;diff=846</id>
		<title>MergeLysozyme.csh</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=MergeLysozyme.csh&amp;diff=846"/>
		<updated>2014-09-30T22:38:25Z</updated>

		<summary type="html">&lt;p&gt;Tara: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/csh -f&lt;br /&gt;
&lt;br /&gt;
set trial1=${1}&lt;br /&gt;
set trial2=${2}&lt;br /&gt;
set datadir1 = /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239&lt;br /&gt;
set datadir2 = /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240&lt;br /&gt;
set runs1 = 27,28,29,31&lt;br /&gt;
set runs2 = 3,4,5,6,7,10,12,14,16,17,18,19,21,24,25,26,27,28,29,30,32,33,34,35,36,37,38,39,40&lt;br /&gt;
set datastring1=`python -c &amp;quot;print&#039; &#039;.join([&#039;data=${datadir1}/r%04d/${trial1}/integration&#039;%i for i in [${runs1}]])&amp;quot;`&lt;br /&gt;
set datastring2=`python -c &amp;quot;print&#039; &#039;.join([&#039;data=${datadir2}/r%04d/${trial2}/integration&#039;%i for i in [${runs2}]])&amp;quot;`&lt;br /&gt;
set tag=last_BT_${trial1}_${trial2}_1.8_&lt;br /&gt;
&lt;br /&gt;
set effective_params=&amp;quot;d_min=1.8 \&lt;br /&gt;
output.n_bins=20 \&lt;br /&gt;
${datastring1} \&lt;br /&gt;
${datastring2} \&lt;br /&gt;
target_unit_cell=79,79,38,90,90,90 \&lt;br /&gt;
target_space_group=P43212 \&lt;br /&gt;
nproc=16 \&lt;br /&gt;
pixel_size=0.11\&lt;br /&gt;
merge_anomalous=False \&lt;br /&gt;
merging.refine_G_Imodel=True\&lt;br /&gt;
plot_single_index_histograms=False \&lt;br /&gt;
raw_data.sdfac_auto=True \&lt;br /&gt;
backend=FS\&lt;br /&gt;
mysql.runtag=${tag} \&lt;br /&gt;
mysql.passwd=terp888 \&lt;br /&gt;
mysql.user=nick \&lt;br /&gt;
mysql.database=xfelnks \&lt;br /&gt;
scaling.mtz_file=&amp;quot;Gd-Lysozyme.mtz&amp;quot; \&lt;br /&gt;
scaling.show_plots=True \&lt;br /&gt;
scaling.algorithm=mark1 \&lt;br /&gt;
scaling.log_cutoff=3. \&lt;br /&gt;
scaling.mtz_column_F=f-obs \&lt;br /&gt;
set_average_unit_cell=True \&lt;br /&gt;
rescale_with_average_cell=True \&lt;br /&gt;
output.prefix=${tag}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
cxi.merge ${effective_params}&lt;br /&gt;
cxi.xmerge ${effective_params}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=844</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=844"/>
		<updated>2014-09-29T23:12:32Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Merge the data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  If this seems like a poor window to search, note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Testing the detz_offset for e240 for the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh e239 trail# e240 trial#&lt;br /&gt;
&lt;br /&gt;
[[mergeLysozyme.log | Log file]]&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/e157/thermoanom_2tli_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/e157/thermonoanom_2tli_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 2tli&lt;br /&gt;
 phenix.xtriage thermonoanom_2tli_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor:14.8&lt;br /&gt;
&lt;br /&gt;
 phenix.automr 2tli.pdb thermonoanom_2tli_s0_mark0.mtz seq_file=2tli.fa identity=100 copies=1 build=False&lt;br /&gt;
&lt;br /&gt;
The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags used in the Nature Methods paper&lt;br /&gt;
 wget http://cci.lbl.gov/publications/download/4ow3_original_iobs_flags.mtz&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine ./AutoMR_run_1_/MR.1.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=thermonoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags \&lt;br /&gt;
  main.number_of_macro_cycles=6 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
trial 003: RWORK = 23.1% RFREE = 26.5% out to 2.1 Angstrom&lt;br /&gt;
&lt;br /&gt;
trial 005: RWORK = 22.0% RFREE = 26.3% out to 2.1 Angstrom (taking untrusted pixels into account)&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=843</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=843"/>
		<updated>2014-09-29T22:47:48Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Integrate the data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  If this seems like a poor window to search, note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Testing the detz_offset for e240 for the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh trail#e239 trial#e240&lt;br /&gt;
&lt;br /&gt;
[[mergeLysozyme.log | Log file]]&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/e157/thermoanom_2tli_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/e157/thermonoanom_2tli_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 2tli&lt;br /&gt;
 phenix.xtriage thermonoanom_2tli_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor:14.8&lt;br /&gt;
&lt;br /&gt;
 phenix.automr 2tli.pdb thermonoanom_2tli_s0_mark0.mtz seq_file=2tli.fa identity=100 copies=1 build=False&lt;br /&gt;
&lt;br /&gt;
The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags used in the Nature Methods paper&lt;br /&gt;
 wget http://cci.lbl.gov/publications/download/4ow3_original_iobs_flags.mtz&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine ./AutoMR_run_1_/MR.1.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=thermonoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags \&lt;br /&gt;
  main.number_of_macro_cycles=6 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
trial 003: RWORK = 23.1% RFREE = 26.5% out to 2.1 Angstrom&lt;br /&gt;
&lt;br /&gt;
trial 005: RWORK = 22.0% RFREE = 26.3% out to 2.1 Angstrom (taking untrusted pixels into account)&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=842</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=842"/>
		<updated>2014-09-29T22:46:51Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Merge the data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  If this seems like a poor window to search, note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Testing the detz_offset for e240 for the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
This results in 6839 integrated reflection pickles for e239 and      for e240.&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh trail#e239 trial#e240&lt;br /&gt;
&lt;br /&gt;
[[mergeLysozyme.log | Log file]]&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/e157/thermoanom_2tli_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/e157/thermonoanom_2tli_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 2tli&lt;br /&gt;
 phenix.xtriage thermonoanom_2tli_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor:14.8&lt;br /&gt;
&lt;br /&gt;
 phenix.automr 2tli.pdb thermonoanom_2tli_s0_mark0.mtz seq_file=2tli.fa identity=100 copies=1 build=False&lt;br /&gt;
&lt;br /&gt;
The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags used in the Nature Methods paper&lt;br /&gt;
 wget http://cci.lbl.gov/publications/download/4ow3_original_iobs_flags.mtz&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine ./AutoMR_run_1_/MR.1.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=thermonoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags \&lt;br /&gt;
  main.number_of_macro_cycles=6 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
trial 003: RWORK = 23.1% RFREE = 26.5% out to 2.1 Angstrom&lt;br /&gt;
&lt;br /&gt;
trial 005: RWORK = 22.0% RFREE = 26.3% out to 2.1 Angstrom (taking untrusted pixels into account)&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Merging&amp;diff=841</id>
		<title>Merging</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Merging&amp;diff=841"/>
		<updated>2014-09-29T22:44:48Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Merging a set of integration files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The result of [[Indexing and integration]] is a set of Python pickle files, each of which essentially contains a table of Miller indices of the observed reflections, their integrated intensities, and estimated errors.  In the general case, these files reflect the measurements from single shots, each exposing different crystals with a unique pulse of X-rays.  &#039;&#039;Merging&#039;&#039; refers to the procedure applied to unite all these observations into a single data set.  During merging, a distinct multiplicative factor, which accounts for the variance in pulse intensity and crystal size, is applied to the observations from a single shot to bring all the observations onto a common scale.  After rejecting possible outliers, the intensities for individual reflections are summed, and their errors are propagated in quadrature.  The result of merging is an mtz file suited for further processing, &#039;&#039;e.g.&#039;&#039; molecular replacement.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Merging a set of integration files ==&lt;br /&gt;
In &#039;&#039;cctbx.xfel&#039;&#039; the per-image scale factors are determined using a &#039;&#039;scaling reference&#039;&#039;.  This scaling reference is expected to be a previously solved, isomorphous data set.  The scale factor is determined by a least-squares fit of the observations to the reference intensities, after applying corrections for polarization&amp;lt;ref&amp;gt;[http://dx.doi.org/10.1107/S0021889882012060 Kahn, R, &amp;lt;i&amp;gt;et al.&amp;lt;/i&amp;gt; Macromolecular Crystallography with Synchrotron Radiation: Photographic Data Collection and Polarization Correction. &amp;lt;i&amp;gt;J Appl Cryst&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;15&amp;lt;/b&amp;gt;, 330–337 (1982).]&amp;lt;/ref&amp;gt;, and a significance filter, which limits the resolution of each diffraction pattern based on the signal-to-noise ratio.  Lattices not conforming to the Bravais symmetry of the scaling reference are rejected.  By default non-isomorphous lattices with cell lengths differing by more than 10% in length from the mean, or 2° in the angles are also rejected, as are lattices that correlate poorly with the scaling reference.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;cxi.merge&#039;&#039; may take several passes over the integrated images.  In order to speed up processing, &#039;&#039;cxi.merge&#039;&#039; will write the scaled data to a back  end database during each pass.  Currently three database back ends are implemented.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;FS&amp;lt;/code&amp;gt; is the simplest back end.  It stores the scaled intensities, their Miller indices, and information about the shots they were observed during in three flat files on the file system.&lt;br /&gt;
&lt;br /&gt;
* The &amp;lt;code&amp;gt;MySQL&amp;lt;/code&amp;gt; back end stores data in a MySQL database.  The database must be set up beforehand, and credentials to access it must be supplied in the parameters passed to &#039;&#039;cxi.merge&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* The &amp;lt;code&amp;gt;SQLite&amp;lt;/code&amp;gt; back end uses a simple SQLite database, which is written to a single file on the file system.  It is easier to use than the &amp;lt;code&amp;gt;MySQL&amp;lt;/code&amp;gt; back end and more efficient than the &amp;lt;code&amp;gt;FS&amp;lt;/code&amp;gt; backend.  Regrettably, the &amp;lt;code&amp;gt;SQLite&amp;lt;/code&amp;gt; back end does not appear to work on the Lustre file system.&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;cctbx.xfel&#039;&#039; images are merged using the &amp;lt;code&amp;gt;cxi.merge&amp;lt;/code&amp;gt; command.  &amp;lt;code&amp;gt;cxi.merge&amp;lt;/code&amp;gt; accepts several options which can conveniently be assembled in a &#039;&#039;phil&#039;&#039; file.  In this tutorial only a subset of the available options are defined.&lt;br /&gt;
&lt;br /&gt;
; backend&lt;br /&gt;
: Back end database; &amp;lt;code&amp;gt;FS&amp;lt;/code&amp;gt; for flat-file ASCII data storage, &amp;lt;code&amp;gt;MySQL&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SQLite&amp;lt;/code&amp;gt; for the respective proper database back ends.  &lt;br /&gt;
; d_min&lt;br /&gt;
: Limiting resolution for scaling and merging&lt;br /&gt;
; pixel_size&lt;br /&gt;
: set the pixel size for the detector used, this is a single value (0.11 for CSPad)&lt;br /&gt;
; data&lt;br /&gt;
: Directory containing integrated data in pickle format.  Repeat to specify additional directories.&lt;br /&gt;
; merge_anomalous&lt;br /&gt;
: &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; to merge anomalous contributors (&#039;&#039;i.e.&#039;&#039; Bijvoet mates), &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt; to preserve them&lt;br /&gt;
; min_corr&lt;br /&gt;
: Correlation cutoff for rejecting individual frames&lt;br /&gt;
; model&lt;br /&gt;
: The scaling reference, PDB filename containing atomic coordinates and isomorphous &amp;lt;code&amp;gt;CRYST1&amp;lt;/code&amp;gt; record.  Note:  quick command to download a pdb file from the Internet is: &amp;lt;code&amp;gt; phenix.fetch_pdb [pdb_code]&amp;lt;/code&amp;gt;&lt;br /&gt;
; nproc&lt;br /&gt;
: Specifies the number of scaling processes &#039;&#039;cxi.merge&#039;&#039; may have running at any one time&lt;br /&gt;
; output.prefix&lt;br /&gt;
: Prefix for all output file names&lt;br /&gt;
; rawdata.sdfac_auto&lt;br /&gt;
: &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; to apply &amp;lt;code&amp;gt;SDFAC&amp;lt;/code&amp;gt; correction to each image, assuming negative intensities are normally distributed noise&lt;br /&gt;
; rescale_with_average_cell&lt;br /&gt;
: Rescale the images a second time, requiring images to conform to the average unit cell.  If set to &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;set_average_unit_cell&amp;lt;/code&amp;gt; must also be set to &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt;.&lt;br /&gt;
; set_average_unit_cell&lt;br /&gt;
: If &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; set the unit cell of the merged data to the average of the merged images, otherwise use the unit cell of the scaling reference&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The merged data is written to an mtz-file named &amp;lt;code&amp;gt;&amp;lt;i&amp;gt;output.prefix&amp;lt;/i&amp;gt;.mtz&amp;lt;/code&amp;gt;.  Standard output, redirected to &amp;lt;code&amp;gt;merge.out&amp;lt;/code&amp;gt; above, mainly consists of statistics for each individual image as it is scaled.  The output concludes with a section labelled &amp;lt;code&amp;gt;FINISHED MERGING&amp;lt;/code&amp;gt;, which first lists the number of accepted and rejected images,&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 962 of 1185 integration files were accepted&lt;br /&gt;
 127 rejected due to wrong Bravais group&lt;br /&gt;
 1 rejected for unit cell outliers&lt;br /&gt;
 12 rejected for low signal&lt;br /&gt;
 83 rejected due to poor correlation&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This is followed by a histograms of the unit cell distribution, and the merging table:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
---------------------------------------------------------------------------------&lt;br /&gt;
                                     &amp;lt;asu   &amp;lt;obs&lt;br /&gt;
Bin  Resolution Range  Completeness redun&amp;gt; redun&amp;gt; n_meas   &amp;lt;I&amp;gt;    &amp;lt;I/sig(I)&amp;gt;&lt;br /&gt;
---------------------------------------------------------------------------------&lt;br /&gt;
  1 -1.0000 -  6.4633     [306/309]  67.61  68.28  20893    35621    27.044&lt;br /&gt;
  2  6.4633 -  5.1299     [285/285]  43.18  43.18  12305    19272    12.490&lt;br /&gt;
  3  5.1299 -  4.4814     [275/275]  46.77  46.77  12862    24391    14.261&lt;br /&gt;
  4  4.4814 -  4.0716     [269/269]  43.38  43.38  11670    29436    14.819&lt;br /&gt;
  5  4.0716 -  3.7798     [249/249]  35.50  35.50   8840    29811    12.716&lt;br /&gt;
  6  3.7798 -  3.5569     [267/267]  32.07  32.07   8562    24212    10.523&lt;br /&gt;
  7  3.5569 -  3.3787     [274/274]  20.99  20.99   5750    23626     8.171&lt;br /&gt;
  8  3.3787 -  3.2317     [256/256]  15.96  15.96   4085    24168     6.746&lt;br /&gt;
  9  3.2317 -  3.1072     [263/264]  12.16  12.20   3209    23936     5.859&lt;br /&gt;
 10  3.1072 -  3.0000     [263/263]   8.74   8.74   2298    20613     4.556&lt;br /&gt;
&lt;br /&gt;
All                     [2707/2711]  33.37  33.42  90474    25594    11.978&lt;br /&gt;
----------------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this case, the overall completeness to 3.0 Å is 2,707 / 2,711, or approximately 100%, and each observed reflection is measured 33.42 times on average (&amp;lt;code&amp;gt;&amp;lt;obs redun&amp;gt;&amp;lt;/code&amp;gt;).  In total 90,474 observations, with an average scaled and integrated intensity of 25,594 analog-to-digital units (ADU), were merged and the mean &amp;lt;i&amp;gt;I&amp;lt;/i&amp;gt; / σ(&amp;lt;i&amp;gt;I&amp;lt;/i&amp;gt;) was determined to be 11.978.&lt;br /&gt;
&lt;br /&gt;
== Additional merging statistics ==&lt;br /&gt;
&#039;&#039;cxi.xmerge&#039;&#039; retrieves the scaled, unmerged intensities from the database back end, and calculates the &amp;lt;i&amp;gt;CC&amp;lt;/i&amp;gt;&amp;lt;sub&amp;gt;1/2&amp;lt;/sub&amp;gt;&amp;lt;ref&amp;gt;[http://dx.doi.org/10.1126/science.1218231 Karplus, P. A. &amp;amp; Diederichs, K. Linking Crystallographic Model and Data Quality. &amp;lt;i&amp;gt;Science&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;336&amp;lt;/b&amp;gt;, 1030–1033 (2012).]&amp;lt;/ref&amp;gt; and &amp;lt;i&amp;gt;CC&amp;lt;/i&amp;gt;&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; statistics.  &amp;lt;i&amp;gt;CC&amp;lt;/i&amp;gt;&amp;lt;sub&amp;gt;1/2&amp;lt;/sub&amp;gt; is defined as Pearson&#039;s correlation coefficient between two sets, such that for each ￼unique reflection the average intensities of two randomly chosen halves of its ￼independent observations are assigned to different set.  &amp;lt;i&amp;gt;CC&amp;lt;/i&amp;gt;&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; is the correlation coefficient between the merged data and the isomorphous scaling reference.  Both statistics are computed in each resolution bin, as well as for the full set of reflections.&lt;br /&gt;
&lt;br /&gt;
Once the database has been populated using &#039;&#039;cxi.merge&#039;&#039;, &#039;&#039;cxi.xmerge&#039;&#039; can be run, using the parameters defined in a &#039;&#039;phil&#039;&#039;-file, &amp;lt;code&amp;gt;Ls-04-lysozyme-xmerge.phil&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ cxi.xmerge Ls04-lysozyme-xmerge.phil&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The options used in this tutorial not already described in [[#Merging a set of integration files|Merging a set of integration files]] are explained below.&lt;br /&gt;
; scaling.mtz_file&lt;br /&gt;
: mtz-file containing experimentally determined reference structure factors, such as synchrotron measurements, to be used for CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.  Experimental measurements, when available, can be downloaded from the PDB using &amp;lt;code&amp;gt;phenix.fetch_pdb –-mtz [pdb_code]&amp;lt;/code&amp;gt;. &lt;br /&gt;
; scaling.mtz_column_F&lt;br /&gt;
: In the experimental measurements mtz-file, the column name containing the reference data; can be either amplitudes or intensities.  The column name should be given &#039;&#039;&#039;in lower case&#039;&#039;&#039;. An MTZ-format file can be inspected to see which columns it contains with &amp;lt;code&amp;gt;phenix.mtz.dump [code].mtz&amp;lt;/code&amp;gt;.  Quick tip:  if experimental measurements are unavailable, mock experimental structure factors can be generated with &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;phenix.fmodel &amp;lt;pdb file&amp;gt; high_resolution=&amp;lt;value&amp;gt; output.type=real&amp;lt;/code&amp;gt; in which case one would use &amp;lt;code&amp;gt;scaling.mtz_column_F=fmodel&amp;lt;/code&amp;gt;.&lt;br /&gt;
; scaling.log_cutoff&lt;br /&gt;
: Intensities less than &amp;lt;i&amp;gt;e&amp;lt;/i&amp;gt;&amp;lt;sup&amp;gt;&amp;lt;code&amp;gt;scaling.log_cutoff&amp;lt;/code&amp;gt;&amp;lt;/sup&amp;gt; will not be included in  the calculation of CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; and R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; (however, these measurements will still be included in the final merged data). &lt;br /&gt;
&lt;br /&gt;
The results are printed on standard output and conclude with a table including the &amp;lt;i&amp;gt;CC&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
---------------------------------------------------------------------------------------&lt;br /&gt;
                                      CC            CC            R     R   Scale Scale&lt;br /&gt;
Bin  Resolution Range  Completeness  int     N     iso     N     int   iso   int   iso&lt;br /&gt;
---------------------------------------------------------------------------------------&lt;br /&gt;
  1 -1.0000 -  6.4633     [233/309] 45.1%     233 56.3%     142 57.5% 45.6% 0.749 3.084&lt;br /&gt;
  2  6.4633 -  5.1299     [184/285] 22.5%     184 56.7%      62 57.2% 31.5% 0.862 2.841&lt;br /&gt;
  3  5.1299 -  4.4814     [203/275] 43.7%     203 57.6%      85 55.3% 37.0% 0.830 2.977&lt;br /&gt;
  4  4.4814 -  4.0716     [220/269] 39.0%     220 59.7%     101 51.4% 30.3% 0.805 3.296&lt;br /&gt;
  5  4.0716 -  3.7798     [187/249] 77.5%     187 33.6%      63 54.3% 39.4% 0.775 4.243&lt;br /&gt;
  6  3.7798 -  3.5569     [198/267] 35.4%     198 47.2%      56 56.8% 27.5% 0.903 3.587&lt;br /&gt;
  7  3.5569 -  3.3787     [198/274] 32.0%     198 70.7%      40 59.9% 31.4% 0.814 3.846&lt;br /&gt;
  8  3.3787 -  3.2317     [163/256] 30.6%     163 24.5%      28 63.9% 49.1% 0.734 4.278&lt;br /&gt;
  9  3.2317 -  3.1072     [164/264] 40.6%     164 53.6%       7 80.4% 32.1% 0.622 5.543&lt;br /&gt;
 10  3.1072 -  3.0000     [137/261]  8.2%     137 93.9%       5 85.6% 33.4% 0.221 4.372&lt;br /&gt;
&lt;br /&gt;
All                                 34.7%    1887 47.7%     589 62.5% 39.5% 0.754 3.157&lt;br /&gt;
---------------------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this case the overall &amp;lt;i&amp;gt;CC&amp;lt;/i&amp;gt;&amp;lt;sub&amp;gt;1/2&amp;lt;/sub&amp;gt; (&amp;lt;code&amp;gt;CC int&amp;lt;/code&amp;gt;) is 34.7%, and the correlation coefficient to the isomorphous reference, &amp;lt;i&amp;gt;CC&amp;lt;/i&amp;gt;&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; (&amp;lt;code&amp;gt;CC iso&amp;lt;/code&amp;gt;) is 47.7%.&lt;br /&gt;
Note that the completeness for the cxi.xmerge output appears lower than that for the cxi.merge output. This is because the cxi.xmerge final table shows the completeness for the data used in the calculation of correlation coefficients, and so the completeness in the previous table should be used for general statistics.&lt;br /&gt;
&lt;br /&gt;
== Merging the tutorial data ==&lt;br /&gt;
&lt;br /&gt;
Compared to indexing and integration, merging is a relatively quick procedure.  However, particularly for large datasets, it may significantly strain computational resources.  Therefore, it is recommended to merge data on SLAC&#039;s interactive nodes.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ssh psanacs.slac.stanford.edu&lt;br /&gt;
$ cd myrelease&lt;br /&gt;
$ cp /reg/g/cctbx/tutorials/merging/Ls04-lysozyme-*merge.phil .&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Before running the merging programs, the &#039;&#039;phil&#039;&#039;-files may need to be edited.  In particular, the location of the directories containing pickle files with the integrated intensities may need to be adjusted.  Since both &amp;lt;code&amp;gt;cxi.merge&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;cxi.xmerge&amp;lt;/code&amp;gt; log to standard output, it is advisable to redirect the stream to a file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cxi.merge Ls04-lysozyme-merge.phil &amp;gt; merge.out&lt;br /&gt;
$ cxi.xmerge Ls04-lysozyme-xmerge.phil &amp;gt; xmerge.out&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The merged reflections, suitable for further processing, are written &amp;lt;code&amp;gt;Ls04-lysozyme.mtz&amp;lt;/code&amp;gt;. Note that although the data for this tutorial extends to 2.2 Å, the statistics become exceedingly poor around 3.0 Å.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Merging&amp;diff=840</id>
		<title>Merging</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Merging&amp;diff=840"/>
		<updated>2014-09-29T22:43:59Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Merging a set of integration files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The result of [[Indexing and integration]] is a set of Python pickle files, each of which essentially contains a table of Miller indices of the observed reflections, their integrated intensities, and estimated errors.  In the general case, these files reflect the measurements from single shots, each exposing different crystals with a unique pulse of X-rays.  &#039;&#039;Merging&#039;&#039; refers to the procedure applied to unite all these observations into a single data set.  During merging, a distinct multiplicative factor, which accounts for the variance in pulse intensity and crystal size, is applied to the observations from a single shot to bring all the observations onto a common scale.  After rejecting possible outliers, the intensities for individual reflections are summed, and their errors are propagated in quadrature.  The result of merging is an mtz file suited for further processing, &#039;&#039;e.g.&#039;&#039; molecular replacement.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Merging a set of integration files ==&lt;br /&gt;
In &#039;&#039;cctbx.xfel&#039;&#039; the per-image scale factors are determined using a &#039;&#039;scaling reference&#039;&#039;.  This scaling reference is expected to be a previously solved, isomorphous data set.  The scale factor is determined by a least-squares fit of the observations to the reference intensities, after applying corrections for polarization&amp;lt;ref&amp;gt;[http://dx.doi.org/10.1107/S0021889882012060 Kahn, R, &amp;lt;i&amp;gt;et al.&amp;lt;/i&amp;gt; Macromolecular Crystallography with Synchrotron Radiation: Photographic Data Collection and Polarization Correction. &amp;lt;i&amp;gt;J Appl Cryst&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;15&amp;lt;/b&amp;gt;, 330–337 (1982).]&amp;lt;/ref&amp;gt;, and a significance filter, which limits the resolution of each diffraction pattern based on the signal-to-noise ratio.  Lattices not conforming to the Bravais symmetry of the scaling reference are rejected.  By default non-isomorphous lattices with cell lengths differing by more than 10% in length from the mean, or 2° in the angles are also rejected, as are lattices that correlate poorly with the scaling reference.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;cxi.merge&#039;&#039; may take several passes over the integrated images.  In order to speed up processing, &#039;&#039;cxi.merge&#039;&#039; will write the scaled data to a back  end database during each pass.  Currently three database back ends are implemented.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;FS&amp;lt;/code&amp;gt; is the simplest back end.  It stores the scaled intensities, their Miller indices, and information about the shots they were observed during in three flat files on the file system.&lt;br /&gt;
&lt;br /&gt;
* The &amp;lt;code&amp;gt;MySQL&amp;lt;/code&amp;gt; back end stores data in a MySQL database.  The database must be set up beforehand, and credentials to access it must be supplied in the parameters passed to &#039;&#039;cxi.merge&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* The &amp;lt;code&amp;gt;SQLite&amp;lt;/code&amp;gt; back end uses a simple SQLite database, which is written to a single file on the file system.  It is easier to use than the &amp;lt;code&amp;gt;MySQL&amp;lt;/code&amp;gt; back end and more efficient than the &amp;lt;code&amp;gt;FS&amp;lt;/code&amp;gt; backend.  Regrettably, the &amp;lt;code&amp;gt;SQLite&amp;lt;/code&amp;gt; back end does not appear to work on the Lustre file system.&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;cctbx.xfel&#039;&#039; images are merged using the &amp;lt;code&amp;gt;cxi.merge&amp;lt;/code&amp;gt; command.  &amp;lt;code&amp;gt;cxi.merge&amp;lt;/code&amp;gt; accepts several options which can conveniently be assembled in a &#039;&#039;phil&#039;&#039; file.  In this tutorial only a subset of the available options are defined.&lt;br /&gt;
&lt;br /&gt;
; backend&lt;br /&gt;
: Back end database; &amp;lt;code&amp;gt;FS&amp;lt;/code&amp;gt; for flat-file ASCII data storage, &amp;lt;code&amp;gt;MySQL&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SQLite&amp;lt;/code&amp;gt; for the respective proper database back ends.  &lt;br /&gt;
; d_min&lt;br /&gt;
: Limiting resolution for scaling and merging&lt;br /&gt;
; data&lt;br /&gt;
: Directory containing integrated data in pickle format.  Repeat to specify additional directories.&lt;br /&gt;
; merge_anomalous&lt;br /&gt;
: &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; to merge anomalous contributors (&#039;&#039;i.e.&#039;&#039; Bijvoet mates), &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt; to preserve them&lt;br /&gt;
; min_corr&lt;br /&gt;
: Correlation cutoff for rejecting individual frames&lt;br /&gt;
; model&lt;br /&gt;
: The scaling reference, PDB filename containing atomic coordinates and isomorphous &amp;lt;code&amp;gt;CRYST1&amp;lt;/code&amp;gt; record.  Note:  quick command to download a pdb file from the Internet is: &amp;lt;code&amp;gt; phenix.fetch_pdb [pdb_code]&amp;lt;/code&amp;gt;&lt;br /&gt;
; nproc&lt;br /&gt;
: Specifies the number of scaling processes &#039;&#039;cxi.merge&#039;&#039; may have running at any one time&lt;br /&gt;
; output.prefix&lt;br /&gt;
: Prefix for all output file names&lt;br /&gt;
; rawdata.sdfac_auto&lt;br /&gt;
: &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; to apply &amp;lt;code&amp;gt;SDFAC&amp;lt;/code&amp;gt; correction to each image, assuming negative intensities are normally distributed noise&lt;br /&gt;
; rescale_with_average_cell&lt;br /&gt;
: Rescale the images a second time, requiring images to conform to the average unit cell.  If set to &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;set_average_unit_cell&amp;lt;/code&amp;gt; must also be set to &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt;.&lt;br /&gt;
; set_average_unit_cell&lt;br /&gt;
: If &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; set the unit cell of the merged data to the average of the merged images, otherwise use the unit cell of the scaling reference&lt;br /&gt;
; pixel_size&lt;br /&gt;
: If &amp;lt;code&amp;gt;True&amp;lt;/code&amp;gt; set the pixel size for the detector used, this is a single value (0.11 for CSPad)&lt;br /&gt;
&lt;br /&gt;
The merged data is written to an mtz-file named &amp;lt;code&amp;gt;&amp;lt;i&amp;gt;output.prefix&amp;lt;/i&amp;gt;.mtz&amp;lt;/code&amp;gt;.  Standard output, redirected to &amp;lt;code&amp;gt;merge.out&amp;lt;/code&amp;gt; above, mainly consists of statistics for each individual image as it is scaled.  The output concludes with a section labelled &amp;lt;code&amp;gt;FINISHED MERGING&amp;lt;/code&amp;gt;, which first lists the number of accepted and rejected images,&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 962 of 1185 integration files were accepted&lt;br /&gt;
 127 rejected due to wrong Bravais group&lt;br /&gt;
 1 rejected for unit cell outliers&lt;br /&gt;
 12 rejected for low signal&lt;br /&gt;
 83 rejected due to poor correlation&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This is followed by a histograms of the unit cell distribution, and the merging table:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
---------------------------------------------------------------------------------&lt;br /&gt;
                                     &amp;lt;asu   &amp;lt;obs&lt;br /&gt;
Bin  Resolution Range  Completeness redun&amp;gt; redun&amp;gt; n_meas   &amp;lt;I&amp;gt;    &amp;lt;I/sig(I)&amp;gt;&lt;br /&gt;
---------------------------------------------------------------------------------&lt;br /&gt;
  1 -1.0000 -  6.4633     [306/309]  67.61  68.28  20893    35621    27.044&lt;br /&gt;
  2  6.4633 -  5.1299     [285/285]  43.18  43.18  12305    19272    12.490&lt;br /&gt;
  3  5.1299 -  4.4814     [275/275]  46.77  46.77  12862    24391    14.261&lt;br /&gt;
  4  4.4814 -  4.0716     [269/269]  43.38  43.38  11670    29436    14.819&lt;br /&gt;
  5  4.0716 -  3.7798     [249/249]  35.50  35.50   8840    29811    12.716&lt;br /&gt;
  6  3.7798 -  3.5569     [267/267]  32.07  32.07   8562    24212    10.523&lt;br /&gt;
  7  3.5569 -  3.3787     [274/274]  20.99  20.99   5750    23626     8.171&lt;br /&gt;
  8  3.3787 -  3.2317     [256/256]  15.96  15.96   4085    24168     6.746&lt;br /&gt;
  9  3.2317 -  3.1072     [263/264]  12.16  12.20   3209    23936     5.859&lt;br /&gt;
 10  3.1072 -  3.0000     [263/263]   8.74   8.74   2298    20613     4.556&lt;br /&gt;
&lt;br /&gt;
All                     [2707/2711]  33.37  33.42  90474    25594    11.978&lt;br /&gt;
----------------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this case, the overall completeness to 3.0 Å is 2,707 / 2,711, or approximately 100%, and each observed reflection is measured 33.42 times on average (&amp;lt;code&amp;gt;&amp;lt;obs redun&amp;gt;&amp;lt;/code&amp;gt;).  In total 90,474 observations, with an average scaled and integrated intensity of 25,594 analog-to-digital units (ADU), were merged and the mean &amp;lt;i&amp;gt;I&amp;lt;/i&amp;gt; / σ(&amp;lt;i&amp;gt;I&amp;lt;/i&amp;gt;) was determined to be 11.978.&lt;br /&gt;
&lt;br /&gt;
== Additional merging statistics ==&lt;br /&gt;
&#039;&#039;cxi.xmerge&#039;&#039; retrieves the scaled, unmerged intensities from the database back end, and calculates the &amp;lt;i&amp;gt;CC&amp;lt;/i&amp;gt;&amp;lt;sub&amp;gt;1/2&amp;lt;/sub&amp;gt;&amp;lt;ref&amp;gt;[http://dx.doi.org/10.1126/science.1218231 Karplus, P. A. &amp;amp; Diederichs, K. Linking Crystallographic Model and Data Quality. &amp;lt;i&amp;gt;Science&amp;lt;/i&amp;gt; &amp;lt;b&amp;gt;336&amp;lt;/b&amp;gt;, 1030–1033 (2012).]&amp;lt;/ref&amp;gt; and &amp;lt;i&amp;gt;CC&amp;lt;/i&amp;gt;&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; statistics.  &amp;lt;i&amp;gt;CC&amp;lt;/i&amp;gt;&amp;lt;sub&amp;gt;1/2&amp;lt;/sub&amp;gt; is defined as Pearson&#039;s correlation coefficient between two sets, such that for each ￼unique reflection the average intensities of two randomly chosen halves of its ￼independent observations are assigned to different set.  &amp;lt;i&amp;gt;CC&amp;lt;/i&amp;gt;&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; is the correlation coefficient between the merged data and the isomorphous scaling reference.  Both statistics are computed in each resolution bin, as well as for the full set of reflections.&lt;br /&gt;
&lt;br /&gt;
Once the database has been populated using &#039;&#039;cxi.merge&#039;&#039;, &#039;&#039;cxi.xmerge&#039;&#039; can be run, using the parameters defined in a &#039;&#039;phil&#039;&#039;-file, &amp;lt;code&amp;gt;Ls-04-lysozyme-xmerge.phil&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;$ cxi.xmerge Ls04-lysozyme-xmerge.phil&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The options used in this tutorial not already described in [[#Merging a set of integration files|Merging a set of integration files]] are explained below.&lt;br /&gt;
; scaling.mtz_file&lt;br /&gt;
: mtz-file containing experimentally determined reference structure factors, such as synchrotron measurements, to be used for CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt;.  Experimental measurements, when available, can be downloaded from the PDB using &amp;lt;code&amp;gt;phenix.fetch_pdb –-mtz [pdb_code]&amp;lt;/code&amp;gt;. &lt;br /&gt;
; scaling.mtz_column_F&lt;br /&gt;
: In the experimental measurements mtz-file, the column name containing the reference data; can be either amplitudes or intensities.  The column name should be given &#039;&#039;&#039;in lower case&#039;&#039;&#039;. An MTZ-format file can be inspected to see which columns it contains with &amp;lt;code&amp;gt;phenix.mtz.dump [code].mtz&amp;lt;/code&amp;gt;.  Quick tip:  if experimental measurements are unavailable, mock experimental structure factors can be generated with &amp;lt;br&amp;gt;&amp;lt;code&amp;gt;phenix.fmodel &amp;lt;pdb file&amp;gt; high_resolution=&amp;lt;value&amp;gt; output.type=real&amp;lt;/code&amp;gt; in which case one would use &amp;lt;code&amp;gt;scaling.mtz_column_F=fmodel&amp;lt;/code&amp;gt;.&lt;br /&gt;
; scaling.log_cutoff&lt;br /&gt;
: Intensities less than &amp;lt;i&amp;gt;e&amp;lt;/i&amp;gt;&amp;lt;sup&amp;gt;&amp;lt;code&amp;gt;scaling.log_cutoff&amp;lt;/code&amp;gt;&amp;lt;/sup&amp;gt; will not be included in  the calculation of CC&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; and R&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; (however, these measurements will still be included in the final merged data). &lt;br /&gt;
&lt;br /&gt;
The results are printed on standard output and conclude with a table including the &amp;lt;i&amp;gt;CC&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
---------------------------------------------------------------------------------------&lt;br /&gt;
                                      CC            CC            R     R   Scale Scale&lt;br /&gt;
Bin  Resolution Range  Completeness  int     N     iso     N     int   iso   int   iso&lt;br /&gt;
---------------------------------------------------------------------------------------&lt;br /&gt;
  1 -1.0000 -  6.4633     [233/309] 45.1%     233 56.3%     142 57.5% 45.6% 0.749 3.084&lt;br /&gt;
  2  6.4633 -  5.1299     [184/285] 22.5%     184 56.7%      62 57.2% 31.5% 0.862 2.841&lt;br /&gt;
  3  5.1299 -  4.4814     [203/275] 43.7%     203 57.6%      85 55.3% 37.0% 0.830 2.977&lt;br /&gt;
  4  4.4814 -  4.0716     [220/269] 39.0%     220 59.7%     101 51.4% 30.3% 0.805 3.296&lt;br /&gt;
  5  4.0716 -  3.7798     [187/249] 77.5%     187 33.6%      63 54.3% 39.4% 0.775 4.243&lt;br /&gt;
  6  3.7798 -  3.5569     [198/267] 35.4%     198 47.2%      56 56.8% 27.5% 0.903 3.587&lt;br /&gt;
  7  3.5569 -  3.3787     [198/274] 32.0%     198 70.7%      40 59.9% 31.4% 0.814 3.846&lt;br /&gt;
  8  3.3787 -  3.2317     [163/256] 30.6%     163 24.5%      28 63.9% 49.1% 0.734 4.278&lt;br /&gt;
  9  3.2317 -  3.1072     [164/264] 40.6%     164 53.6%       7 80.4% 32.1% 0.622 5.543&lt;br /&gt;
 10  3.1072 -  3.0000     [137/261]  8.2%     137 93.9%       5 85.6% 33.4% 0.221 4.372&lt;br /&gt;
&lt;br /&gt;
All                                 34.7%    1887 47.7%     589 62.5% 39.5% 0.754 3.157&lt;br /&gt;
---------------------------------------------------------------------------------------&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this case the overall &amp;lt;i&amp;gt;CC&amp;lt;/i&amp;gt;&amp;lt;sub&amp;gt;1/2&amp;lt;/sub&amp;gt; (&amp;lt;code&amp;gt;CC int&amp;lt;/code&amp;gt;) is 34.7%, and the correlation coefficient to the isomorphous reference, &amp;lt;i&amp;gt;CC&amp;lt;/i&amp;gt;&amp;lt;sub&amp;gt;iso&amp;lt;/sub&amp;gt; (&amp;lt;code&amp;gt;CC iso&amp;lt;/code&amp;gt;) is 47.7%.&lt;br /&gt;
Note that the completeness for the cxi.xmerge output appears lower than that for the cxi.merge output. This is because the cxi.xmerge final table shows the completeness for the data used in the calculation of correlation coefficients, and so the completeness in the previous table should be used for general statistics.&lt;br /&gt;
&lt;br /&gt;
== Merging the tutorial data ==&lt;br /&gt;
&lt;br /&gt;
Compared to indexing and integration, merging is a relatively quick procedure.  However, particularly for large datasets, it may significantly strain computational resources.  Therefore, it is recommended to merge data on SLAC&#039;s interactive nodes.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ssh psanacs.slac.stanford.edu&lt;br /&gt;
$ cd myrelease&lt;br /&gt;
$ cp /reg/g/cctbx/tutorials/merging/Ls04-lysozyme-*merge.phil .&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Before running the merging programs, the &#039;&#039;phil&#039;&#039;-files may need to be edited.  In particular, the location of the directories containing pickle files with the integrated intensities may need to be adjusted.  Since both &amp;lt;code&amp;gt;cxi.merge&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;cxi.xmerge&amp;lt;/code&amp;gt; log to standard output, it is advisable to redirect the stream to a file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cxi.merge Ls04-lysozyme-merge.phil &amp;gt; merge.out&lt;br /&gt;
$ cxi.xmerge Ls04-lysozyme-xmerge.phil &amp;gt; xmerge.out&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The merged reflections, suitable for further processing, are written &amp;lt;code&amp;gt;Ls04-lysozyme.mtz&amp;lt;/code&amp;gt;. Note that although the data for this tutorial extends to 2.2 Å, the statistics become exceedingly poor around 3.0 Å.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
	<entry>
		<id>http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=839</id>
		<title>Gd-Lysozyme</title>
		<link rel="alternate" type="text/html" href="http://viper.lbl.gov:8080/cctbx.xfel/index.php?title=Gd-Lysozyme&amp;diff=839"/>
		<updated>2014-09-29T22:09:15Z</updated>

		<summary type="html">&lt;p&gt;Tara: /* Integrate the data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In this tutorial, we assume that we are handed an SFX dataset containing Lysozyme diffraction, but are not told anything else.  We will have to go through all the data runs, figure out which one is to be used for dark subtraction, and account for untrusted pixels and detector metrology.  At this point, we will be prepared to integrate and merge the data.  Finally, we will perform simple molecular replacement and ask whether there is any Gd signal in the anomalous difference Fourier. &lt;br /&gt;
&lt;br /&gt;
=Discovery of data collection parameters=&lt;br /&gt;
Log in to pslogin.slac.stanford.edu, and then to psana.  Carry through flags so that X-windows will work&lt;br /&gt;
&lt;br /&gt;
 ssh -YAC $USER@pslogin.slac.stanford.edu&lt;br /&gt;
 ssh -YAC psana&lt;br /&gt;
&lt;br /&gt;
Go in to the working directory and source the package manager:&lt;br /&gt;
&lt;br /&gt;
 cd ~/myrelease&lt;br /&gt;
 sit_setup&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory for the 2014 tutorial files if not already done:&lt;br /&gt;
 mkdir -p cxi84914&lt;br /&gt;
&lt;br /&gt;
List out the Gd-Lysozyme XTC files (this could take time since there are many images):&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e239&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/xtc/e240&lt;br /&gt;
&lt;br /&gt;
Notice that there are numerous runs in the directory.  Now we will create composite averages for each run.  Grab this configuration file: [[mkdark_Gd-Lysozyme.cfg]] and put it in your cxi84914 directory.  For one run only from each experiment directory:&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r 16 -t 0&lt;br /&gt;
&lt;br /&gt;
 cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
 -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r 16 -t 0&lt;br /&gt;
Take note:&lt;br /&gt;
* -c configuration file&lt;br /&gt;
* -o output directory (will be created)&lt;br /&gt;
* -i input files (directory containing the XTC streams)&lt;br /&gt;
* -q which batch queue to use&lt;br /&gt;
* -s funnel all streams for the run into one node (takes longer, but necessary for averaging)&lt;br /&gt;
* -p number of cores to use on the node&lt;br /&gt;
* -x which experiment number&lt;br /&gt;
* -r which run number&lt;br /&gt;
* -t which processing trial (auto increments from 0 if not given)&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 239:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 27 28 29 30 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
For all the runs in the Gd-Lysozyme data set 240:&lt;br /&gt;
 kinit&lt;br /&gt;
 aklog&lt;br /&gt;
 for m in 1 2 3 4 5 6 7 8 9 10 12 13 14 16 17 18 19 21 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkdark_Gd-Lysozyme.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bjobs lists all your batch jobs; use this form for more information including other-user load:&lt;br /&gt;
 bjobs -w -u all -q psanacsq&lt;br /&gt;
 bkill [number] # stops unwanted job&lt;br /&gt;
&lt;br /&gt;
Some runs take up to 2 hrs wall time to average.  Find the averages, view the max-composites, and list out header information for each experiment separately and create a table of the results:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 239:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456955&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569557&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569529&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The next Gd-Lysozyme experiment:&lt;br /&gt;
 ls /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000/out/*.pickle&lt;br /&gt;
 cctbx.image_viewer `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`&lt;br /&gt;
 for m in `find /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r*/000 -name &amp;quot;max*.pickle&amp;quot;`; &lt;br /&gt;
  do echo $m; cxi.print_pickle $m; echo; done&lt;br /&gt;
&lt;br /&gt;
Let&#039;s make a table of the results for experiment 240:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; &lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Run&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Distance&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Wavelength&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Diffraction&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| Comments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 156.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.145418&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 2&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 101.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454165&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 3&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 4&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 5&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454175&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 6&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 7&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.454176&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 8&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 97.735&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.453730&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 9&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 171.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569401&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 10&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 12&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45695&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;|&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 13&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45815&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 14&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456952&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 16&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.45697&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 17&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.457426&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 18&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.467101&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 19&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 21&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456949&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 24&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456950&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 25&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456958&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 26&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569358&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 27&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569524&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 28&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456964&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| very weak powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 29&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4570738&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 30&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569528&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| saturated spots&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 31&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569488&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| dark&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 32&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456953&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 33&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569476&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 34&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 35&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456966&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 36&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.456948&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 37&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4573264&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 38&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569576&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 39&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569520&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 40&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 81.0&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| 1.4569505&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| strong powder&lt;br /&gt;
| style=&amp;quot;padding: 2px;&amp;quot;| &lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Some conclusions: &lt;br /&gt;
&lt;br /&gt;
* Run 30 was the dark run for experiment 239.  We&#039;ll use the average and standard deviation for further processing.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/avg-r0030.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e239/r0030/000/out/stddev-r0030.pickle&lt;br /&gt;
&lt;br /&gt;
* Runs 1, 8, 13 and 31 were dark runs for experiment 240.  We will discard runs 1 and 8 since the detector distances are unique and would require separate detector calibration. Either run 13 or 31 will work so we&#039;ll use the average and standard deviation of run 31 for further processing of experiment 240.  Tutorial students can take result from the instructor&#039;s directory:&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/avg-r0031.pickle&lt;br /&gt;
 /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/initial_dark/e240/r0031/000/out/stddev-r0031.pickle&lt;br /&gt;
&lt;br /&gt;
* We are interested in getting the Gd anomalous signal from lysozyme, runs were collected at the far remote for f&amp;amp;rdquo; at approximately 8500 eV or 1.457 Angstroms.  See the [http://skuld.bmsc.washington.edu  X-ray Anomalous Scattering].&lt;br /&gt;
&lt;br /&gt;
* We&#039;ll accept runs 27-29 and 31 (&amp;quot;calibration27&amp;quot;) for experiment 239, and in experiment 240 runs 3-7, 10, 11, 14-19, 23-30 and 32-40 (&amp;quot;calibration3&amp;quot;). We&#039;ll also discard run 9 of experiment 240 as the diffraction was relatively weak and the unique detector distance would require separate detector calibration.&lt;br /&gt;
&lt;br /&gt;
=Prepare to mask out the untrusted pixels=&lt;br /&gt;
We&#039;ll now calculate dark-subtracted averages for experiment 239.  &lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e239.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -s -p 8 -x 239 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 30 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e239.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1150 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 15 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 15 --avg_max 1150 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/avg-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e239/r0030/000/out/stddev-r0030.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0027/000/out/max-r0027.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity. &lt;br /&gt;
&lt;br /&gt;
Now We need to repeat the procedure above to calculate dark-subtracted averages for experiment 240.  &lt;br /&gt;
 for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 23 24 25 26 27 28 29 20 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/mkavg_e240.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -s -p 8 -x 240 -r ${m} -t 0; done&lt;br /&gt;
&lt;br /&gt;
This repeats exactly the same averaging calculations as before, except the dark average from run 31 is subtracted.  &lt;br /&gt;
The dark image to be subtracted (along with its std deviation) is defined in the configuration file [[mkavg_e240.cfg]].&lt;br /&gt;
&lt;br /&gt;
Now we&#039;ll figure out which pixels are untrusted, and thus should not be integrated.  Three criteria will be used:&lt;br /&gt;
* Hot pixels--on the average-dark the pixel values exceed 1250 (should be fine tuned by inspecting the dark &amp;amp; using trial and error)&lt;br /&gt;
* Hot pixels--on the standard deviation-dark the stddev exceeds 4 and therefore unreliable (also should be fine tuned by trial and error)&lt;br /&gt;
* Cold pixels or shadows--on a maximum-composite data image, inspect values and set a minimum threshold value (we choose 14 here)&lt;br /&gt;
For more information on masking parameters see [[Preparatory_steps|creating a mask image]]&lt;br /&gt;
&lt;br /&gt;
 cxi.make_mask -v --maxproj_min 14 --avg_max 1250 --stddev_max 4 --output mask_base.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/avg-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/initial_dark/e240/r0031/000/out/stddev-r0031.pickle \&lt;br /&gt;
  /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0018/000/out/max-r0018.pickle&lt;br /&gt;
&lt;br /&gt;
Inspect the mask:&lt;br /&gt;
 cctbx.image_viewer mask_base.pickle show_untrusted=true&lt;br /&gt;
&lt;br /&gt;
Non-bonded pixels are masked and untrusted regions of high and low/negative intensity.&lt;br /&gt;
&lt;br /&gt;
=Correct the detector metrology=&lt;br /&gt;
Accurate data integration requires highly precise knowledge of pixel positions in laboratory space (metrology).  Gaining this knowledge is especially difficult due to the [[CSPAD Pattern | segmented nature of the CSPAD detector]], which is tiled into 64 application-specific integrated circuits (ASICs).  The 64 ASICs are arranged in quadrants that are approximately 4-fold rotationally symmetric, with 8 sensors per quadrant and 2 ASICs per sensor.   The sensors are field-serviceable, and may therefore change from Run to Run.     &lt;br /&gt;
&lt;br /&gt;
We thus need to determine positions and rotations for all 64 tiles, ideally down to an accuracy on order of 10 microns. As a general overview, cctbx takes the following steps:&lt;br /&gt;
&lt;br /&gt;
* Tile placement in physical space is measured by the beamline operators optically using electron microscopy.  This is done at the per-sensor level (2 ASICs per sensor).  This is already hard-coded; nothing for the user to do.&lt;br /&gt;
&lt;br /&gt;
* Relative positions of the quadrants are determined coarsely by considering powder rings.  &lt;br /&gt;
&lt;br /&gt;
* Sensor positions are refined based on Bragg spot diffraction, allowing for whole-pixel translations in x and y.&lt;br /&gt;
&lt;br /&gt;
* ASIC positions are refined to subpixel accuracy based on Bragg diffraction, allow for sub-pixel translations and rotations.&lt;br /&gt;
&lt;br /&gt;
==Quadrant positions==&lt;br /&gt;
The electron microscopy step above determines only the sensor positions relative to the frames of reference of each quadrant; but not the absolute position of each quadrant in space.  At the CXI instrument, the forward detector DS1 has rail-mounted quadrants to allow re-sizing of the central hole.  The quadrant placement should be assessed for both the forward and back (DS2) detectors.  &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=tmmclark).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,-6,-7,0,-1,-4).  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 27, 29 and 31:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -9, 2, 0, -4] (poor self correlation value approx. 0.06 weak powder diffraction for this run)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 5, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e239/r0028/000/out/max-r0028.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations=2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. From the GUI it also appears that distance=81 fits; meaning that the detz_offset for the configuration file of 571 is ok.&lt;br /&gt;
&lt;br /&gt;
Now we need to check e240: &lt;br /&gt;
&lt;br /&gt;
For lysozyme we examine one of the strong images (maximum composite).  Students may use the instructor&#039;s files ($USER=nksauter).  We first determine that our image has a timestamp that identifies it within cctbx as being from run 7 (2013):&lt;br /&gt;
&lt;br /&gt;
 cxi.print_pickle /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle &lt;br /&gt;
  &amp;gt; Detector format version: CXI 7.1&lt;br /&gt;
 cxi.detector_format_versions&lt;br /&gt;
 cxi.detector_format_versions &amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0019/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;Settings&amp;quot; GUI panel shows detector distance as well as the hard-coded quadrant positions corresponding to &amp;quot;CXI 7.1&amp;quot;, namely [2, -6, 3, -6, -7, 0, -1, -4]. Tile translations have been zeroed out in the code. The settings can be changed in the panel, or alternately given as a separate command line parameter (distl.quad_translations=2,-6,3,6,-7,0,-1,-4.  The object is to align the powder pattern with the predicted rings (red circles) based on the unit cell parameters.  It can be seen that the alignment is not quite perfect.&lt;br /&gt;
&lt;br /&gt;
Since we have well-formed powder rings, we can run the automatic quadrant positioning tool:&lt;br /&gt;
&lt;br /&gt;
 cspad.quadrants /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot;&lt;br /&gt;
 &amp;gt; The NEW QUAD translations are:  [2, -6, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
Try a few different max-composites from runs 3, 7, 17, 27:&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -3]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [2, -5, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [19, -6, 3, -6, -11, 11, 1, -1] (very poor self-correlation coefficient around 0.06 run 17 is weak powder and not a good run to use for the metrology)&lt;br /&gt;
&lt;br /&gt;
The NEW QUAD translations are: [3, -4, 4, -6, -6, 1, 0, -4]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These can be pasted on to the command line for graphical review:&lt;br /&gt;
 cxi.view /reg/d/psdm/cxi/cxi84914/scratch/$USER/averages/e240/r0029/000/out/max-r0029.pickle \&lt;br /&gt;
  distl.detector_format_version=&amp;quot;CXI 7.1&amp;quot; viewer.calibrate_unitcell.d_min=10 \&lt;br /&gt;
  viewer.calibrate_unitcell.unitcell=79,79,38,90,90,90 viewer.calibrate_unitcell.spacegroup=P43212\&lt;br /&gt;
  distl.quad_translations= 2, -6, 4, -6, -6, 1, 0, -4&lt;br /&gt;
&lt;br /&gt;
This looks slightly better. We will continue in the next section to test the distance and find the best value.&lt;br /&gt;
&lt;br /&gt;
==Data Discovery Phase==&lt;br /&gt;
Before we can move forward with metrology on the pixel and sub pixel level, we must test if the data can be indexed and index a test image. Beginning with e239 we will choose run 27 and run hit finding and dump the images for trial 0. The configuration file [[Gd-Lysozyme-27_discover.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t000.phil]] (t000 means trial 0)] for trial 0 we comment out the target cell and setting. Modules that are commented out in the config file can be uncommented for indexing once we discover the correct parameters.&lt;br /&gt;
&lt;br /&gt;
  cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /path to home/myrelease/cxi84914/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 0&lt;br /&gt;
&lt;br /&gt;
Nothing can progress until we successfully index an image.&lt;br /&gt;
The next steps involve adjusting the configuration file so that we can just look the images and find one that should index. First we make a new configuration file that just does a hit find and a raw image dump and examine images to find one with &amp;quot;good&amp;quot; diffraction. We choose the s00 stream as this will give a thin slice of the entire run and we can examine all images from this run using the command:&lt;br /&gt;
&lt;br /&gt;
  cctbx.image_viewer shot-s00-20130315225*&lt;br /&gt;
&lt;br /&gt;
Looking through these images the best is the third image (shot-s00-20130315225354116.pickle). First we check using this image if spot finder has the correct parameters by using the .phil file parameters in image viewer as follows:&lt;br /&gt;
&lt;br /&gt;
  distl.image_viewer distl.minimum_signal_height=5 distal.minimum_spot_height=10 \&lt;br /&gt;
  distal.minimum_spot_area=1 shot-s00-20130315225354116.pickle&lt;br /&gt;
&lt;br /&gt;
The spot_finder is finding the spots correctly so it seems there is another issue. In examine the images it is clear that the water rings are not at the expected resolution of approximately 3.5 angstroms but rather around 1.8 angstroms indicating that the detz_offset is incorrect (way off) and indexing is not going to work until this is fixed.&lt;br /&gt;
&lt;br /&gt;
This brings us to trial 1. The detz_offset is incorrect and we aren&#039;t in the ball park so first we will try a detz_offset = 591 which puts the detector at 100 mm away to make the water rings be closer to a 3.5 angstrom resolution. To do this we edit  [[Gd-Lysozyme-27_discover.cfg]] by uncomment the indexing module (also comment out my_ana_pkg.mod_dump:img_thresh, if you don&#039;t want to dump the raw images a second time) and change detz_offset to 591. Then run the following command:&lt;br /&gt;
 &lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq &lt;br /&gt;
  -p 8 -x 239 -r 27 -t 1&lt;br /&gt;
&lt;br /&gt;
Looking at ~/myrelease/cxi84914/e239/r0027/stdout log file s00.out the unit cell found (86.3581, 86.3581, 42.8606, 90, 90, 90) is not the correct one and many images did not index at all. We need to try to get to a value for detz_offset that is in the correct range. For trial 2 we will use a detz_offset of 581, so the detz_offset in [[Gd-Lysozyme-27_discover.cfg]] is changed t0 581 and we run the following command:&lt;br /&gt;
&lt;br /&gt;
   cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27_discover.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/USERNAME/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r 27 -t 2&lt;br /&gt;
&lt;br /&gt;
Checking the log file the indexed unit cell is (78.1073, 78.1073, 39.1608, 90, 90, 90) which is much closer to what we expect and checking how many indexed images are in r0027/002/out &lt;br /&gt;
  ls -l |wc -1&lt;br /&gt;
counts all files in current directory and we get 188 indexed images out of a total of 303 total images in our image dump of r0027 for trial 0. Before accepting detz_offset of 581 we will try a series of detz_offset values in the range of 575 - 595. Go to your my release in your home directory and create a new directory called diet_trials; cd into it and run this command to create new configuration files with the test detz_offset values. &lt;br /&gt;
  for i in `seq 575 595`; do vi -c &amp;quot;%s/581/$i/g&amp;quot; -c &amp;quot;w Gd-Lysozyme-27_discover0$i.cfg&amp;quot; \&lt;br /&gt;
  -c q\! ../cxi84914/e239/Gd-Lysozyme-27_discover0.cfg ; done&lt;br /&gt;
Here, a vi command is executed repeatedly that searches for the number 581 in your config file and replaces it with a number from 575 to 595, then writes out the new file with an appropriate file name.  If this seems like a poor window to search, note that the number was originally 571, and has already been optimized to 581 through earlier trials.&lt;br /&gt;
&lt;br /&gt;
Next, submit indexing jobs for each candidate detz offset from your myrelease folder:&lt;br /&gt;
&lt;br /&gt;
 for i in `seq 575 595`; do cxi.lsf -c dist_trials/Gd-Lysozyme-27_discover0$i.cfg \&lt;br /&gt;
 -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/ -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -r 27 &lt;br /&gt;
 -q psanacsq -p 8 -t $i; done&lt;br /&gt;
&lt;br /&gt;
When complete, go to your results directory:&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/dist_trials/r0027&lt;br /&gt;
&lt;br /&gt;
Then determine which detz offset is best:&lt;br /&gt;
 for i in `ls`; do echo -n &amp;quot;$i &amp;quot;; ls $i/out | wc -l; done&lt;br /&gt;
Output for r0027:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
detz_offset:        Indexed images:&lt;br /&gt;
575                          80&lt;br /&gt;
576                          98&lt;br /&gt;
577                          120&lt;br /&gt;
578                          153&lt;br /&gt;
579                          182&lt;br /&gt;
580                          185&lt;br /&gt;
581                          187&lt;br /&gt;
582                          159&lt;br /&gt;
583                          154&lt;br /&gt;
584                          142&lt;br /&gt;
585                          120&lt;br /&gt;
586                          116&lt;br /&gt;
587                          103&lt;br /&gt;
588                          85&lt;br /&gt;
589                          81&lt;br /&gt;
590                          68&lt;br /&gt;
591                          64&lt;br /&gt;
592                          58&lt;br /&gt;
593                          60&lt;br /&gt;
594                          53&lt;br /&gt;
595                          50&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The detz_offset of 581 gives the most indexed images. So now we move to the next step in the metrology (unit-pixel tile positions). Testing the detz_offset for e240 for the same range of values yields a detz_offset of 580.&lt;br /&gt;
&lt;br /&gt;
==Unit-pixel tile positions==&lt;br /&gt;
We now know the correct detz_offset (581) and we can change the Gd-Lysozyme-t000.phil file by uncommenting the target unit cell and known setting and change the confif file to only do the indexing and integration with a detz_offset=581. &lt;br /&gt;
Now we will index the data to derive model lattices. The configuration file [[Gd-Lysozyme-27.cfg]] (for configuration run 27) names our phil parameter file [[Gd-Lysozyme-t003.phil]] (t003 means trial 3)].  We&#039;ll then compare model and observation, from which we can deduce better metrology. This will be done for both experiments 239 and 240 separately. &lt;br /&gt;
&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e239/[[Gd-Lysozyme-27.cfg]] \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 3; done&lt;br /&gt;
&lt;br /&gt;
 bkill 0 # stop all jobs; wrong file path&lt;br /&gt;
&lt;br /&gt;
Now for e240 with detz_offset of 580 and a different dark path we need a different config file [[Gd-Lysozyme-3.cfg]] (for configuration run 3) the .phil file for the two experiments is the same in this trial 1. I have separated the configuration and phil files for each experiment in ~/myrelease/cxi84914 by creating e239 and e240 directories to place the files. &lt;br /&gt;
&lt;br /&gt;
   for m in 3 4 5 6 7 10 12 14 15 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
   do echo $m; cxi.lsf -c ~/myrelease/cxi84914/e240/Gd-Lysozyme-3.cfg   \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/tmmclark/results/e240/ -i /reg/d/psdm/cxi/cxi84914/xtc/e240/ \&lt;br /&gt;
  -q psanacsq -p 8 -x 240 -r ${m} -t 1; done&lt;br /&gt;
&lt;br /&gt;
A quick command to count how many integration files there are in e239 and e240:&lt;br /&gt;
&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/*/003/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
 find /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/*/001/integration -name &amp;quot;int*.pickle&amp;quot;|wc -l&lt;br /&gt;
&lt;br /&gt;
We have 6427 and 98808 integrated pickles for e239 and e240 respectively. &lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e239.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/r*/003/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e239 \&lt;br /&gt;
 Gd-Lysozyme-t003.phil | tee Gd-27-t003.unit&lt;br /&gt;
&lt;br /&gt;
Determine whole-pixel translations for all sensors on the CSPAD for e240.  &lt;br /&gt;
 cspad.metrology data=/reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/r*/001/integration \&lt;br /&gt;
 bravais_setting_id=9 max_frames=1000 min_count=25 \&lt;br /&gt;
 detector_format_version=&amp;quot;CXI 7.1&amp;quot; ~/myrelease/cxi84914/e240 \&lt;br /&gt;
 Gd-Lysozyme-t001.phil | tee Gd-27-t001.unit&lt;br /&gt;
&lt;br /&gt;
List out the new unit translations for e239 and e240:&lt;br /&gt;
 cat Gd-27-t003.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
 cat Gd-3-t001.unit |grep -A21 &amp;quot;Unit translations&amp;quot;&lt;br /&gt;
Results from three refinement cycles are listed; capture the last one and incorporate it into a new version of the integration phil file, [[Gd-Lysozyme-t004.phil]].  &lt;br /&gt;
&lt;br /&gt;
Repeat this process for both experiments, incrementing the trial numbers and creating a new trial phil file each time until the unit pixel translations have converged and the rmsd is less than 1 unit pixel. Once the final unit pixel metrology for experiments e239 and e240 is complete, we have 6669 and 99073 integrated pickle files.  &lt;br /&gt;
&lt;br /&gt;
The next step is to incorporate the sub pixel translations and rotations into a new phil file and integrate each experiment once more.&lt;br /&gt;
&lt;br /&gt;
==Add sub-pixel corrections== &lt;br /&gt;
The rmsd is now  on the sub pixel level (less than 0.8 or both e239 and e240).  We&#039;ll leave the unit-translations exactly where they are now. No sub pixel translations were applied to these data, we move to merging, however for this integration round we&#039;ll increase our integration limits to 1.8 Angstroms.&lt;br /&gt;
&lt;br /&gt;
=Integrate the data=&lt;br /&gt;
We&#039;re ready for the final integration trial.  Again edit the configuration file Gd-Lysozyme-27.cfg and Gd-Lysozyme-3.cfg so that they points to the latest phil file, with the converged unit pixel metrologies using .phil files [[Gd-Lysozyme-27-t007.phil]] and  [[Gd-Lysozyme-3-t006.phil]]&lt;br /&gt;
We use the trials from each experiment where the most images were integrated (only difference was e239 was indexed at 1.8 Angstrom resolution and e240 was indexed at 1.9 Angstrom resolution). Start with merging these indexed images first.&lt;br /&gt;
&lt;br /&gt;
 Submit integration jobs:&lt;br /&gt;
 for m in 27 28 29 31; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-27.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e239/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e239 -q psanacsq -p 8 -x 239 -r ${m} -t 7; done&lt;br /&gt;
&lt;br /&gt;
  for m in 3 4 5 6 7 10 12 14 16 17 18 19 21 24 25 26 27 28 29 30 32 33 34 35 36 37 38 39 40; \&lt;br /&gt;
  do echo $m; cxi.lsf -c ~/myrelease/cxi84914/Gd-Lysozyme-3.cfg \&lt;br /&gt;
  -o /reg/d/psdm/cxi/cxi84914/scratch/$USER/results/e240/ \&lt;br /&gt;
  -i /reg/d/psdm/cxi/cxi84914/xtc/e240 -q psanacsq -p 8 -x 239 -r ${m} -t 6; done&lt;br /&gt;
&lt;br /&gt;
This results in 6839 integrated reflection pickles for e239 and      for e240.&lt;br /&gt;
&lt;br /&gt;
=Merge the data=&lt;br /&gt;
We will merge the data as a new structure see [http://viper.lbl.gov/cctbx.xfel/index.php/Advanced_Merging  Advanced Merging Tutorial] in particular use case 2 (new structure).&lt;br /&gt;
&lt;br /&gt;
back to psana.  Get the command file [[mergeLysozyme.csh]]. We are merging all the runs from both experiments. &lt;br /&gt;
&lt;br /&gt;
 mkdir /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 cd /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge&lt;br /&gt;
 ./mergeLysozyme.csh&lt;br /&gt;
&lt;br /&gt;
[[mergeLysozyme.log | Log file]]&lt;br /&gt;
&lt;br /&gt;
=Solve the structure=&lt;br /&gt;
&lt;br /&gt;
Some quick commands to evaluate the data.  Here the result *.mtz files must be moved back to your $HOME directory and transferred to your laptop to run PHENIX:&lt;br /&gt;
&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/e157/thermoanom_2tli_s0_mark0.mtz $HOME&lt;br /&gt;
 cp /reg/d/psdm/cxi/cxi84914/scratch/$USER/merge/e157/thermonoanom_2tli_s0_mark0.mtz $HOME&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;s0&amp;quot; files; &amp;quot;s1&amp;quot; and &amp;quot;s2&amp;quot; are the semi-datasets used only to calculate CC1/2.&lt;br /&gt;
 phenix.fetch_pdb --mtz 2tli&lt;br /&gt;
 phenix.xtriage thermonoanom_2tli_s0_mark0.mtz scaling.input.xray_data.obs_labels=Iobs &amp;gt; triage_noanom.log&lt;br /&gt;
&lt;br /&gt;
Wilson B factor:14.8&lt;br /&gt;
&lt;br /&gt;
 phenix.automr 2tli.pdb thermonoanom_2tli_s0_mark0.mtz seq_file=2tli.fa identity=100 copies=1 build=False&lt;br /&gt;
&lt;br /&gt;
The MR-placed model is in ./AutoMR_run_1_/MR.1.pdb.&lt;br /&gt;
&lt;br /&gt;
Obtain the set of R-free-flags used in the Nature Methods paper&lt;br /&gt;
 wget http://cci.lbl.gov/publications/download/4ow3_original_iobs_flags.mtz&lt;br /&gt;
&lt;br /&gt;
Refine the model&lt;br /&gt;
 phenix.refine ./AutoMR_run_1_/MR.1.pdb refinement.output.prefix=001 \&lt;br /&gt;
  xray_data.file_name=thermonoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags \&lt;br /&gt;
  main.number_of_macro_cycles=6 optimize_xyz_weight=True \&lt;br /&gt;
  optimize_adp_weight=True nproc=20 refinement.input.xray_data.labels=IMEAN \&lt;br /&gt;
  ordered_solvent=true ordered_solvent.mode=every_macro_cycle&lt;br /&gt;
trial 003: RWORK = 23.1% RFREE = 26.5% out to 2.1 Angstrom&lt;br /&gt;
&lt;br /&gt;
trial 005: RWORK = 22.0% RFREE = 26.3% out to 2.1 Angstrom (taking untrusted pixels into account)&lt;br /&gt;
&lt;br /&gt;
Run an ersatz script (provided by Nat Echols) to measure the peak heights of the anomalous scatterers.&lt;br /&gt;
&lt;br /&gt;
 libtbx.python [[map_height_at_atoms.py]] \&lt;br /&gt;
  001_001.pdb thermoanom_2tli_s0_mark0.mtz \&lt;br /&gt;
  input.xray_data.labels=Iobs \&lt;br /&gt;
  xray_data.r_free_flags.file_name=4ow3_original_iobs_flags.mtz \&lt;br /&gt;
  xray_data.r_free_flags.label=R-free-flags&lt;br /&gt;
&lt;br /&gt;
Promising results for the Zn and one Ca:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   5.97 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   0.93 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.74 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.08 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   0.20 sigma&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Better results from trial 005:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
pdb=&amp;quot;ZN    ZN A 317 &amp;quot; :   7.66 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 318 &amp;quot; :   1.10 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 319 &amp;quot; :   2.52 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 320 &amp;quot; :   1.40 sigma&lt;br /&gt;
pdb=&amp;quot;CA    CA A 321 &amp;quot; :   1.01 sigma&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Tara</name></author>
	</entry>
</feed>