Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add QT example of ROI tool. [skip ci]
Browse files Browse the repository at this point in the history
YooSunYoung committed Nov 21, 2024
1 parent cd7d1ad commit fbcd34f
Showing 1 changed file with 59 additions and 13 deletions.
72 changes: 59 additions & 13 deletions docs/user-guide/odin_simulation.ipynb
Original file line number Diff line number Diff line change
@@ -399,7 +399,7 @@
" super().__init__(callback=self.start_stop, value=value, **kwargs)\n",
"\n",
" self._figure = figure\n",
" self._tool = Rectangles(ax=self._figure.ax, autostart=False)\n",
" self._tool = Rectangles(ax=self._figure.ax, autostart=kwargs.get('autostart', False))\n",
" self.rectangles = []\n",
" self._draw_node = pp.Node(lambda: self.rectangles) # Empty rectangle info.\n",
" self._destination = destination\n",
@@ -444,6 +444,7 @@
"metadata": {},
"outputs": [],
"source": [
"# Prepare the merge method\n",
"from functools import reduce\n",
"\n",
"\n",
@@ -464,39 +465,76 @@
" return da.sum('x').sum('y')\n",
"\n",
"\n",
"original_data_node = pp.Node(_binned_sample)\n",
"merge_node = pp.Node(_show_histogram)\n",
"merge_node.add_parents(original_data_node)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "14",
"metadata": {},
"outputs": [],
"source": [
"data_node = pp.Node(_binned_sample.sum('time_of_arrival'))\n",
"f2d = pp.imagefigure(\n",
" data_node, norm='log', title=\"Region of Interest Selection\", cbar=True\n",
")\n",
"original_data_node = pp.Node(_binned_sample)\n",
"merge_node = pp.Node(_show_histogram)\n",
"merge_node.add_parents(original_data_node)\n",
"\n",
"r = MultiRectangleTool(figure=f2d, destination=merge_node, icon='vector-square')\n",
"\n",
"f1d = pp.linefigure(\n",
" merge_node, title=\"Time of Arrival Spectrum in ROI\", grid=True, vmin=0\n",
")\n",
"\n",
"\n",
"f2d.toolbar['roi'] = r\n",
"box = HBar([f2d, f1d])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "14",
"id": "15",
"metadata": {},
"outputs": [],
"source": [
"box"
]
},
{
"cell_type": "markdown",
"id": "16",
"metadata": {},
"source": [
"If you want to use QT instead of notebook, you can use the snippet below.\n",
"\n",
"```python\n",
"%matplotlib qt # Should be at the top of the notebook.\n",
"import matplotlib.pyplot as plt\n",
"\n",
"fig, ax = plt.subplots(ncols=2)\n",
"data_node = pp.Node(_binned_sample.sum('time_of_arrival'))\n",
"f2d = pp.imagefigure(\n",
" data_node, norm='log', title=\"Region of Interest Selection\", cbar=True, ax=ax[0]\n",
")\n",
"\n",
"original_data_node = pp.Node(_binned_sample)\n",
"merge_node = pp.Node(_show_histogram)\n",
"merge_node.add_parents(original_data_node)\n",
"\n",
"r = MultiRectangleTool(figure=f2d, destination=merge_node, icon='vector-square', autostart=True)\n",
"f1d = pp.linefigure(\n",
" merge_node, title=\"Time of Arrival Spectrum in ROI\", grid=True, vmin=0, ax=ax[1]\n",
")\n",
"\n",
"fig.show() # Will start the QT application.\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "15",
"id": "17",
"metadata": {},
"outputs": [],
"source": [
@@ -513,7 +551,7 @@
},
{
"cell_type": "markdown",
"id": "16",
"id": "18",
"metadata": {},
"source": [
"## Choppers\n",
@@ -526,7 +564,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "17",
"id": "19",
"metadata": {},
"outputs": [],
"source": [
@@ -577,7 +615,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "18",
"id": "20",
"metadata": {},
"outputs": [],
"source": [
@@ -675,7 +713,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "19",
"id": "21",
"metadata": {},
"outputs": [],
"source": [
@@ -709,7 +747,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "20",
"id": "22",
"metadata": {},
"outputs": [],
"source": [
@@ -740,6 +778,14 @@
"\n",
"TBETA # Display one of the T0 choppers"
]
},
{
"cell_type": "markdown",
"id": "23",
"metadata": {},
"source": [
"## WFM Stitching\n"
]
}
],
"metadata": {

0 comments on commit fbcd34f

Please sign in to comment.