<commit_before>#!/usr/bin/env python
import numpy as np
import matplotlib.pyplot as plt
import mpl_toolkits.mplot3d.axes3d as p3
import matplotlib.animation as animation

def update_lines(num,data,lines):
    """ for frame number 'num', update a list of matplotlib line objects 'lines'
     with data for the given frame 'data[num]' """
    conf = data[num,:,:] # current particle configuration
    # loop through each one of the 16 dots and the 16 particles together
    for line,pos in zip(lines,conf):
        x,y,z = pos
        line.set_data(x,y)
        line.set_3d_properties(z)
    # end for
# end def update_lines

if __name__ == '__main__':
    # Attach 3D axis to the figure
    fig = plt.figure()
    ax = p3.Axes3D(fig)

    nframe = 100
    natom  = 16
    ndim   = 3

    # local particle positions, must have shape (nframe,natom*ndim)
    data = np.loadtxt('nxyz.dat')
    data = data.reshape(nframe,natom,ndim)

    # make first frame: 16 dots, one for each particle
    lines = [ax.plot( data[0,:,0], data[0,:,1], data[0,:,2], 'o' )[0] for dat in data[0]]
    #plt.show()

    # Creating the Animation object
    ani = animation.FuncAnimation(fig, update_lines, nframe, fargs=(data, lines),
                                  interval=50, blit=False)
    plt.show()
# end __main__<commit_msg>automatically determine trajectory file shape<commit_after>#!/usr/bin/env python
import numpy as np
import matplotlib.pyplot as plt
import mpl_toolkits.mplot3d.axes3d as p3
import matplotlib.animation as animation

def update_lines(num,data,lines):
    """ for frame number 'num', update a list of matplotlib line objects 'lines'
     with data for the given frame 'data[num]' """
    conf = data[num,:,:] # current particle configuration
    # loop through each one of the 16 dots and the 16 particles together
    for line,pos in zip(lines,conf):
        x,y,z = pos
        line.set_data(x,y)
        line.set_3d_properties(z)
    # end for
# end def update_lines

if __name__ == '__main__':

    ndim = 3

    # local particle positions, must have shape (nframe,natom*ndim)
    data = np.loadtxt('nxyz.dat')
    nframe,nad = data.shape
    natom = nad/ndim
    data = data.reshape(nframe,natom,ndim)

    # Attach 3D axis to the figure
    fig = plt.figure()
    ax = p3.Axes3D(fig)

    # make first frame: 16 dots, one for each particle
    lines = [ax.plot( data[0,:,0], data[0,:,1], data[0,:,2], 'o' )[0] for dat in data[0]]
    #plt.show()

    # Creating the Animation object
    ani = animation.FuncAnimation(fig, update_lines, nframe, fargs=(data, lines),
                                  interval=50, blit=False)
    plt.show()
# end __main__
{'fraction_non_alphanumeric': 0.11444652908067542, 'fraction_numerical': 0.019887429643527205, 'mean_word_length': 3.0332829046898637, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4144668', 'n_tokens_mistral': 949, 'n_tokens_neox': 892, 'n_words': 275}