.. 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_1D_1_examples_plot_6_Mass.py: Mass spectrometry (sparse) dataset ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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. .. code-block:: default import csdmpy as cp filename = "https://osu.box.com/shared/static/ul3rajps49zfuz9ozj3j5xsjmgeuybuy.csdf" mass_spec = cp.load(filename) print(mass_spec.data_structure) .. rst-class:: sphx-glr-script-out 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" ] ] } ] } } Here, the coordinates along the dimension are .. code-block:: default print(mass_spec.dimensions[0].coordinates) .. rst-class:: sphx-glr-script-out 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.] and the corresponding components of the dependent variable, .. code-block:: default print(mass_spec.dependent_variables[0].components[0]) .. rst-class:: sphx-glr-script-out 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.] 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. .. code-block:: default cp.plot(mass_spec) .. image:: /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 1.133 seconds) .. _sphx_glr_download_auto_examples_1D_1_examples_plot_6_Mass.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_6_Mass.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_6_Mass.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_