.. only:: html
.. note::
:class: sphx-glr-download-link-note
Click :ref:`here ` 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
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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.
Let's import the CSD model data-file.
.. code-block:: default
import csdmpy as cp
filename = "https://osu.box.com/shared/static/1ltzzbdyeo5bn7xuxmdkxj3e4o1xvvjc.csdf"
sparse_1d = cp.load(filename)
There are two linear dimensions and two single-component sparse dependent variables.
The tuple of the dimension and the dependent variable instances are
.. code-block:: default
x = sparse_1d.dimensions
y = sparse_1d.dependent_variables
The coordinates, viewed only for the first ten coordinates, are
.. code-block:: default
print(x[0].coordinates[:10])
.. rst-class:: sphx-glr-script-out
Out:
.. code-block:: none
[ 0. 192. 384. 576. 768. 960. 1152. 1344. 1536. 1728.] us
.. code-block:: default
print(x[1].coordinates[:10])
.. rst-class:: sphx-glr-script-out
Out:
.. code-block:: none
[ 0. 192. 384. 576. 768. 960. 1152. 1344. 1536. 1728.] us
Converting the coordinates to `ms`.
.. code-block:: default
x[0].to("ms")
x[1].to("ms")
**Visualizing the dataset**
.. code-block:: default
import matplotlib.pyplot as plt
plt.contourf(
x[0].coordinates.value,
x[1].coordinates.value,
y[0].components[0].real,
cmap="gray_r",
)
plt.xlabel(x[0].axis_label)
plt.ylabel(x[1].axis_label)
plt.title(y[0].name)
plt.show()
.. image:: /auto_examples/sparse/images/sphx_glr_plot_0_1D_sparse_001.png
:class: sphx-glr-single-img
.. 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.854 seconds)
.. _sphx_glr_download_auto_examples_sparse_plot_0_1D_sparse.py:
.. only :: html
.. container:: sphx-glr-footer
:class: sphx-glr-footer-example
.. container:: sphx-glr-download sphx-glr-download-python
:download:`Download Python source code: plot_0_1D_sparse.py `
.. container:: sphx-glr-download sphx-glr-download-jupyter
:download:`Download Jupyter notebook: plot_0_1D_sparse.ipynb `
.. only:: html
.. rst-class:: sphx-glr-signature
`Gallery generated by Sphinx-Gallery `_