Write trajectories and add some scripts for analyzing trajectories