lab-cosmo / chemiscope

An interactive structure/property explorer for materials and molecules
http://chemiscope.org
BSD 3-Clause "New" or "Revised" License
131 stars 32 forks source link

Dealing with only specific atom environments #134

Closed sandipde closed 2 years ago

sandipde commented 3 years ago

At the moment, there is a hard restriction on the way the environment centric viewer can be activated. The data for all the all the atoms in the structure has be supplied. In practice, it is often the case that I want to build the map focussing on only specific atoms of interest (eg. Cu atoms in a Zeolite). It would be great to

  1. either remove the restriction by only checking consistency on the number of descriptors and the env prop
  2. Allowing "None" values in the descriptors and properties for the environments of not interest. I believe Plotly can handle None values by hiding them. In your library however you are checking for string/float and hence my attempt to pass None failed.
Luthaf commented 3 years ago

either remove the restriction by only checking consistency on the number of descriptors and the env prop

This is a duplicate of #38, but with a better explanation of the problem, so I'll close #38 in favor of this one.

Allowing "None" values in the descriptors and properties for the environments of not interest. I believe Plotly can handle None values by hiding them. In your library however you are checking for string/float and hence my attempt to pass None failed.

The trick we have been using is to set properties for the environments we don't want to show on the map to NaN, and this causes plotly to hide them.

I don't know how the plotly python bindings deal with None, since there is no such thing in Javascript. Maybe None values are mapped to null, and plotly hide these? I'll try to look into this.

Luthaf commented 3 years ago

To be clear, even if the NaN trick should work fine we still want to support this use case natively, if nothing else to reduce the size of the JSON files.

sandipde commented 3 years ago

Thanks @Luthaf for the prompt response. I did not check np.NaN option but if that works then that's a equivalent work around of the None option (yes in js it would be null). As you correctly said it would be indeed great to have native support for this.

Luthaf commented 2 years ago

Fixed by #166!

Here is a script one can use to convert from the "old" NaN based representation of sparse environment list to the new format: https://gist.github.com/Luthaf/489599acbc1633451ca59838a55dd1a0