Skip to content

Commit

Permalink
htdocs update (master)
Browse files Browse the repository at this point in the history
  • Loading branch information
DiamondLightSource-build-server committed Jun 24, 2024
1 parent 167ed0f commit 00f80ae
Show file tree
Hide file tree
Showing 16 changed files with 1,105 additions and 95 deletions.
36 changes: 32 additions & 4 deletions _modules/dials/algorithms/indexing/indexer.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ <h1>Source code for dials.algorithms.indexing.indexer</h1><div class="highlight"
<span class="kn">import</span> <span class="nn">iotbx.phil</span>
<span class="kn">import</span> <span class="nn">libtbx</span>
<span class="kn">from</span> <span class="nn">cctbx</span> <span class="kn">import</span> <span class="n">sgtbx</span>
<span class="kn">from</span> <span class="nn">dxtbx.model</span> <span class="kn">import</span> <span class="n">ExperimentList</span><span class="p">,</span> <span class="n">ImageSequence</span>
<span class="kn">from</span> <span class="nn">dxtbx.model</span> <span class="kn">import</span> <span class="n">ExperimentList</span><span class="p">,</span> <span class="n">ImageSequence</span><span class="p">,</span> <span class="n">tof_helpers</span>

<span class="kn">import</span> <span class="nn">dials.util</span>
<span class="kn">from</span> <span class="nn">dials.algorithms.indexing</span> <span class="kn">import</span> <span class="p">(</span>
Expand Down Expand Up @@ -931,7 +931,7 @@ <h1>Source code for dials.algorithms.indexing.indexer</h1><div class="highlight"
<span class="n">refined_reflections</span> <span class="o">=</span> <span class="n">reflections</span><span class="o">.</span><span class="n">select</span><span class="p">(</span><span class="n">imgset_sel</span><span class="p">)</span>
<span class="n">panel_numbers</span> <span class="o">=</span> <span class="n">flex</span><span class="o">.</span><span class="n">size_t</span><span class="p">(</span><span class="n">refined_reflections</span><span class="p">[</span><span class="s2">&quot;panel&quot;</span><span class="p">])</span>
<span class="n">xyzcal_mm</span> <span class="o">=</span> <span class="n">refined_reflections</span><span class="p">[</span><span class="s2">&quot;xyzcal.mm&quot;</span><span class="p">]</span>
<span class="n">x_mm</span><span class="p">,</span> <span class="n">y_mm</span><span class="p">,</span> <span class="n">z_rad</span> <span class="o">=</span> <span class="n">xyzcal_mm</span><span class="o">.</span><span class="n">parts</span><span class="p">()</span>
<span class="n">x_mm</span><span class="p">,</span> <span class="n">y_mm</span><span class="p">,</span> <span class="n">z</span> <span class="o">=</span> <span class="n">xyzcal_mm</span><span class="o">.</span><span class="n">parts</span><span class="p">()</span>
<span class="n">xy_cal_mm</span> <span class="o">=</span> <span class="n">flex</span><span class="o">.</span><span class="n">vec2_double</span><span class="p">(</span><span class="n">x_mm</span><span class="p">,</span> <span class="n">y_mm</span><span class="p">)</span>
<span class="n">xy_cal_px</span> <span class="o">=</span> <span class="n">flex</span><span class="o">.</span><span class="n">vec2_double</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">xy_cal_mm</span><span class="p">))</span>
<span class="k">for</span> <span class="n">i_panel</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">expt</span><span class="o">.</span><span class="n">detector</span><span class="p">)):</span>
Expand All @@ -942,10 +942,18 @@ <h1>Source code for dials.algorithms.indexing.indexer</h1><div class="highlight"
<span class="p">)</span>
<span class="n">x_px</span><span class="p">,</span> <span class="n">y_px</span> <span class="o">=</span> <span class="n">xy_cal_px</span><span class="o">.</span><span class="n">parts</span><span class="p">()</span>
<span class="k">if</span> <span class="n">expt</span><span class="o">.</span><span class="n">scan</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">z_px</span> <span class="o">=</span> <span class="n">expt</span><span class="o">.</span><span class="n">scan</span><span class="o">.</span><span class="n">get_array_index_from_angle</span><span class="p">(</span><span class="n">z_rad</span><span class="p">,</span> <span class="n">deg</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="k">if</span> <span class="n">expt</span><span class="o">.</span><span class="n">scan</span><span class="o">.</span><span class="n">has_property</span><span class="p">(</span><span class="s2">&quot;time_of_flight&quot;</span><span class="p">):</span>
<span class="n">tof</span> <span class="o">=</span> <span class="n">expt</span><span class="o">.</span><span class="n">scan</span><span class="o">.</span><span class="n">get_property</span><span class="p">(</span><span class="s2">&quot;time_of_flight&quot;</span><span class="p">)</span>
<span class="n">frames</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">tof</span><span class="p">)))</span>
<span class="n">tof_to_frame</span> <span class="o">=</span> <span class="n">tof_helpers</span><span class="o">.</span><span class="n">tof_to_frame_interpolator</span><span class="p">(</span><span class="n">tof</span><span class="p">,</span> <span class="n">frames</span><span class="p">)</span>
<span class="n">z</span><span class="o">.</span><span class="n">set_selected</span><span class="p">(</span><span class="n">z</span> <span class="o">&lt;</span> <span class="nb">min</span><span class="p">(</span><span class="n">tof</span><span class="p">),</span> <span class="nb">min</span><span class="p">(</span><span class="n">tof</span><span class="p">))</span>
<span class="n">z</span><span class="o">.</span><span class="n">set_selected</span><span class="p">(</span><span class="n">z</span> <span class="o">&gt;</span> <span class="nb">max</span><span class="p">(</span><span class="n">tof</span><span class="p">),</span> <span class="nb">max</span><span class="p">(</span><span class="n">tof</span><span class="p">))</span>
<span class="n">z_px</span> <span class="o">=</span> <span class="n">flex</span><span class="o">.</span><span class="n">double</span><span class="p">(</span><span class="n">tof_to_frame</span><span class="p">(</span><span class="n">z</span><span class="p">))</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">z_px</span> <span class="o">=</span> <span class="n">expt</span><span class="o">.</span><span class="n">scan</span><span class="o">.</span><span class="n">get_array_index_from_angle</span><span class="p">(</span><span class="n">z</span><span class="p">,</span> <span class="n">deg</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="c1"># must be a still image, z centroid not meaningful</span>
<span class="n">z_px</span> <span class="o">=</span> <span class="n">z_rad</span>
<span class="n">z_px</span> <span class="o">=</span> <span class="n">z</span>
<span class="n">xyzcal_px</span> <span class="o">=</span> <span class="n">flex</span><span class="o">.</span><span class="n">vec3_double</span><span class="p">(</span><span class="n">x_px</span><span class="p">,</span> <span class="n">y_px</span><span class="p">,</span> <span class="n">z_px</span><span class="p">)</span>
<span class="n">reflections</span><span class="p">[</span><span class="s2">&quot;xyzcal.px&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">set_selected</span><span class="p">(</span><span class="n">imgset_sel</span><span class="p">,</span> <span class="n">xyzcal_px</span><span class="p">)</span>

Expand Down Expand Up @@ -1004,6 +1012,25 @@ <h1>Source code for dials.algorithms.indexing.indexer</h1><div class="highlight"
<span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="o">.</span><span class="n">max_cell</span> <span class="o">=</span> <span class="n">params</span><span class="o">.</span><span class="n">multiplier</span> <span class="o">*</span> <span class="nb">max</span><span class="p">(</span><span class="n">uc_params</span><span class="p">[:</span><span class="mi">3</span><span class="p">])</span>
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">&quot;Using max_cell: </span><span class="si">%.1f</span><span class="s2"> Angstrom&quot;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="o">.</span><span class="n">max_cell</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>

<span class="n">convert_reflections_z_to_deg</span> <span class="o">=</span> <span class="kc">True</span>
<span class="n">all_tof_experiments</span> <span class="o">=</span> <span class="kc">False</span>
<span class="k">for</span> <span class="n">expt</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">experiments</span><span class="p">:</span>
<span class="k">if</span> <span class="n">expt</span><span class="o">.</span><span class="n">scan</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">and</span> <span class="n">expt</span><span class="o">.</span><span class="n">scan</span><span class="o">.</span><span class="n">has_property</span><span class="p">(</span>
<span class="s2">&quot;time_of_flight&quot;</span>
<span class="p">):</span>
<span class="n">all_tof_experiments</span> <span class="o">=</span> <span class="kc">True</span>
<span class="k">elif</span> <span class="n">all_tof_experiments</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
<span class="s2">&quot;Cannot find max cell for ToF and non-ToF experiments at the same time&quot;</span>
<span class="p">)</span>

