示例#1
0
 def test_delta_x_from_grid(self):
     coordinates = np.array([0.0, 1.0, 3.0, 6.0, 10.0])
     limits = (1.0, 4.0)
     expected_delta_x = np.array([1.0, 1.5, 2.5, 3.5, 4.0])
     np.testing.assert_array_equal(
         delta_x_from_grid(coordinates=coordinates, limits=limits),
         expected_delta_x)
示例#2
0
    def calculate_delta_x(self, grid, min_cut_off, max_cut_off):
        """
        Calculates the distance between the midpoints of each consecutive site. Inserts the calculated distance to the next grid point outside of the calculation region to the first and last position as the delta_x value for the endmost sites. 
        Args:
            grid (object): Grid object - contains properties of the grid including the x coordinates and the volumes. Used to access the x coordinates.
            min_cut_off (float): Minimum x coordinate value defining the calculation region. 
	    max_cut_off (float): Maximum x coordinate value defining the calculation region.
	Returns:
	    delta_x_from_grid (list): Distance between consecutive sites. 
	"""
        min_index, max_index = self.find_index(grid, min_cut_off, max_cut_off)
        min_offset, max_offset = self.calculate_offset(grid, min_cut_off,
                                                       max_cut_off)
        return delta_x_from_grid(grid.x[min_index + 1:max_index],
                                 [min_offset, max_offset])
示例#3
0
 def test_delta_x_from_grid_with_uneven_grid(self):
     grid = np.array([0.5, 1.0, 2.0, 3.0, 5.0])
     limits = [0.5, 1.0]
     expected_delta_x = np.array([0.5, 0.75, 1.0, 1.5, 1.0])
     delta_x = delta_x_from_grid(grid, limits)
     np.testing.assert_array_almost_equal(expected_delta_x, delta_x)
示例#4
0
 def test_delta_x_from_grid(self):
     grid = np.array([0.0, 1.0, 2.0, 3.0, 4.0])
     limits = [1.0, 1.0]
     expected_delta_x = np.array([1.0, 1.0, 1.0, 1.0, 1.0])
     delta_x = delta_x_from_grid(grid, limits)
     np.testing.assert_array_equal(expected_delta_x, delta_x)