Skip to content

Commit dc537be

Browse files
committed
chg: Update documentation with new functionality
1 parent a25729f commit dc537be

6 files changed

Lines changed: 170 additions & 16 deletions

File tree

212 KB
Loading

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
# a list of builtin themes.
133133
#
134134
html_theme = 'sphinx_rtd_theme'
135-
tml_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
135+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
136136

137137
# Theme options are theme-specific and customize the look and feel of a theme
138138
# further. For a list of options available for each theme, see the

docs/source/quickstart.rst

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ the path of the *.fid* directory:
4848
.. code:: python
4949
5050
>>> import nmrpy
51-
>>> import os, sysconfig
52-
>>> fname = os.path.join(sysconfig.get_paths()['purelib'], 'nmrpy',
51+
>>> import os
52+
>>> fname = os.path.join(os.path.dirname(nmrpy.__file__),
5353
'tests', 'test_data', 'test1.fid')
5454
>>> fid_array = nmrpy.from_path(fname)
55-
55+
56+
5657
You will notice that the ``fid_array`` object is instantiated and now owns
5758
several attributes, most of which are of the form ``fidXX`` where *XX* is
5859
a number starting at 00. These are the individual arrayed
@@ -81,8 +82,9 @@ visualise the result: ::
8182

8283
.. image:: _static/quickstart_2.png
8384

84-
Finally, we Fourier-transform the data into the frequency domain: ::
85+
Finally, we zero-fill and Fourier-transform the data into the frequency domain: ::
8586

87+
>>> fid_array.zf_fids()
8688
>>> fid_array.ft_fids()
8789
>>> fid_array.fid00.plot_ppm()
8890

@@ -327,7 +329,18 @@ Peak integrals of the entire :class:`~nmrpy.data_objects.FidArray` are stored in
327329
individual :class:`~nmrpy.data_objects.Fid` as
328330
:attr:`~nmrpy.data_objects.Fid.deconvoluted_integrals`.
329331

330-
We could easily plot the species integrals using the following code:
332+
Plotting the time-course
333+
========================
334+
335+
The acquisition times for the individual :class:`~nmrpy.data_objects.Fid`
336+
objects in the :class:`~nmrpy.data_objects.FidArray` are stored in an array
337+
:attr:`~nmrpy.data_objects.FidArray.t` for easy access. Note that when each
338+
:class:`~nmrpy.data_objects.Fid` is collected with multiple transients/scans on
339+
the spectrometer, the acquisition time is calculated as the *middle* of its
340+
overall acquisition period.
341+
342+
We could thus easily plot the time-course of the species integrals using the
343+
following code:
331344

332345
.. code:: python
333346
@@ -365,6 +378,52 @@ We could easily plot the species integrals using the following code:
365378

366379
.. _quickstart_exporting:
367380

381+
382+
Deleting individual `Fid` objects from a `FidArray`
383+
===================================================
384+
385+
Sometimes it may be desirable to remove one or more
386+
:class:`~nmrpy.data_objects.Fid` objects from a
387+
:class:`~nmrpy.data_objects.FidArray`, e.g. to remove outliers from the
388+
time-course of concentrations. This can be conveniently achieved with the
389+
:meth:`~nmrpy.data_objects.FidArray.del_fid()` method, which takes as argument
390+
the :attr:`~nmrpy.data_objects.Fid.id` of the :class:`~nmrpy.data_objects.Fid`
391+
to be removed. The acquisition time array
392+
:attr:`~nmrpy.data_objects.FidArray.t` is updated accordingly by removing the
393+
corresponding time-point. After this,
394+
:meth:`~nmrpy.data_objects.FidArray.deconv_fids` has to be run again to update
395+
the array of peak integrals.
396+
397+
A list of all the :class:`~nmrpy.data_objects.Fid` objects in a
398+
:class:`~nmrpy.data_objects.FidArray` is returned by the
399+
:meth:`~nmrpy.data_objects.FidArray.get_fids` method. ::
400+
401+
>>> print([f.id for f in fid_array.get_fids()])
402+
['fid00', 'fid01', 'fid02', 'fid03', 'fid04', 'fid05', 'fid06', 'fid07',
403+
'fid08', 'fid09', 'fid10', 'fid11', 'fid12', 'fid13', 'fid14', 'fid15',
404+
'fid16', 'fid17', 'fid18', 'fid19', 'fid20', 'fid21', 'fid22', 'fid23']
405+
406+
>>> for fid_id in [f.id for f in fid_array.get_fids()][::4]:
407+
fid_array.del_fid(fid_id)
408+
409+
>>> print([f.id for f in fid_array.get_fids()])
410+
['fid01', 'fid02', 'fid03', 'fid05', 'fid06', 'fid07', 'fid09', 'fid10',
411+
'fid11', 'fid13', 'fid14', 'fid15', 'fid17', 'fid18', 'fid19', 'fid21',
412+
'fid22', 'fid23']
413+
414+
>>> print(['{:.2f}'.format(i) for i in fid_array.t])
415+
['3.48', '5.80', '8.12', '12.76', '15.08', '17.40', '22.04', '24.36', '26.68',
416+
'31.32', '33.64', '35.96', '40.60', '42.92', '45.24', '49.88', '52.20', '54.52']
417+
418+
The gaps left by the deleted :class:`~nmrpy.data_objects.Fid` objects are clearly visible in the plotted
419+
:class:`~nmrpy.data_objects.FidArray`: ::
420+
421+
>>> fid_array.plot_array(upper_ppm=7, lower_ppm=-1, filled=True, azim=-68, elev=25)
422+
423+
.. image:: _static/quickstart_15.png
424+
:width: 75%
425+
:align: center
426+
368427
Saving / Loading
369428
================
370429

docs/source/quickstart_script.rst

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ The full script for the quickstart tutorial:
33
.. code:: python
44
55
import nmrpy
6-
import os, sysconfig
6+
import os
77
from matplotlib import pyplot as plt
88
9-
fname = os.path.join(sysconfig.get_paths()['purelib'], 'nmrpy',
10-
'tests', 'test_data', 'test1.fid')
9+
fname = os.path.join(os.path.dirname(nmrpy.__file__), 'tests',
10+
'test_data', 'test1.fid')
1111
fid_array = nmrpy.from_path(fid_path=fname)
1212
fid_array.emhz_fids()
1313
#fid_array.fid00.plot_ppm()
@@ -58,5 +58,14 @@ The full script for the quickstart tutorial:
5858
ax.legend(loc=0, frameon=False)
5959
plt.show()
6060
61+
print([f.id for f in fid_array.get_fids()])
62+
63+
#delete selected Fids from array
64+
for fid_id in [f.id for f in fid_array.get_fids()][::4]:
65+
fid_array.del_fid(fid_id)
66+
print([f.id for f in fid_array.get_fids()])
67+
print(['{:.2f}'.format(i) for i in fid_array.t])
68+
#fid_array.plot_array(upper_ppm=7, lower_ppm=-1, filled=True, azim=-68, elev=25)
69+
6170
#fid_array.save_to_file(filename='fidarray.nmrpy')
6271
#fid_array = nmrpy.from_path(fid_path='fidarray.nmrpy')

nmrpy/docs/quickstart_tutorial.ipynb

Lines changed: 92 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -537,10 +537,23 @@
537537
"cell_type": "markdown",
538538
"metadata": {},
539539
"source": [
540-
"Peak integrals of the complete `FidArray` are stored in `deconvoluted_integrals`, or in each individual `Fid` as `deconvoluted_integrals`.\n",
540+
"Peak integrals of the complete `FidArray` are stored in `deconvoluted_integrals`, or in each individual `Fid` as `deconvoluted_integrals`."
541+
]
542+
},
543+
{
544+
"cell_type": "markdown",
545+
"metadata": {},
546+
"source": [
547+
"## Plotting the time-course"
548+
]
549+
},
550+
{
551+
"cell_type": "markdown",
552+
"metadata": {},
553+
"source": [
554+
"The acquisition times for the individual `Fid` objects in the `FidArray` are stored in an array `t` for easy access. Note that when each `Fid` is collected with multiple transients/scans on the spectrometer, the acquisition time is calculated as the middle of its overall acquisition period.\n",
541555
"\n",
542-
"The species integrals can easily be plotted using the following code:\n",
543-
" "
556+
"We could thus easily plot the time-course of the species integrals using the following code: "
544557
]
545558
},
546559
{
@@ -578,6 +591,60 @@
578591
"ax.legend(loc=0, frameon=False)"
579592
]
580593
},
594+
{
595+
"cell_type": "markdown",
596+
"metadata": {},
597+
"source": [
598+
"## Deleting individual `Fid` objects from a `FidArray`"
599+
]
600+
},
601+
{
602+
"cell_type": "markdown",
603+
"metadata": {},
604+
"source": [
605+
"Sometimes it may be desirable to remove one or more `Fid` objects from a `FidArray`, e.g. to remove outliers from the time-course of concentrations. This can be conveniently achieved with the `del_fid()` method, which takes as argument the `id` of the `Fid` to be removed. The acquisition time array `t` is updated accordingly by removing the corresponding time-point. After this, `deconv_fids()` has to be run again to update the array of peak integrals.\n",
606+
"\n",
607+
"A list of all the `Fid` objects in a `FidArray` is returned by the `get_fids()` method."
608+
]
609+
},
610+
{
611+
"cell_type": "code",
612+
"execution_count": null,
613+
"metadata": {},
614+
"outputs": [],
615+
"source": [
616+
"print([f.id for f in fid_array.get_fids()])"
617+
]
618+
},
619+
{
620+
"cell_type": "code",
621+
"execution_count": null,
622+
"metadata": {},
623+
"outputs": [],
624+
"source": [
625+
"for fid_id in [f.id for f in fid_array.get_fids()][::4]:\n",
626+
" fid_array.del_fid(fid_id)\n",
627+
"\n",
628+
"print([f.id for f in fid_array.get_fids()])\n",
629+
"print(['{:.2f}'.format(i) for i in fid_array.t])"
630+
]
631+
},
632+
{
633+
"cell_type": "markdown",
634+
"metadata": {},
635+
"source": [
636+
"The gaps left by the deleted `Fid` objects are clearly visible in the plotted `FidArray`:"
637+
]
638+
},
639+
{
640+
"cell_type": "code",
641+
"execution_count": null,
642+
"metadata": {},
643+
"outputs": [],
644+
"source": [
645+
"fid_array.plot_array(upper_ppm=7, lower_ppm=-1, filled=True, azim=-68, elev=25)"
646+
]
647+
},
581648
{
582649
"cell_type": "markdown",
583650
"metadata": {},
@@ -609,7 +676,23 @@
609676
"cell_type": "markdown",
610677
"metadata": {},
611678
"source": [
612-
"And reloaded using `from_path()`:"
679+
"The filename need not be specified, if not given the name is taken from `fid_path` and the *.nmrpy* extension is appended. If the file exists, it is not overwritten; a forced overwrite can be specified with:"
680+
]
681+
},
682+
{
683+
"cell_type": "code",
684+
"execution_count": null,
685+
"metadata": {},
686+
"outputs": [],
687+
"source": [
688+
"fid_array.save_to_file(filename='fidarray.nmrpy', overwrite=True)"
689+
]
690+
},
691+
{
692+
"cell_type": "markdown",
693+
"metadata": {},
694+
"source": [
695+
"The `FidArray` can be reloaded using `from_path()`:"
613696
]
614697
},
615698
{
@@ -622,7 +705,7 @@
622705
},
623706
"outputs": [],
624707
"source": [
625-
"fid_array = nmrpy.data_objects.FidArray.from_path(fid_path='fidarray.nmrpy')"
708+
"fid_array = nmrpy.from_path(fid_path='fidarray.nmrpy')"
626709
]
627710
}
628711
],
@@ -642,13 +725,16 @@
642725
"name": "python",
643726
"nbconvert_exporter": "python",
644727
"pygments_lexer": "ipython3",
645-
"version": "3.8.2"
728+
"version": "3.9.6"
646729
},
647730
"toc": {
731+
"base_numbering": 1,
648732
"nav_menu": {},
649733
"number_sections": true,
650734
"sideBar": true,
651735
"skip_h1_title": false,
736+
"title_cell": "Table of Contents",
737+
"title_sidebar": "Contents",
652738
"toc_cell": false,
653739
"toc_position": {},
654740
"toc_section_display": "block",

packaging/conda/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% set version = "0.2.5" %}
1+
{% set version = "0.2.6" %}
22

33
package:
44
name: nmrpy

0 commit comments

Comments
 (0)