<span class="k">if</span> <span class="n">all_tof_experiments</span><span class="p">:</span>
<span class="k">if</span> <span class="n">params</span><span class="o">.</span><span class="n">step_size</span> <span class="o">&lt;</span> <span class="mi">100</span><span class="p">:</span>
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">&quot;Setting default ToF step size to 500 usec&quot;</span><span class="p">)</span>
<span class="n">params</span><span class="o">.</span><span class="n">step_size</span> <span class="o">=</span> <span class="mi">500</span>
<span class="n">convert_reflections_z_to_deg</span> <span class="o">=</span> <span class="kc">False</span>

<span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="o">.</span><span class="n">max_cell</span> <span class="o">=</span> <span class="n">find_max_cell</span><span class="p">(</span>
<span class="bp">self</span><span class="o">.</span><span class="n">reflections</span><span class="p">,</span>
<span class="n">max_cell_multiplier</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">multiplier</span><span class="p">,</span>
Expand All @@ -1015,6 +1042,7 @@ <h1>Source code for dials.algorithms.indexing.indexer</h1><div class="highlight"
<span class="n">filter_ice</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">filter_ice</span><span class="p">,</span>
<span class="n">filter_overlaps</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">filter_overlaps</span><span class="p">,</span>
<span class="n">overlaps_border</span><span class="o">=</span><span class="n">params</span><span class="o">.</span><span class="n">overlaps_border</span><span class="p">,</span>
<span class="n">convert_reflections_z_to_deg</span><span class="o">=</span><span class="n">convert_reflections_z_to_deg</span><span class="p">,</span>
<span class="p">)</span><span class="o">.</span><span class="n">max_cell</span>
<span class="n">logger</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">&quot;Found max_cell: </span><span class="si">%.1f</span><span class="s2"> Angstrom&quot;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">params</span><span class="o">.</span><span class="n">max_cell</span><span class="p">)</span></div>

