.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/1D_1_examples/plot_6_Mass.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_1D_1_examples_plot_6_Mass.py: Mass spectrometry (sparse) dataset ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. GENERATED FROM PYTHON SOURCE LINES 6-10 The following mass spectrometry data of acetone is an example of a sparse dataset. Here, the CSDM data file holds a sparse dependent variable. Upon import, the components of the dependent variable sparsely populates the coordinate grid. The remaining unpopulated coordinates are assigned a zero value. .. GENERATED FROM PYTHON SOURCE LINES 10-18 .. code-block:: Python import matplotlib.pyplot as plt import csdmpy as cp filename = "https://www.ssnmr.org/sites/default/files/CSDM/MassSpec/acetone.csdf" mass_spec = cp.load(filename) print(mass_spec.data_structure) .. rst-class:: sphx-glr-script-out .. code-block:: none { "csdm": { "version": "1.0", "read_only": true, "timestamp": "2019-06-23T17:53:26Z", "description": "MASS spectrum of acetone", "dimensions": [ { "type": "linear", "count": 51, "increment": "1.0", "coordinates_offset": "10.0", "label": "m/z" } ], "dependent_variables": [ { "type": "internal", "name": "acetone", "numeric_type": "float32", "quantity_type": "scalar", "component_labels": [ "relative abundance" ], "components": [ [ "0.0, 0.0, ..., 10.0, 0.0" ] ] } ] } } .. GENERATED FROM PYTHON SOURCE LINES 19-20 Here, the coordinates along the dimension are .. GENERATED FROM PYTHON SOURCE LINES 20-22 .. code-block:: Python print(mass_spec.dimensions[0].coordinates) .. rst-class:: sphx-glr-script-out .. code-block:: none [10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60.] .. GENERATED FROM PYTHON SOURCE LINES 23-24 and the corresponding components of the dependent variable, .. GENERATED FROM PYTHON SOURCE LINES 24-26 .. code-block:: Python print(mass_spec.dependent_variables[0].components[0]) .. rst-class:: sphx-glr-script-out .. code-block:: none [ 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 9. 9. 49. 0. 0. 79. 1000. 19. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 270. 10. 0.] .. GENERATED FROM PYTHON SOURCE LINES 27-29 Note, only eight values were listed in the dependent variable's `components` attribute in the `.csdf` file. The remaining component values were set to zero. .. GENERATED FROM PYTHON SOURCE LINES 29-34 .. code-block:: Python plt.figure(figsize=(5, 3.5)) ax = plt.subplot(projection="csdm") ax.plot(mass_spec) plt.tight_layout() plt.show() .. image-sg:: /auto_examples/1D_1_examples/images/sphx_glr_plot_6_Mass_001.png :alt: plot 6 Mass :srcset: /auto_examples/1D_1_examples/images/sphx_glr_plot_6_Mass_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.250 seconds) .. _sphx_glr_download_auto_examples_1D_1_examples_plot_6_Mass.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_6_Mass.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_6_Mass.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_