.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/sparse/plot_0_1D_sparse.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_sparse_plot_0_1D_sparse.py: Sparse along one dimension, 2D{1,1} dataset ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. GENERATED FROM PYTHON SOURCE LINES 6-12 The following is an example [#f2]_ of a 2D{1,1} sparse dataset with two-dimensions, :math:`d=2`, and two, :math:`p=2`, sparse single-component dependent-variables, where the component is sparsely sampled along one dimension. The following is an example of a hypercomplex acquisition of the NMR dataset. Let's import the CSD model data-file. .. GENERATED FROM PYTHON SOURCE LINES 12-17 .. code-block:: Python import csdmpy as cp filename = "https://www.ssnmr.org/sites/default/files/CSDM/sparse/iglu_1d.csdf" sparse_1d = cp.load(filename) .. GENERATED FROM PYTHON SOURCE LINES 18-20 There are two linear dimensions and two single-component sparse dependent variables. The tuple of the dimension and the dependent variable instances are .. GENERATED FROM PYTHON SOURCE LINES 20-23 .. code-block:: Python x = sparse_1d.dimensions y = sparse_1d.dependent_variables .. GENERATED FROM PYTHON SOURCE LINES 24-25 The coordinates, viewed only for the first ten coordinates, are .. GENERATED FROM PYTHON SOURCE LINES 25-27 .. code-block:: Python print(x[0].coordinates[:10]) .. rst-class:: sphx-glr-script-out .. code-block:: none [ 0. 192. 384. 576. 768. 960. 1152. 1344. 1536. 1728.] us .. GENERATED FROM PYTHON SOURCE LINES 28-30 .. code-block:: Python print(x[1].coordinates[:10]) .. rst-class:: sphx-glr-script-out .. code-block:: none [ 0. 192. 384. 576. 768. 960. 1152. 1344. 1536. 1728.] us .. GENERATED FROM PYTHON SOURCE LINES 31-32 Converting the coordinates to `ms`. .. GENERATED FROM PYTHON SOURCE LINES 32-35 .. code-block:: Python x[0].to("ms") x[1].to("ms") .. GENERATED FROM PYTHON SOURCE LINES 36-37 **Visualizing the dataset** .. GENERATED FROM PYTHON SOURCE LINES 37-52 .. code-block:: Python import matplotlib.pyplot as plt # split the CSDM object with two dependent variables into two CSDM objects with single # dependent variables. cos, sin = sparse_1d.split() # cosine data plt.figure(figsize=(5, 3.5)) ax = plt.subplot(projection="csdm") cb = ax.contourf(cos.real) plt.colorbar(cb, ax=ax) plt.tight_layout() plt.show() .. image-sg:: /auto_examples/sparse/images/sphx_glr_plot_0_1D_sparse_001.png :alt: cos :srcset: /auto_examples/sparse/images/sphx_glr_plot_0_1D_sparse_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 53-62 .. code-block:: Python # sine data plt.figure(figsize=(5, 3.5)) ax = plt.subplot(projection="csdm") cb = ax.contourf(sin.real) plt.colorbar(cb, ax=ax) plt.tight_layout() plt.show() .. image-sg:: /auto_examples/sparse/images/sphx_glr_plot_0_1D_sparse_002.png :alt: sin :srcset: /auto_examples/sparse/images/sphx_glr_plot_0_1D_sparse_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 63-68 .. rubric:: Citation .. [#f2] Balsgart NM, Vosegaard T., Fast Forward Maximum entropy reconstruction of sparsely sampled data., J Magn Reson. 2012, 223, 164-169. doi: 10.1016/j.jmr.2012.07.002 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.140 seconds) .. _sphx_glr_download_auto_examples_sparse_plot_0_1D_sparse.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_0_1D_sparse.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_0_1D_sparse.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_