Skip to content

Commit

Permalink
Added desc of usage
Browse files Browse the repository at this point in the history
  • Loading branch information
sofiia-chorna committed Sep 3, 2024
1 parent ba8b273 commit 89bfd9b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
8 changes: 7 additions & 1 deletion python/chemiscope/explore.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def explore(frames, featurize=None, properties=None, environments=None, mode="de
# Define a function for dimensionality reduction
def soap_kpca_featurize(frames):
def soap_kpca_featurize(frames, _environments):
# Compute descriptors
soap = dscribe.descriptors.SOAP(
species=["C"],
Expand Down Expand Up @@ -175,6 +175,12 @@ def soap_pca_featurize(frames, centers=None):


def _pick_env_frames(envs, frames):
"""
Get environment indices par structures and pick corresponding frames
:param: list envs: each element is a list of [env_index, atom_index, cutoff]
:param: list frames: list of frames
"""
grouped_envs = {}
picked_frames = []
for [env_index, atom_index, _cutoff] in envs:
Expand Down
26 changes: 18 additions & 8 deletions python/examples/6-explore.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ def fetch_dataset(filename, base_url="https://zenodo.org/records/12748925/files/
#
# Provide the frames to the :py:func:`chemiscope.explore`. It will generate a Chemiscope
# interactive widget with the reduced dimensionality of data.
envs = [(0, 0, 3.5),
(1, 1, 3.5),
(2, 2, 3.5)]
chemiscope.explore(frames, environments=envs)
chemiscope.explore(frames)

# %%
#
Expand All @@ -87,6 +84,18 @@ def fetch_dataset(filename, base_url="https://zenodo.org/records/12748925/files/
# properties to be used in visualization.


# %%
#
# Besides this, it is possible to run the dimentionality reduction algorithm and display
# specific atom-centered environments. They can be manually defined by specifying a list
# of tuples in the format ``[index of structure, index of atom, cutoff]``, as shown in
# this example.
#
# Alternatively, the environments can be extracted from the frames using the function
# :py:func:`all_atomic_environments` or :py:func:`librascal_atomic_environments`.

chemiscope.explore(frames, environments=[(0, 0, 3.5), (1, 0, 3.5), (2, 1, 3.5)])

# %%
#
# Example with custom featurizer and custom properties
Expand All @@ -105,10 +114,11 @@ def fetch_dataset(filename, base_url="https://zenodo.org/records/12748925/files/

# %%
#
# Define the function ``soap_kpca_featurize`` which takes one argument
# (``frames``). This argument contains the structures provided to
# :py:func:`chemiscope.explore` and is internally
# passed to the ``featurize`` function.
# Define the function ``soap_kpca_featurize`` which takes two arguments
# (``frames``, which contains the structures provided to
# :py:func:`chemiscope.explore` and internally passed to the ``featurize`` function;
# ``environments``, optional aurgument with the atom-centered environments,
# if they were provided to the :py:func:`chemiscope.explore`.


def soap_kpca_featurize(frames, _environments):
Expand Down

0 comments on commit 89bfd9b

Please sign in to comment.