From: Robin Betz (robin_at_robinbetz.com)
Date: Wed Aug 09 2017 - 14:01:11 CDT

I use VMD with the Python interpreter to apply smoothing functions to the
coordinates in-memory.
Here's an implementation of the Savitsky-Golay filter which I find distorts
rotating rings (Phe, etc) less than the built-in averaging. You can
probably do the same with the tcl interface, but I'm not quite so familiar
with its available functionality.

import numpy as np
from scipy.signal import savgol_filter
def smooth_savitsky_golay(molid, window=5, polyorder=3):
    smoother = np.empty((molecule.numframes(molid),
molecule.numatoms(molid)*3))
    print smoother.shape
    for t in range(molecule.numframes(molid)):
        smoother[t] = vmdnumpy.timestep(molid, t).flatten()

    smoothed = savgol_filter(smoother, window, polyorder, axis=0,
mode="nearest")

    for t in range(molecule.numframes(molid)):
        conv = smoothed[t].reshape((molecule.numatoms(molid), 3))
        np.copyto(vmdnumpy.timestep(molid, t), conv)

Hope this helps,
Robin

On Wed, Aug 9, 2017 at 10:25 AM, Albert <mailmd2011_at_gmail.com> wrote:

> I could do this in Gromacs before I load it to VMD. However, the smooth
> the .xtc file has the same problem observed in VMD.
>
> Albert
>
> On 08/09/2017 04:15 PM, Axel Kohlmeyer wrote:
>
>
>
> On Wed, Aug 9, 2017 at 10:00 AM, Albert <mailmd2011_at_gmail.com> wrote:
>
>> so there is no solution for this issue currently?
>>
>
> ​it is not really an issue in my opinion. VMD does what you are asking for
> and it is not VMD's problem that you don't like it.
>
> you are free to write a tool that post-processes your trajectory
> differently outside of VMD and denoises it more to your liking. however,
> finding an algorithm that does what you seem to be looking for, is far from
> trivial. i used to have a modification for VMD, that implements a modified
> windowed filter that would not just compute an average, but rather would do
> a fit to a higher order polynomial. it helps for certain things, but
> doesn't resolve the deformation entirely.
>
> axel.
> ​
>
>
>
>>
>> regards
>>
>>
>>
>> On 08/09/2017 12:40 PM, Axel Kohlmeyer wrote:
>>
>>
>>
>> On Wed, Aug 9, 2017 at 4:59 AM, Albert <mailmd2011_at_gmail.com> wrote:
>>
>>> Hello,
>>>
>>> I tick the smooth trajectory function in VMD. However, I noticed that
>>> some of my molecule is distorted and looks very weird. I am just wondering
>>> how to solve this problem?
>>>
>>
>> ​the trajectory smoothing in VMD works by simply applying a window
>> average to atom positions. the observed distortion is a consequence of that
>> and cannot be avoided unless you would implement a much more complex
>> algorithm.
>>
>> axel.
>>
>>
>>
>>>
>>> Thanks a lot
>>>
>>> Albert
>>>
>>>
>>
>>
>> --
>> Dr. Axel Kohlmeyer akohlmey_at_gmail.com http://goo.gl/1wk0
>> College of Science & Technology, Temple University, Philadelphia PA, USA
>> International Centre for Theoretical Physics, Trieste. Italy.
>>
>>
>>
>
>
> --
> Dr. Axel Kohlmeyer akohlmey_at_gmail.com http://goo.gl/1wk0
> College of Science & Technology, Temple University, Philadelphia PA, USA
> International Centre for Theoretical Physics, Trieste. Italy.
>
>
>