.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        Click :ref:`here <sphx_glr_download_auto_examples_sparse_plot_1_2D_sparse.py>`     to download the full example code
    .. rst-class:: sphx-glr-example-title

    .. _sphx_glr_auto_examples_sparse_plot_1_2D_sparse.py:


Sparse along two dimensions, 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 two dimensions.

Let's import the CSD model data-file and look at its data structure.


.. code-block:: default

    import csdmpy as cp

    filename = "https://osu.box.com/shared/static/kaos28g47brtswi6mgsgaap5qlahp1zo.csdf"
    sparse_2d = 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_2d.dimensions
    y = sparse_2d.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")








**Visualize 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_1_2D_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  0.385 seconds)


.. _sphx_glr_download_auto_examples_sparse_plot_1_2D_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_1_2D_sparse.py <plot_1_2D_sparse.py>`



  .. container:: sphx-glr-download sphx-glr-download-jupyter

     :download:`Download Jupyter notebook: plot_1_2D_sparse.ipynb <plot_1_2D_sparse.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
