Calculating average of each residues obtained for last 50ns

19 views
Skip to first unread message

Viswanath Vittaladevaram

unread,
Oct 16, 2022, 10:15:39 AM10/16/22
to mdnalysis-...@googlegroups.com
Hi,

How to calculate average of reach residues which is obtained during last 50ns?


I need an example of code that would be useful to relate to my  trajectory information obtained

Thanks,
Viswanath.V

Hugo Macdermott-Opeskin

unread,
Oct 17, 2022, 7:13:28 PM10/17/22
to MDnalysis discussion
Hi Viswanath.V

What kind of average do you want. The average position?
If so you will need to collect the positions in a numpy array and then average them using numpy.mean()

Something like this would work. 

positions = []
for ts in u.trajectory:
    positions.append(ts.positions)

# 3D array, atoms, xyz, time
positions_array = np.asarray(positions)

average = np.mean(positions_array, axis=-1)

You may need to double check i have the right axis for the mean etc.

Cheers

Hugo
Reply all
Reply to author
Forward
0 new messages