예제 #1
0
파일: pdf.py 프로젝트: sciapp/pyMolDyn
    def continuous_coordinates(coords, volume, resolution):
        cachedir = os.path.expanduser(config.Path.cache_dir)
        cachepath = os.path.join(cachedir, 'discretization_cache.hdf5')
        dcache = DiscretizationCache(cachepath)
        disc = dcache.get_discretization(volume, resolution)

        return np.array(map(disc.discrete_to_continuous, coords))
예제 #2
0
파일: pdf.py 프로젝트: sciapp/pyMolDyn
    def continuous_coordinates(coords, volume, resolution):
        cachedir = os.path.expanduser(config.Path.cache_dir)
        cachepath = os.path.join(cachedir, 'discretization_cache.hdf5')
        dcache = DiscretizationCache(cachepath)
        disc = dcache.get_discretization(volume, resolution)

        return np.array(map(disc.discrete_to_continuous, coords))
예제 #3
0
파일: pdf.py 프로젝트: sciapp/pyMolDyn
    def __init__(self, *args):
        """
        Create a sample from atom and cavity positions and smooth them to
        get the PDFs

        The constructor can be called in two ways:

        - ``PDF(results)`` :
            retrieve the data from :class:`core.data.Results`

        - ``PDF(positions, elements, cavitycenters, volume)`` :
            use the given arrays and the volume object
        """
        if len(args) == 1:
            results = args[0]
            positions = results.atoms.positions
            elements = results.atoms.elements
            volume = results.atoms.volume
            if results.domains is not None:
                centers = results.domains.centers
                cachedir = os.path.expanduser(config.Path.cache_dir)
                cachepath = os.path.join(cachedir, 'discretization_cache.hdf5')
                dcache = DiscretizationCache(cachepath)
                disc = dcache.get_discretization(volume, results.resolution)
                centers = map(disc.discrete_to_continuous, centers)
            else:
                centers = []
        elif len(args) == 4:
            positions, elements, centers, volume = args
        else:
            raise TypeError("PDF expects 1 or 4 parameters")

        self.positions = np.array(positions, copy=False)
        self.elements = np.array(elements, dtype="|S4", copy=False)
        self.centers = np.array(centers, copy=False)
        self.volume = volume
        self.num_atoms = np.where(self.elements != "cav")[0].size
        self.numberdensity = float(self.num_atoms) / self.volume.volume

        self.stats = self._genstats(self.positions,
                                    self.elements,
                                    self.centers,
                                    self.volume)
예제 #4
0
파일: pdf.py 프로젝트: sciapp/pyMolDyn
    def __init__(self, *args):
        """
        Create a sample from atom and cavity positions and smooth them to
        get the PDFs

        The constructor can be called in two ways:

        - ``PDF(results)`` :
            retrieve the data from :class:`core.data.Results`

        - ``PDF(positions, elements, cavitycenters, volume)`` :
            use the given arrays and the volume object
        """
        if len(args) == 1:
            results = args[0]
            positions = results.atoms.positions
            elements = results.atoms.elements
            volume = results.atoms.volume
            if results.domains is not None:
                centers = results.domains.centers
                cachedir = os.path.expanduser(config.Path.cache_dir)
                cachepath = os.path.join(cachedir, 'discretization_cache.hdf5')
                dcache = DiscretizationCache(cachepath)
                disc = dcache.get_discretization(volume, results.resolution)
                centers = map(disc.discrete_to_continuous, centers)
            else:
                centers = []
        elif len(args) == 4:
            positions, elements, centers, volume = args
        else:
            raise TypeError("PDF expects 1 or 4 parameters")

        self.positions = np.array(positions, copy=False)
        self.elements = np.array(elements, dtype="|S4", copy=False)
        self.centers = np.array(centers, copy=False)
        self.volume = volume
        self.num_atoms = np.where(self.elements != "cav")[0].size
        self.numberdensity = float(self.num_atoms) / self.volume.volume

        self.stats = self._genstats(self.positions, self.elements,
                                    self.centers, self.volume)