#!/usr/bin/env python
# -*- coding: utf-8; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- 
# vim:fenc=utf-8:et:sw=4:ts=4:sts=4:tw=0

import os, sys
import numpy as np
from progressbar import ProgressBar, Percentage, Bar, ETA, FileTransferSpeed, \
     RotatingMarker, ReverseBar, SimpleProgress

from oppvasp.plotutils import DisplacementPlot

dp = DisplacementPlot()
dp.read_trajectory( dir = './' )

# Find the diffusivity of all atoms:
m = 65

D = np.zeros(m)
pbar = ProgressBar(widgets=['Henter diff koeff...',Percentage(),Bar()], maxval = m).start()    
for at in range(m):
    pbar.update(at)
    D[at] = dp.get_diffusion_coeff(at)[0]
pbar.finish()

# Find the 3 atoms with the highest diffusivity:
arg = np.argsort(D)
include_atoms = arg[:-4:-1] # return the last three values (not including -4)


#pbar = ProgressBar(widgets=['Smoothen trajectories...',Percentage(),Bar()], maxval = m).start()    
styles = [ { 'color' : c } for c in ['red','blue','black'] ]