.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/1-base.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_examples_1-base.py: Simple chemiscope input ======================= This example demonstrates the basic usage of the chemiscope package, reading structures and properties from an ASE package and preparing a chemiscope file to visualize them. Use `chemiscope.show` in a Jupyter notebook for interactive visualization .. GENERATED FROM PYTHON SOURCE LINES 13-18 .. code-block:: Python import ase.io import chemiscope .. GENERATED FROM PYTHON SOURCE LINES 19-20 Load structures from an extended xyz file .. GENERATED FROM PYTHON SOURCE LINES 21-24 .. code-block:: Python frames = ase.io.read("data/showcase.xyz", ":") .. GENERATED FROM PYTHON SOURCE LINES 25-28 A chemiscope widget can be used to visualize structures and properties. This generates a Chemiscope object that is rendered to an interactive widget when executed in a Jupyter notebook. .. GENERATED FROM PYTHON SOURCE LINES 29-46 .. code-block:: Python chemiscope.show( frames=frames, # quickly extract properties from the ASE frames. nb: if you're doing this for # sharing, don't forget to also include metadata such as units and description properties=chemiscope.extract_properties(frames, only=["dipole_ccsd", "ccsd_pol"]), # it's always good to set some metadata to explain what the dataset - title is bare # minimum meta=dict(name="Dipole and polarizability"), # it is possible to set _all_ visualization parameters with a dictionary format. # this is a shortcut for the most basic ones settings=chemiscope.quick_settings( x="ccsd_pol[1]", y="ccsd_pol[2]", color="dipole_ccsd[1]" ), ) .. chemiscope:: _datasets/fig_1-base_001.json.gz :mode: default .. raw:: html


.. GENERATED FROM PYTHON SOURCE LINES 47-51 For sharing with collaborators, or when one does not want to use an interactive notebook, one can also write a JSON (or compressed JSON) file that contains all information about structures and properties, and can be viewed at chemiscope.org Save as a file that can be viewed at chemiscope.org .. GENERATED FROM PYTHON SOURCE LINES 52-63 .. code-block:: Python chemiscope.write_input( "showcase.json.gz", frames=frames, properties=chemiscope.extract_properties(frames, only=["dipole_ccsd", "ccsd_pol"]), meta=dict(name="Dipole and polarizability"), settings=chemiscope.quick_settings( x="ccsd_pol[1]", y="ccsd_pol[2]", color="dipole_ccsd[1]" ), ) .. GENERATED FROM PYTHON SOURCE LINES 64-66 In a notebook it is also possible to load a `.json` file and create an interactive widget from it. .. GENERATED FROM PYTHON SOURCE LINES 67-69 .. code-block:: Python chemiscope.show_input("showcase.json.gz") .. chemiscope:: _datasets/fig_1-base_002.json.gz :mode: default .. raw:: html


.. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.052 seconds) .. _sphx_glr_download_examples_1-base.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 1-base.ipynb <1-base.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 1-base.py <1-base.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 1-base.zip <1-base.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_