You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
otherwise I think that it was not completely clear how many structures were considered in the plot. In my specific case, it is interesting to know how many steps did it take to optimize the molecular structure with quantum mechanics. Besides, it also helps to point towards the first and last structure, which could be a bit confusing without a color reference.
I hope it may be of interest and let me know if any adjustments are needed!
now I got the FutureWarning regarding Downcasting again. Uncommenting pd.set_option("future.no_silent_downcasting", True) removes it. Otherwise your addition is nice. However, it works only good for a large number of molecules where the number of colors is equal or the number of molecules is larger than the number of colors in the colormap. Try it with two or three molecules to check what I mean.
As far as I can tell, it was related to how the **xyz_df_list ** was constructed. The total number of xyz was always minus one.
Instead, if the following function is employed to construct the same list, the issue is solved, and one can get a plot where two and three xyz have different colors.
Let me know if you find it useful.
Best,
Enric
def read_xyz_to_dataframe(file_path):
"""
Given a text file with concatenated xyz coordinates, the function generates
a list of panda objects for each xyz.
"""
with open(file_path, 'r') as file:
lines = file.readlines()
data = []
i = 0
while i < len(lines):
# Number of atoms (first line)
num_atoms = int(lines[i].strip())
i += 1
# Second line (energy or other information)
i += 1
# Temporal list for every xyz
data2 = []
# Extract atomic coordinates
for _ in range(num_atoms):
line = lines[i].split()
element = line[0]
x, y, z = map(float, line[1:4])
data2.append([element, x, y, z])
i += 1
# List of xyz
data.append(data2)
# Now convert it to list of pd objects
xyz_df_list = list()
columns = ["element", "x", "y", "z"]
for structure in data:
xyzdata = structure
df = pd.DataFrame(xyzdata, columns=columns)
xyz_df_list.append(df)
return xyz_df_list
xyz_df_list = read_xyz_to_dataframe(args.filename[0])
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi Sebastian,
I’ve added a colorbar to facilitate the interpretation of the plot that arises from:
python3 xyzoverlay.py multi-mol_trj.xyz -aa -vcm -cm coolwarm -ee Hthe new feature should appear by just adding the keyboard
-cb True:python3 xyzoverlay.py multi-mol_trj.xyz -aa -vcm -cm coolwarm -cb True -ee Hotherwise I think that it was not completely clear how many structures were considered in the plot. In my specific case, it is interesting to know how many steps did it take to optimize the molecular structure with quantum mechanics. Besides, it also helps to point towards the first and last structure, which could be a bit confusing without a color reference.
I hope it may be of interest and let me know if any adjustments are needed!
Best,
Enric