Skip to content

Commit

Permalink
Add notebook in version 3
Browse files Browse the repository at this point in the history
  • Loading branch information
vallsv committed Mar 14, 2017
1 parent aa7398a commit 39035c4
Show file tree
Hide file tree
Showing 15 changed files with 5,800 additions and 0 deletions.
793 changes: 793 additions & 0 deletions silx/io/io.v3.ipynb

Large diffs are not rendered by default.

279 changes: 279 additions & 0 deletions silx/plot/Plot1DExercise.v3.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,279 @@
{
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
},
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# One curve\n",
"## plot a simple curve and play with it\n",
"\n",
"- $x=[0, pi]$\n",
"\n",
"- $y=e^x$\n",
"\n",
"- see documentation: http://www.silx.org/doc/silx/dev/modules/gui/plot/plotwindow.html#silx.gui.plot.PlotWindow.Plot1D\n",
"\n",
"- see tutorial: http://www.silx.org/doc/silx/dev/modules/gui/plot/getting_started.html\n",
"\n",
"- use Plot1D and Plot1D.addCurve\n",
" - 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",
"\n",
"![larger-iso-surface-using-silx-plot3d](img/plot_exp.png)\n",
"\n",
"play with the interface:\n",
"- log scale\n",
"- grid\n",
"- display points\n",
"- ..."
]
},
{
"cell_type": "code",
"collapsed": true,
"input": [
"import numpy\n",
"from silx.gui.plot import Plot1D\n",
"%gui qt"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": null
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import numpy\n",
"x=numpy.linspace(0, numpy.pi, 1000)\n",
"y=numpy.exp(x)"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": null
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"..."
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": null
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Shift the curve\n",
"get back the curve and add an offset in y axis\n",
"\n",
"- $y=y+100.0$\n",
"- get all needed data from the 'Plot1D' object\n",
"- use getCurve([curveID]) function. Return : \n",
" - x\n",
" - y\n",
" - legend\n",
" - info (if some informations has been added)\n",
" - params (color, linewidth...)\n",
"\n",
"![shift exponential](img/plot1D_shiftCurveExp.png)"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"..."
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": null
},
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"Many curves"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## plot the following functionin the same plot window\n",
"- $y=sin(x)$\n",
"\n",
"- $y=cos(x)$\n",
"\n",
"- $y=x $\n",
"\n",
"- play with the curve selection from options->legend\n",
"\n",
"![plot_legends](img/plot_curves_legend.png)"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"..."
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": null
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## remove one curve by the id\n",
"\n",
"- using the 'Plot1D' function 'remove([curveID])'"
]
},
{
"cell_type": "code",
"collapsed": true,
"input": [
"..."
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": null
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## shift curves by 30 in the x axis \n",
"- by using the functions of the 'Plot1D' object\n",
" - getAllCurves\n",
" - addCurve\n",
"- keep at least the color of the curve\n",
"- Result should be close to\n",
"\n",
"![plot1D_shiftcurves](img/plot1D_shiftCurves.png)"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"..."
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": null
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# ROI\n"
]
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"load data from data/spectrum.dat"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"import silx.io\n",
"sf = silx.io.open(\"data/spectrum.dat\")\n",
"x_data=sf['1.1/measurement/channel']\n",
"y_data=sf['1.1/measurement/counts']"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": null
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Plot the data"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"plot=Plot1D()\n",
"x=numpy.linspace(0.0, numpy.pi)\n",
"y=numpy.sin(x)\n",
"plot.addCurve(x_data, y_data)\n",
"plot.setYAxisLogarithmic(True)\n",
"plot.show()"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": null
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"options -> ROI -> add ROI -> select min and max limits.\n",
"estimate integral between lower and upper limits\n",
" - Raw counts\n",
"![raw_counts](img/plot_ROI_raw_counts.png)\n",
" - Net counts\n",
"![raw_counts](img/plot_ROI_net_counts.png)"
]
},
{
"cell_type": "code",
"collapsed": true,
"input": [],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": null
}
],
"metadata": {}
}
]
}
Loading

0 comments on commit 39035c4

Please sign in to comment.