Beispiel #1
0
    def test_clone(self):
        store = Storage(filename=self.filename, template=self.template_snapshot, mode='w')
        assert(os.path.isfile(self.filename))

        copy = self.template_snapshot.copy()
        store.save(copy)

        store.save(self.traj)

        store.clone(filename=self.filename_clone, subset = self.solute_indices)

        # clone the storage and reduce the number of atoms to only solute

        store2 = Storage(filename=self.filename_clone, mode='a')

        # do some tests, if this is still the same data

        compare_snapshot(
            store2.snapshots.load(0),
            store.snapshots.load(0).subset(self.solute_indices)
        )

        compare_snapshot(
            store2.snapshots.load(1),
            store.snapshots.load(1).subset(self.solute_indices)
        )
        store.close()
        store2.close()

        pass
    def test_clone(self):
        store = Storage(filename=self.filename, template=self.template_snapshot, mode='w')
        assert(os.path.isfile(self.filename))

        copy = self.template_snapshot.copy()
        store.save(copy)

        store.save(self.traj)

        store.clone(filename=self.filename_clone, subset = self.solute_indices)

        # clone the storage and reduce the number of atoms to only solute

        store2 = Storage(filename=self.filename_clone, mode='a')

        # do some tests, if this is still the same data

        compare_snapshot(
            store2.snapshots.load(0),
            store.snapshots.load(0).subset(self.solute_indices)
        )

        compare_snapshot(
            store2.snapshots.load(1),
            store.snapshots.load(1).subset(self.solute_indices)
        )
        store.close()
        store2.close()

        pass
"""
This is an example file of how to remove water from a netCDF file.

@author: Jan-Hendrik Prinz
"""

from openpathsampling.storage import Storage

if __name__=="__main__":

    storage = Storage(
        filename="trajectory.nc",
        mode='a'
    )

    solute = range(22)
    storage.clone('test_solute.nc', subset=None)
    storage.close()

    storage2 = Storage('test_solute.nc')
    storage2.clone('test_solute2.nc', subset=solute)