Skip to content

Commit 39035c4

Browse files
committed
Add notebook in version 3
1 parent aa7398a commit 39035c4

15 files changed

Lines changed: 5800 additions & 0 deletions

silx/io/io.v3.ipynb

Lines changed: 793 additions & 0 deletions
Large diffs are not rendered by default.

silx/plot/Plot1DExercise.v3.ipynb

Lines changed: 279 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,279 @@
1+
{
2+
"metadata": {
3+
"kernelspec": {
4+
"display_name": "Python 3",
5+
"language": "python",
6+
"name": "python3"
7+
},
8+
"language_info": {
9+
"codemirror_mode": {
10+
"name": "ipython",
11+
"version": 3
12+
},
13+
"file_extension": ".py",
14+
"mimetype": "text/x-python",
15+
"name": "python",
16+
"nbconvert_exporter": "python",
17+
"pygments_lexer": "ipython3",
18+
"version": "3.5.2"
19+
},
20+
"name": ""
21+
},
22+
"nbformat": 3,
23+
"nbformat_minor": 0,
24+
"worksheets": [
25+
{
26+
"cells": [
27+
{
28+
"cell_type": "markdown",
29+
"metadata": {},
30+
"source": [
31+
"# One curve\n",
32+
"## plot a simple curve and play with it\n",
33+
"\n",
34+
"- $x=[0, pi]$\n",
35+
"\n",
36+
"- $y=e^x$\n",
37+
"\n",
38+
"- see documentation: http://www.silx.org/doc/silx/dev/modules/gui/plot/plotwindow.html#silx.gui.plot.PlotWindow.Plot1D\n",
39+
"\n",
40+
"- see tutorial: http://www.silx.org/doc/silx/dev/modules/gui/plot/getting_started.html\n",
41+
"\n",
42+
"- use Plot1D and Plot1D.addCurve\n",
43+
" - legend is used as the ID of the curve. So if a new curve is setted with an existing id it will erase the first curve\n",
44+
"\n",
45+
"![larger-iso-surface-using-silx-plot3d](img/plot_exp.png)\n",
46+
"\n",
47+
"play with the interface:\n",
48+
"- log scale\n",
49+
"- grid\n",
50+
"- display points\n",
51+
"- ..."
52+
]
53+
},
54+
{
55+
"cell_type": "code",
56+
"collapsed": true,
57+
"input": [
58+
"import numpy\n",
59+
"from silx.gui.plot import Plot1D\n",
60+
"%gui qt"
61+
],
62+
"language": "python",
63+
"metadata": {},
64+
"outputs": [],
65+
"prompt_number": null
66+
},
67+
{
68+
"cell_type": "code",
69+
"collapsed": false,
70+
"input": [
71+
"import numpy\n",
72+
"x=numpy.linspace(0, numpy.pi, 1000)\n",
73+
"y=numpy.exp(x)"
74+
],
75+
"language": "python",
76+
"metadata": {},
77+
"outputs": [],
78+
"prompt_number": null
79+
},
80+
{
81+
"cell_type": "code",
82+
"collapsed": false,
83+
"input": [
84+
"..."
85+
],
86+
"language": "python",
87+
"metadata": {},
88+
"outputs": [],
89+
"prompt_number": null
90+
},
91+
{
92+
"cell_type": "markdown",
93+
"metadata": {},
94+
"source": [
95+
"## Shift the curve\n",
96+
"get back the curve and add an offset in y axis\n",
97+
"\n",
98+
"- $y=y+100.0$\n",
99+
"- get all needed data from the 'Plot1D' object\n",
100+
"- use getCurve([curveID]) function. Return : \n",
101+
" - x\n",
102+
" - y\n",
103+
" - legend\n",
104+
" - info (if some informations has been added)\n",
105+
" - params (color, linewidth...)\n",
106+
"\n",
107+
"![shift exponential](img/plot1D_shiftCurveExp.png)"
108+
]
109+
},
110+
{
111+
"cell_type": "code",
112+
"collapsed": false,
113+
"input": [
114+
"..."
115+
],
116+
"language": "python",
117+
"metadata": {},
118+
"outputs": [],
119+
"prompt_number": null
120+
},
121+
{
122+
"cell_type": "heading",
123+
"level": 1,
124+
"metadata": {},
125+
"source": [
126+
"Many curves"
127+
]
128+
},
129+
{
130+
"cell_type": "markdown",
131+
"metadata": {},
132+
"source": [
133+
"## plot the following functionin the same plot window\n",
134+
"- $y=sin(x)$\n",
135+
"\n",
136+
"- $y=cos(x)$\n",
137+
"\n",
138+
"- $y=x $\n",
139+
"\n",
140+
"- play with the curve selection from options->legend\n",
141+
"\n",
142+
"![plot_legends](img/plot_curves_legend.png)"
143+
]
144+
},
145+
{
146+
"cell_type": "code",
147+
"collapsed": false,
148+
"input": [
149+
"..."
150+
],
151+
"language": "python",
152+
"metadata": {},
153+
"outputs": [],
154+
"prompt_number": null
155+
},
156+
{
157+
"cell_type": "markdown",
158+
"metadata": {},
159+
"source": [
160+
"## remove one curve by the id\n",
161+
"\n",
162+
"- using the 'Plot1D' function 'remove([curveID])'"
163+
]
164+
},
165+
{
166+
"cell_type": "code",
167+
"collapsed": true,
168+
"input": [
169+
"..."
170+
],
171+
"language": "python",
172+
"metadata": {},
173+
"outputs": [],
174+
"prompt_number": null
175+
},
176+
{
177+
"cell_type": "markdown",
178+
"metadata": {},
179+
"source": [
180+
"## shift curves by 30 in the x axis \n",
181+
"- by using the functions of the 'Plot1D' object\n",
182+
" - getAllCurves\n",
183+
" - addCurve\n",
184+
"- keep at least the color of the curve\n",
185+
"- Result should be close to\n",
186+
"\n",
187+
"![plot1D_shiftcurves](img/plot1D_shiftCurves.png)"
188+
]
189+
},
190+
{
191+
"cell_type": "code",
192+
"collapsed": false,
193+
"input": [
194+
"..."
195+
],
196+
"language": "python",
197+
"metadata": {},
198+
"outputs": [],
199+
"prompt_number": null
200+
},
201+
{
202+
"cell_type": "markdown",
203+
"metadata": {},
204+
"source": [
205+
"# ROI\n"
206+
]
207+
},
208+
{
209+
"cell_type": "heading",
210+
"level": 2,
211+
"metadata": {},
212+
"source": [
213+
"load data from data/spectrum.dat"
214+
]
215+
},
216+
{
217+
"cell_type": "code",
218+
"collapsed": false,
219+
"input": [
220+
"import silx.io\n",
221+
"sf = silx.io.open(\"data/spectrum.dat\")\n",
222+
"x_data=sf['1.1/measurement/channel']\n",
223+
"y_data=sf['1.1/measurement/counts']"
224+
],
225+
"language": "python",
226+
"metadata": {},
227+
"outputs": [],
228+
"prompt_number": null
229+
},
230+
{
231+
"cell_type": "heading",
232+
"level": 2,
233+
"metadata": {},
234+
"source": [
235+
"Plot the data"
236+
]
237+
},
238+
{
239+
"cell_type": "code",
240+
"collapsed": false,
241+
"input": [
242+
"plot=Plot1D()\n",
243+
"x=numpy.linspace(0.0, numpy.pi)\n",
244+
"y=numpy.sin(x)\n",
245+
"plot.addCurve(x_data, y_data)\n",
246+
"plot.setYAxisLogarithmic(True)\n",
247+
"plot.show()"
248+
],
249+
"language": "python",
250+
"metadata": {},
251+
"outputs": [],
252+
"prompt_number": null
253+
},
254+
{
255+
"cell_type": "markdown",
256+
"metadata": {},
257+
"source": [
258+
"options -> ROI -> add ROI -> select min and max limits.\n",
259+
"estimate integral between lower and upper limits\n",
260+
" - Raw counts\n",
261+
"![raw_counts](img/plot_ROI_raw_counts.png)\n",
262+
" - Net counts\n",
263+
"![raw_counts](img/plot_ROI_net_counts.png)"
264+
]
265+
},
266+
{
267+
"cell_type": "code",
268+
"collapsed": true,
269+
"input": [],
270+
"language": "python",
271+
"metadata": {},
272+
"outputs": [],
273+
"prompt_number": null
274+
}
275+
],
276+
"metadata": {}
277+
}
278+
]
279+
}

0 commit comments

Comments
 (0)