Expand Down
2 changes: 2 additions & 0 deletions _modules/dials/algorithms/indexing/max_cell.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ <h1>Source code for dials.algorithms.indexing.max_cell</h1><div class="highlight
<span class="n">filter_ice</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
<span class="n">filter_overlaps</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
<span class="n">overlaps_border</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span>
<span class="n">convert_reflections_z_to_deg</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
<span class="p">):</span>
<span class="n">logger</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;Finding suitable max_cell based on </span><span class="si">%i</span><span class="s2"> reflections&quot;</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">reflections</span><span class="p">))</span>
<span class="c1"># Exclude potential ice-ring spots from nearest neighbour analysis if needed</span>
Expand Down Expand Up @@ -109,6 +110,7 @@ <h1>Source code for dials.algorithms.indexing.max_cell</h1><div class="highlight
<span class="n">percentile</span><span class="o">=</span><span class="n">nearest_neighbor_percentile</span><span class="p">,</span>
<span class="n">histogram_binning</span><span class="o">=</span><span class="n">histogram_binning</span><span class="p">,</span>
<span class="n">nn_per_bin</span><span class="o">=</span><span class="n">nn_per_bin</span><span class="p">,</span>
<span class="n">convert_reflections_z_to_deg</span><span class="o">=</span><span class="n">convert_reflections_z_to_deg</span><span class="p">,</span>
<span class="p">)</span>
<span class="k">except</span> <span class="ne">AssertionError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">DialsIndexError</span><span class="p">(</span><span class="s2">&quot;Failure in nearest neighbour analysis:</span><span class="se">\n</span><span class="s2">&quot;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
Expand Down
4 changes: 2 additions & 2 deletions _modules/dials/algorithms/indexing/model_evaluation.html
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ <h1>Source code for dials.algorithms.indexing.model_evaluation</h1><div class="h
<span class="k">def</span> <span class="nf">score_by_rmsd_xy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">reverse</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
<span class="c1"># smaller rmsds = better</span>
<span class="n">rmsd_x</span><span class="p">,</span> <span class="n">rmsd_y</span><span class="p">,</span> <span class="n">rmsd_z</span> <span class="o">=</span> <span class="n">flex</span><span class="o">.</span><span class="n">vec3_double</span><span class="p">(</span>
<span class="n">s</span><span class="o">.</span><span class="n">rmsds</span> <span class="k">for</span> <span class="n">s</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">all_solutions</span>
<span class="n">s</span><span class="o">.</span><span class="n">rmsds</span><span class="p">[:</span><span class="mi">3</span><span class="p">]</span> <span class="k">for</span> <span class="n">s</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">all_solutions</span>
<span class="p">)</span><span class="o">.</span><span class="n">parts</span><span class="p">()</span>
<span class="n">rmsd_xy</span> <span class="o">=</span> <span class="n">flex</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="n">flex</span><span class="o">.</span><span class="n">pow2</span><span class="p">(</span><span class="n">rmsd_x</span><span class="p">)</span> <span class="o">+</span> <span class="n">flex</span><span class="o">.</span><span class="n">pow2</span><span class="p">(</span><span class="n">rmsd_y</span><span class="p">))</span>
<span class="n">score</span> <span class="o">=</span> <span class="n">flex</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">rmsd_xy</span><span class="p">)</span> <span class="o">/</span> <span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
Expand Down Expand Up @@ -384,7 +384,7 @@ <h1>Source code for dials.algorithms.indexing.model_evaluation</h1><div class="h
<span class="n">perm</span> <span class="o">=</span> <span class="n">flex</span><span class="o">.</span><span class="n">sort_permutation</span><span class="p">(</span><span class="n">combined_scores</span><span class="p">)</span>

<span class="n">rmsd_x</span><span class="p">,</span> <span class="n">rmsd_y</span><span class="p">,</span> <span class="n">rmsd_z</span> <span class="o">=</span> <span class="n">flex</span><span class="o">.</span><span class="n">vec3_double</span><span class="p">(</span>
<span class="n">s</span><span class="o">.</span><span class="n">rmsds</span> <span class="k">for</span> <span class="n">s</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">all_solutions</span>
<span class="n">s</span><span class="o">.</span><span class="n">rmsds</span><span class="p">[:</span><span class="mi">3</span><span class="p">]</span> <span class="k">for</span> <span class="n">s</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">all_solutions</span>
<span class="p">)</span><span class="o">.</span><span class="n">parts</span><span class="p">()</span>
<span class="n">rmsd_xy</span> <span class="o">=</span> <span class="n">flex</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="n">flex</span><span class="o">.</span><span class="n">pow2</span><span class="p">(</span><span class="n">rmsd_x</span><span class="p">)</span> <span class="o">+</span> <span class="n">flex</span><span class="o">.</span><span class="n">pow2</span><span class="p">(</span><span class="n">rmsd_y</span><span class="p">))</span>

Expand Down
Loading

0 comments on commit 00f80ae

Please sign in to comment.