def test_xyz(self): traj = pt.iterload("./data/Tc5b.x", "./data/Tc5b.top") frame = Frame() frame.append_xyz(traj[0].xyz) aa_eq(frame.xyz, traj[0].xyz) aa_eq(frame.xyz.flatten(), traj[0].xyz.flatten()) aa_eq(np.array(frame._buffer1d), traj[0].xyz.flatten())
def test_xyz(self): traj = pt.iterload(fn('Tc5b.x'), fn('Tc5b.top')) frame = Frame() frame.append_xyz(traj[0].xyz) aa_eq(frame.xyz, traj[0].xyz) aa_eq(frame.xyz.flatten(), traj[0].xyz.flatten()) aa_eq(np.array(frame._buffer1d), traj[0].xyz.flatten())
def merge_frames(iterables): """merge from frames to a single Frame. Order matters. Examples -------- >>> import pytraj as pt >>> traj = pt.load_sample_data('tz2') >>> traj[0] <Frame with 5293 atoms> >>> merge_frames(traj(0, 3)) <Frame with 15879 atoms> """ from pytraj import Frame xyz = np.vstack((f.xyz.copy() for f in iterables)) frame = Frame() frame.append_xyz(xyz) return frame
n_frames = traj.n_frames if rank == 0: ref = traj[0] ref_xyz = np.asarray(ref.xyz, dtype=np.float64) else: ref = None ref_xyz = np.empty((n_atoms, 3), dtype=np.float64) # broadcast ref_xyz to other cores from master comm.Bcast([ref_xyz, MPI.DOUBLE]) if rank != 0: # need to reconstruct ref ref = Frame() ref.append_xyz(ref_xyz) _ref = ref.copy() def rmsd_mpi(traj, _ref): arr0 = pyca.calc_rmsd("@CA", traj, traj.top, _ref) return arr0 arr0 = rmsd_mpi(traj, _ref) if rank == 0: data = np.empty(size * traj.n_frames, dtype=np.float64) else: data = None