.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/vector/plot_0_vector.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_vector_plot_0_vector.py: Vector, 1D{2} dataset --------------------- .. GENERATED FROM PYTHON SOURCE LINES 6-12 The 1D{2} datasets are one-dimensional, :math:`d=1`, with two-component dependent variable, :math:`p=2`. Such datasets are more common with the weather forecast, such as the wind velocity predicting at a location as a function of time. The following is an example of a simulated 1D vector field dataset. .. GENERATED FROM PYTHON SOURCE LINES 12-20 .. code-block:: Python import matplotlib.pyplot as plt import csdmpy as cp filename = "https://www.ssnmr.org/sites/default/files/CSDM/vector/1D_vector.csdf" vector_data = cp.load(filename) print(vector_data.data_structure) .. rst-class:: sphx-glr-script-out .. code-block:: none { "csdm": { "version": "1.0", "read_only": true, "timestamp": "2019-02-12T10:00:00Z", "dimensions": [ { "type": "linear", "count": 10, "increment": "1.0 m", "quantity_name": "length", "reciprocal": { "quantity_name": "wavenumber" } } ], "dependent_variables": [ { "type": "internal", "numeric_type": "float32", "quantity_type": "vector_2", "components": [ [ "0.6907923, 0.31292602, ..., 0.40570852, 0.7005596" ], [ "0.5603441, 0.06866818, ..., 0.48200375, 0.15077808" ] ] } ] } } .. GENERATED FROM PYTHON SOURCE LINES 21-23 The tuple of the dimension and dependent variable instances from this example are .. GENERATED FROM PYTHON SOURCE LINES 23-26 .. code-block:: Python x = vector_data.dimensions y = vector_data.dependent_variables .. GENERATED FROM PYTHON SOURCE LINES 27-28 with coordinates .. GENERATED FROM PYTHON SOURCE LINES 28-30 .. code-block:: Python print(x[0].coordinates) .. rst-class:: sphx-glr-script-out .. code-block:: none [0. 1. 2. 3. 4. 5. 6. 7. 8. 9.] m .. GENERATED FROM PYTHON SOURCE LINES 31-35 In this example, the components of the dependent variable are vectors as seen from the :attr:`~csdmpy.DependentVariable.quantity_type` attribute of the corresponding dependent variable instance. .. GENERATED FROM PYTHON SOURCE LINES 35-37 .. code-block:: Python print(y[0].quantity_type) .. rst-class:: sphx-glr-script-out .. code-block:: none vector_2 .. GENERATED FROM PYTHON SOURCE LINES 38-40 From the value `vector_2`, `vector` indicates a vector dataset, while `2` indicates the number of vector components. .. GENERATED FROM PYTHON SOURCE LINES 42-43 **Visualizing the dataset** .. GENERATED FROM PYTHON SOURCE LINES 43-48 .. code-block:: Python plt.figure(figsize=(5, 3.5)) cp.plot(vector_data) plt.tight_layout() plt.show() .. image-sg:: /auto_examples/vector/images/sphx_glr_plot_0_vector_001.png :alt: plot 0 vector :srcset: /auto_examples/vector/images/sphx_glr_plot_0_vector_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.284 seconds) .. _sphx_glr_download_auto_examples_vector_plot_0_vector.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_vector.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_0_vector.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_