Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jul 16, 2024
1 parent 0903e71 commit 3f35184
Show file tree
Hide file tree
Showing 16 changed files with 294 additions and 126 deletions.
2 changes: 1 addition & 1 deletion assets/css/atom.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/css/rss.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/css/styles_feeling_responsive.css.map

Large diffs are not rendered by default.

Binary file modified nightly/.doctrees/demos/00_CIL_geometry.doctree
Binary file not shown.
Binary file modified nightly/.doctrees/environment.pickle
Binary file not shown.
Binary file modified nightly/.doctrees/framework.doctree
Binary file not shown.
112 changes: 56 additions & 56 deletions nightly/.doctrees/nbsphinx/demos/00_CIL_geometry.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"execution_count": 1,
"metadata": {
"execution": {
"iopub.execute_input": "2024-07-15T16:14:07.718963Z",
"iopub.status.busy": "2024-07-15T16:14:07.718795Z",
"iopub.status.idle": "2024-07-15T16:14:07.721939Z",
"shell.execute_reply": "2024-07-15T16:14:07.721547Z"
"iopub.execute_input": "2024-07-16T08:11:33.859548Z",
"iopub.status.busy": "2024-07-16T08:11:33.859378Z",
"iopub.status.idle": "2024-07-16T08:11:33.862454Z",
"shell.execute_reply": "2024-07-16T08:11:33.861985Z"
}
},
"outputs": [],
Expand Down Expand Up @@ -142,10 +142,10 @@
"execution_count": 2,
"metadata": {
"execution": {
"iopub.execute_input": "2024-07-15T16:14:07.723733Z",
"iopub.status.busy": "2024-07-15T16:14:07.723579Z",
"iopub.status.idle": "2024-07-15T16:14:09.435905Z",
"shell.execute_reply": "2024-07-15T16:14:09.435349Z"
"iopub.execute_input": "2024-07-16T08:11:33.864567Z",
"iopub.status.busy": "2024-07-16T08:11:33.864182Z",
"iopub.status.idle": "2024-07-16T08:11:34.701188Z",
"shell.execute_reply": "2024-07-16T08:11:34.700679Z"
}
},
"outputs": [
Expand Down Expand Up @@ -209,10 +209,10 @@
"execution_count": 3,
"metadata": {
"execution": {
"iopub.execute_input": "2024-07-15T16:14:09.466098Z",
"iopub.status.busy": "2024-07-15T16:14:09.465731Z",
"iopub.status.idle": "2024-07-15T16:14:09.704662Z",
"shell.execute_reply": "2024-07-15T16:14:09.704131Z"
"iopub.execute_input": "2024-07-16T08:11:34.731458Z",
"iopub.status.busy": "2024-07-16T08:11:34.730997Z",
"iopub.status.idle": "2024-07-16T08:11:34.963103Z",
"shell.execute_reply": "2024-07-16T08:11:34.962550Z"
}
},
"outputs": [
Expand All @@ -229,7 +229,7 @@
{
"data": {
"text/plain": [
"<cil.utilities.display.show_geometry at 0x7f0b9cb0b860>"
"<cil.utilities.display.show_geometry at 0x7f151e3d6180>"
]
},
"execution_count": 3,
Expand Down Expand Up @@ -271,10 +271,10 @@
"execution_count": 4,
"metadata": {
"execution": {
"iopub.execute_input": "2024-07-15T16:14:09.706600Z",
"iopub.status.busy": "2024-07-15T16:14:09.706428Z",
"iopub.status.idle": "2024-07-15T16:14:09.897040Z",
"shell.execute_reply": "2024-07-15T16:14:09.896548Z"
"iopub.execute_input": "2024-07-16T08:11:34.965411Z",
"iopub.status.busy": "2024-07-16T08:11:34.965136Z",
"iopub.status.idle": "2024-07-16T08:11:35.166893Z",
"shell.execute_reply": "2024-07-16T08:11:35.166325Z"
}
},
"outputs": [
Expand All @@ -291,7 +291,7 @@
{
"data": {
"text/plain": [
"<cil.utilities.display.show_geometry at 0x7f0b9c58a7e0>"
"<cil.utilities.display.show_geometry at 0x7f151dc742f0>"
]
},
"execution_count": 4,
Expand Down Expand Up @@ -333,10 +333,10 @@
"execution_count": 5,
"metadata": {
"execution": {
"iopub.execute_input": "2024-07-15T16:14:09.899213Z",
"iopub.status.busy": "2024-07-15T16:14:09.898826Z",
"iopub.status.idle": "2024-07-15T16:14:10.117425Z",
"shell.execute_reply": "2024-07-15T16:14:10.116896Z"
"iopub.execute_input": "2024-07-16T08:11:35.168829Z",
"iopub.status.busy": "2024-07-16T08:11:35.168666Z",
"iopub.status.idle": "2024-07-16T08:11:35.396282Z",
"shell.execute_reply": "2024-07-16T08:11:35.395757Z"
}
},
"outputs": [
Expand All @@ -353,7 +353,7 @@
{
"data": {
"text/plain": [
"<cil.utilities.display.show_geometry at 0x7f0b6df55f40>"
"<cil.utilities.display.show_geometry at 0x7f151d849250>"
]
},
"execution_count": 5,
Expand Down Expand Up @@ -394,10 +394,10 @@
"execution_count": 6,
"metadata": {
"execution": {
"iopub.execute_input": "2024-07-15T16:14:10.119464Z",
"iopub.status.busy": "2024-07-15T16:14:10.119124Z",
"iopub.status.idle": "2024-07-15T16:14:10.313653Z",
"shell.execute_reply": "2024-07-15T16:14:10.313131Z"
"iopub.execute_input": "2024-07-16T08:11:35.398492Z",
"iopub.status.busy": "2024-07-16T08:11:35.398089Z",
"iopub.status.idle": "2024-07-16T08:11:35.591213Z",
"shell.execute_reply": "2024-07-16T08:11:35.590714Z"
}
},
"outputs": [
Expand All @@ -414,7 +414,7 @@
{
"data": {
"text/plain": [
"<cil.utilities.display.show_geometry at 0x7f0b6df71e80>"
"<cil.utilities.display.show_geometry at 0x7f151d84a180>"
]
},
"execution_count": 6,
Expand Down Expand Up @@ -447,10 +447,10 @@
"execution_count": 7,
"metadata": {
"execution": {
"iopub.execute_input": "2024-07-15T16:14:10.315519Z",
"iopub.status.busy": "2024-07-15T16:14:10.315349Z",
"iopub.status.idle": "2024-07-15T16:14:10.542859Z",
"shell.execute_reply": "2024-07-15T16:14:10.542398Z"
"iopub.execute_input": "2024-07-16T08:11:35.593423Z",
"iopub.status.busy": "2024-07-16T08:11:35.593071Z",
"iopub.status.idle": "2024-07-16T08:11:35.828432Z",
"shell.execute_reply": "2024-07-16T08:11:35.827943Z"
}
},
"outputs": [
Expand All @@ -467,7 +467,7 @@
{
"data": {
"text/plain": [
"<cil.utilities.display.show_geometry at 0x7f0b6de3d5b0>"
"<cil.utilities.display.show_geometry at 0x7f151c1d2e40>"
]
},
"execution_count": 7,
Expand Down Expand Up @@ -499,10 +499,10 @@
"execution_count": 8,
"metadata": {
"execution": {
"iopub.execute_input": "2024-07-15T16:14:10.544831Z",
"iopub.status.busy": "2024-07-15T16:14:10.544659Z",
"iopub.status.idle": "2024-07-15T16:14:10.766564Z",
"shell.execute_reply": "2024-07-15T16:14:10.766043Z"
"iopub.execute_input": "2024-07-16T08:11:35.830356Z",
"iopub.status.busy": "2024-07-16T08:11:35.830185Z",
"iopub.status.idle": "2024-07-16T08:11:36.051123Z",
"shell.execute_reply": "2024-07-16T08:11:36.050558Z"
}
},
"outputs": [
Expand All @@ -519,7 +519,7 @@
{
"data": {
"text/plain": [
"<cil.utilities.display.show_geometry at 0x7f0b6df56450>"
"<cil.utilities.display.show_geometry at 0x7f151c2496a0>"
]
},
"execution_count": 8,
Expand Down Expand Up @@ -549,10 +549,10 @@
"execution_count": 9,
"metadata": {
"execution": {
"iopub.execute_input": "2024-07-15T16:14:10.768657Z",
"iopub.status.busy": "2024-07-15T16:14:10.768389Z",
"iopub.status.idle": "2024-07-15T16:14:10.991952Z",
"shell.execute_reply": "2024-07-15T16:14:10.991403Z"
"iopub.execute_input": "2024-07-16T08:11:36.053333Z",
"iopub.status.busy": "2024-07-16T08:11:36.052989Z",
"iopub.status.idle": "2024-07-16T08:11:36.275014Z",
"shell.execute_reply": "2024-07-16T08:11:36.274485Z"
}
},
"outputs": [
Expand All @@ -569,7 +569,7 @@
{
"data": {
"text/plain": [
"<cil.utilities.display.show_geometry at 0x7f0b6df57920>"
"<cil.utilities.display.show_geometry at 0x7f151e1d8b00>"
]
},
"execution_count": 9,
Expand Down Expand Up @@ -638,10 +638,10 @@
"execution_count": 10,
"metadata": {
"execution": {
"iopub.execute_input": "2024-07-15T16:14:10.993983Z",
"iopub.status.busy": "2024-07-15T16:14:10.993715Z",
"iopub.status.idle": "2024-07-15T16:14:10.998509Z",
"shell.execute_reply": "2024-07-15T16:14:10.998044Z"
"iopub.execute_input": "2024-07-16T08:11:36.276962Z",
"iopub.status.busy": "2024-07-16T08:11:36.276789Z",
"iopub.status.idle": "2024-07-16T08:11:36.281446Z",
"shell.execute_reply": "2024-07-16T08:11:36.280998Z"
}
},
"outputs": [
Expand Down Expand Up @@ -711,10 +711,10 @@
"execution_count": 11,
"metadata": {
"execution": {
"iopub.execute_input": "2024-07-15T16:14:11.000358Z",
"iopub.status.busy": "2024-07-15T16:14:11.000045Z",
"iopub.status.idle": "2024-07-15T16:14:11.638348Z",
"shell.execute_reply": "2024-07-15T16:14:11.637829Z"
"iopub.execute_input": "2024-07-16T08:11:36.283358Z",
"iopub.status.busy": "2024-07-16T08:11:36.283006Z",
"iopub.status.idle": "2024-07-16T08:11:36.928711Z",
"shell.execute_reply": "2024-07-16T08:11:36.928177Z"
}
},
"outputs": [
Expand Down Expand Up @@ -772,7 +772,7 @@
{
"data": {
"text/plain": [
"<cil.utilities.display.show_geometry at 0x7f0b9c982360>"
"<cil.utilities.display.show_geometry at 0x7f151df40620>"
]
},
"execution_count": 11,
Expand Down Expand Up @@ -815,10 +815,10 @@
"execution_count": 12,
"metadata": {
"execution": {
"iopub.execute_input": "2024-07-15T16:14:11.640512Z",
"iopub.status.busy": "2024-07-15T16:14:11.640112Z",
"iopub.status.idle": "2024-07-15T16:14:11.642730Z",
"shell.execute_reply": "2024-07-15T16:14:11.642361Z"
"iopub.execute_input": "2024-07-16T08:11:36.930739Z",
"iopub.status.busy": "2024-07-16T08:11:36.930386Z",
"iopub.status.idle": "2024-07-16T08:11:36.932994Z",
"shell.execute_reply": "2024-07-16T08:11:36.932612Z"
}
},
"outputs": [],
Expand Down
10 changes: 8 additions & 2 deletions nightly/_modules/cil/framework/framework/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,8 @@ <h1>Source code for cil.framework.framework</h1><div class="highlight"><pre>
<span class="n">log</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>


<div class="viewcode-block" id="Partitioner">
<a class="viewcode-back" href="../../../../framework/#cil.framework.Partitioner">[docs]</a>
<span class="k">class</span> <span class="nc">Partitioner</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&#39;&#39;&#39;Interface for AcquisitionData to be able to partition itself in a number of batches.</span>

Expand Down Expand Up @@ -615,6 +617,8 @@ <h1>Source code for cil.framework.framework</h1><div class="highlight"><pre>
<span class="n">ags</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">ag</span><span class="p">)</span>
<span class="k">return</span> <span class="n">BlockGeometry</span><span class="p">(</span><span class="o">*</span><span class="n">ags</span><span class="p">)</span>

<div class="viewcode-block" id="Partitioner.partition">
<a class="viewcode-back" href="../../../../framework/#cil.framework.Partitioner.partition">[docs]</a>
<span class="k">def</span> <span class="nf">partition</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">num_batches</span><span class="p">,</span> <span class="n">mode</span><span class="p">,</span> <span class="n">seed</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&#39;&#39;&#39;Partition the data into ``num_batches`` batches using the specified ``mode``.</span>

Expand Down Expand Up @@ -660,7 +664,8 @@ <h1>Source code for cil.framework.framework</h1><div class="highlight"><pre>
<span class="k">elif</span> <span class="n">mode</span> <span class="o">==</span> <span class="n">Partitioner</span><span class="o">.</span><span class="n">RANDOM_PERMUTATION</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_partition_random_permutation</span><span class="p">(</span><span class="n">num_batches</span><span class="p">,</span> <span class="n">seed</span><span class="o">=</span><span class="n">seed</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">&#39;Unknown partition mode </span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">mode</span><span class="p">))</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">&#39;Unknown partition mode </span><span class="si">{}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">mode</span><span class="p">))</span></div>


<span class="k">def</span> <span class="nf">_partition_deterministic</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">num_batches</span><span class="p">,</span> <span class="n">stagger</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">indices</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&#39;&#39;&#39;Partition the data into ``num_batches`` batches.</span>
Expand Down Expand Up @@ -712,7 +717,8 @@ <h1>Source code for cil.framework.framework</h1><div class="highlight"><pre>

<span class="n">indices</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">indices</span><span class="p">)</span>

<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_partition_deterministic</span><span class="p">(</span><span class="n">num_batches</span><span class="p">,</span> <span class="n">stagger</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">indices</span><span class="o">=</span><span class="n">indices</span><span class="p">)</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_partition_deterministic</span><span class="p">(</span><span class="n">num_batches</span><span class="p">,</span> <span class="n">stagger</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">indices</span><span class="o">=</span><span class="n">indices</span><span class="p">)</span></div>


<span class="k">def</span> <span class="nf">find_key</span><span class="p">(</span><span class="n">dic</span><span class="p">,</span> <span class="n">val</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;return the key of dictionary dic given the value&quot;&quot;&quot;</span>
Expand Down
58 changes: 58 additions & 0 deletions nightly/_sources/framework.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,64 @@ This provide a base class that will behave as normal :code:`DataContainer`.
:members:
:inherited-members:

Partitioner
===========

This method partitions an instance of tomography :code:`AcquisitionData` into a number of batches. For example, to use with a stochastic optimisation method.

The partitioning is done by taking batches of angles and the corresponding data collected by taking projections along these angles. The partitioner method chooses what angles go in which batch depending on the `mode` and takes in an `AquisitionData` object and outputs a `BlockDataContainer` where each element in the block is `AquisitionData` object with the batch of data and corresponding geometry.
We consider a **batch** to be a subset of the :code:`AcquisitionData` and the verb, **to partition**, to be the act of splitting into batches.


For example:

.. code-block :: python
from cil.utilities import dataexample
from cil.plugins.astra.operators import ProjectionOperator
# get the data
data = dataexample.SIMULATED_PARALLEL_BEAM_DATA.get()
data.reorder('astra')
data = data.get_slice(vertical='centre')
# create the geometries
ag = data.geometry
ig = ag.get_ImageGeometry()
# partition the data into batches contained in the elements of a BlockDataContainer
data_partitioned = data.partition(num_batches=10, mode='staggered') # Choose mode from `sequential`, `staggered` or `random_permutation`
# From the partitioned data build a BlockOperator container the projectors for each batch
A_partitioned = ProjectionOperator(ig, data_partitioned.geometry, device = "cpu")
print('The total number of angles is ', len(data.geometry.angles))
print('The first 30 angles are ', data.geometry.angles[:30])
print('In batch zero the number of angles is ', len(data_partitioned[0].geometry.angles))
print('The angles in batch zero are ', data_partitioned[0].geometry.angles)
print('The angles in batch one are ', data_partitioned[1].geometry.angles)
.. code-block :: RST
The total number of angles is 300
The first 30 angles are [ 0. 1.2 2.4 3.6 4.8 6. 7.2 8.4 9.6 10.8 12. 13.2 14.4 15.6
16.8 18. 19.2 20.4 21.6 22.8 24. 25.2 26.4 27.6 28.8 30. 31.2 32.4
33.6 34.8]
In batch zero the number of angles is 30
The angles in batch zero are [ 0. 12. 24. 36. 48. 60. 72. 84. 96. 108. 120. 132. 144. 156.
168. 180. 192. 204. 216. 228. 240. 252. 264. 276. 288. 300. 312. 324.
336. 348.]
The angles in batch one are [ 1.2 13.2 25.2 37.2 49.2 61.2 73.2 85.2 97.2 109.2 121.2 133.2
145.2 157.2 169.2 181.2 193.2 205.2 217.2 229.2 241.2 253.2 265.2 277.2
289.2 301.2 313.2 325.2 337.2 349.2]
The :code:`partition` method is defined as part of:

.. autoclass:: cil.framework.Partitioner
:members:


DataOrder
=========
.. autoclass:: cil.framework.DataOrder
Expand Down
Loading

0 comments on commit 3f35184

Please sign in to comment.