Skip to content

Commit

Permalink
Fix plot x axis
Browse files Browse the repository at this point in the history
  • Loading branch information
stefsmeets committed Jul 15, 2024
1 parent 668b24e commit bdc0427
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/gemdat/plots/matplotlib/_msd_per_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def msd_per_element(
fig, ax = plt.subplots()

# Since we want to plot in picosecond, we convert the time units
time_ps = trajectory.time_step * 1e12
time_ps = trajectory.time_step / 1000
t_values = np.arange(len(trajectory)) * time_ps

for sp in species:
Expand Down
2 changes: 1 addition & 1 deletion src/gemdat/plots/plotly/_msd_per_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def msd_per_element(*, trajectory: Trajectory) -> go.Figure:
species = list(set(trajectory.species))

# Since we want to plot in picosecond, we convert the time units
time_ps = trajectory.time_step * 1e12
time_ps = trajectory.time_step / 1000

for sp in species:
traj = trajectory.filter(sp.symbol)
Expand Down
11 changes: 7 additions & 4 deletions src/gemdat/trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import hashlib
import json
import pickle
import re
import xml.etree.ElementTree as ET
from itertools import compress, pairwise
from pathlib import Path
Expand All @@ -26,6 +27,9 @@
from .volume import Volume


SP_NAME = re.compile(r'([a-zA-Z]+)')


def _lengths(vectors: np.ndarray, lattice: Lattice) -> np.ndarray:
"""Calculate vector lengths using the metric tensor (Dunitz 1078, p227).
Expand Down Expand Up @@ -371,7 +375,6 @@ def from_gromacs(
cache : Optional[Path], optional
Path to cache data for vasprun.xml
Returns
-------
trajectory : Trajectory
Expand All @@ -383,7 +386,6 @@ def from_gromacs(

topology_file = str(topology_file)
coords_file = str(coords_file)
edr_file = str(edr_file)

if not cache:
kwargs = {
Expand Down Expand Up @@ -414,7 +416,7 @@ def from_gromacs(
lattice = Lattice.from_parameters(*utraj.trajectory[0].dimensions)
coords = lattice.get_fractional_coords(coords)

species = [Element(sp.capitalize()) for sp in utraj.atoms.names]
species = [Element(SP_NAME.match(sp).group().capitalize()) for sp in utraj.atoms.names] # type: ignore

site_properties = {
'residue': [sp.residue for sp in utraj.atoms],
Expand All @@ -427,14 +429,15 @@ def from_gromacs(
}

if edr_file:
edr_file = str(edr_file)
aux = mda.auxiliary.EDR.EDRReader(edr_file)
metadata['aux'] = aux.get_data(aux.terms)

obj = cls(
species=species,
coords=coords,
lattice=lattice,
time_step=utraj.trajectory.dt * 1000,
time_step=utraj.trajectory.dt * 1000, # ps -> fs
constant_lattice=constant_lattice,
metadata=metadata,
site_properties=site_properties,
Expand Down

0 comments on commit bdc0427

Please sign in to comment.