Пример #1
0
    def interpolate(self, int_grid):
        """
        Convert the 1D gridfunction to another grid using interpolation.

        This method returns the same density, but on another grid.
        For the interpolation, the IMLS algorithm is used (see
        L{interpolation} for details).

        The main purpose of this routine is to obtain a density/potential on
        a L{cubegrid} that is suitable for visualization from one that is
        available only on an L{adfgrid}.

        @param int_grid: the grid to use for the interpolated density
        @type  int_grid: subclass of L{grid}

        @return: the interpolated gridfunction
        @rtype:  L{GridFiunction1D}
        """
        new_values = numpy.empty((int_grid.npoints, ))

        interp = Grids.interpolation(self)
        for i, point in enumerate(int_grid.coorditer()):
            if i % 500 == 0:
                print "Interpolating point %i of %i " % (i, int_grid.npoints)
            new_values[i] = interp.get_value_at_point(point)

        import hashlib
        m = hashlib.md5()
        m.update("Interpolated from :\n")
        m.update(self.get_checksum())
        m.update("on grid :\n")
        m.update(int_grid.get_grid_block(True))

        return GridFunction1D(int_grid, new_values, m.digest())
Пример #2
0
    def get_value_at_point(self, point):
        """
        Get value at one point by interpolation.

        @param point: the point for which the interpolated gridfunction is needed.
        """
        interp = Grids.interpolation(self)
        return interp.get_value_at_point(point)