Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions notebooks/01_data_objects.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,28 @@
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Plot `cropped` in the PyMoDAQ viewer (needs a display): the errors are drawn as a band around the line, and the\n",
"**Errors** button of the toolbar shows or hides it."
]
},
{
"cell_type": "code",
"metadata": {
"tags": [
"exercise"
]
},
"source": [
"%gui qt\n",
"... # plot `cropped` in the PyMoDAQ viewer"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
50 changes: 38 additions & 12 deletions notebooks/02_saving_loading.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
"from pathlib import Path\n",
"from pymodaq_utils.math_utils import gauss1D\n",
"from pymodaq_data.data import Axis, DataRaw, DataToExport\n",
"from pymodaq_data.h5modules.saving import H5SaverLowLevel\n",
"from pymodaq_data.h5modules.data_saving import DataToExportSaver, DataLoader\n",
"from pymodaq_data.h5modules.data_saving import DataToExportSaver, DataSaverLoader, DataLoader\n",
"\n",
"DATA = Path('../data')\n",
"\n",
Expand Down Expand Up @@ -50,15 +49,11 @@
},
"source": [
"path = Path('line.h5')\n",
"path.unlink(missing_ok=True) # init_file appends to an existing file\n",
"\n",
"h5saver = H5SaverLowLevel()\n",
"... # create the file at `path`\n",
"... # add a detector group under '/RawData', titled 'Photodiode line'\n",
"... # save `mesure` in the group '/RawData/Detector000' (hint: DataToExportSaver)\n",
"for node in ...: # walk all the nodes of the file, from '/'\n",
" print(node)\n",
"h5saver.close_file()"
"with DataToExportSaver(..., new_file=...) as saver: # the path of the file; overwrite it if it exists\n",
" ... # save `mesure` in the group '/RawData' (hint: add_data)\n",
" for node in saver.h5saver.walk_nodes('/'): # all the nodes of the file: where are the data, the axis, the errors?\n",
" print(node)\n",
"# the file is closed when leaving the `with` block"
],
"execution_count": null,
"outputs": []
Expand All @@ -79,14 +74,45 @@
},
"source": [
"loader = ... # open the file for reading\n",
"loaded = ... # load everything under '/RawData/Detector000' (a DataToExport)\n",
"loaded = ... # load everything under '/RawData' (a DataToExport)\n",
"loader.close_file()\n",
"back = ... # the data named 'line'\n",
"print(...) # is it equal to `line`? Print also its axes and its errors"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 2 bis. One data alone\n",
"\n",
"`DataSaverLoader` saves one data object (a `DataWithAxes`), `DataToExportSaver` a whole `DataToExport`. Compare the\n",
"nodes with the ones of the part 1."
]
},
{
"cell_type": "code",
"metadata": {
"tags": [
"exercise"
]
},
"source": [
"path_one = Path('line_alone.h5')\n",
"with DataSaverLoader(path_one, new_file=True) as saver:\n",
" ... # save `line` in the group '/RawData'\n",
"loader = DataLoader(path_one)\n",
"for node in loader.walk_nodes('/'):\n",
" print(node)\n",
"alone = ... # load the data node '/RawData/Data00'\n",
"loader.close_file()\n",
"print(alone == line)"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
46 changes: 46 additions & 0 deletions notebooks/03_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,30 @@
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Plot the averaged data with its error bars and the weighted fit: are the residuals inside the error bars?"
]
},
{
"cell_type": "code",
"metadata": {
"tags": [
"exercise"
]
},
"source": [
"fig, ax = plt.subplots()\n",
"ax.errorbar(x, window.data[0], yerr=..., fmt='.', label='mean of 8 scans') # the errors of `window`\n",
"ax.plot(x, model(x, *popt_w), '-', label='weighted fit')\n",
"ax.set_xlabel('wavelength (nm)')\n",
"ax.legend()"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -241,6 +265,28 @@
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Plot the spectrum with its errors in the PyMoDAQ viewer (needs a display): where is the band the widest?"
]
},
{
"cell_type": "code",
"metadata": {
"tags": [
"exercise"
]
},
"source": [
"%gui qt\n",
"import pymodaq_gui # registers the Qt plotter\n",
"... # plot `spectrum` in the PyMoDAQ viewer"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
Loading