ind_nan = np.isnan(z_xyz) if any(ind_nan): tree = cKDTree(xyz) _, ind = tree.query(locations[ind_nan, :]) z_xyz[ind_nan] = xyz[ind, dim] # Create an active bool of all True active = np.all((locations[:, dim] < z_xyz).reshape((mesh.nC, -1), order="F"), axis=1) return active.ravel() meshTensor = deprecate_function(unpack_widths, "meshTensor", removal_version="1.0.0", future_warn=False) closestPoints = deprecate_function(closest_points_index, "closestPoints", removal_version="1.0.0", future_warn=False) ExtractCoreMesh = deprecate_function(extract_core_mesh, "ExtractCoreMesh", removal_version="1.0.0", future_warn=False) closest_points = deprecate_function(closest_points_index, "closest_points", removal_version="1.0.0", future_warn=False)
# Area calculation # # Approximate by 4 different triangles, and divide by 2. # Each triangle is one half of the length of the cross product # # So also could be viewed as the average parallelogram. # # TODO: This does not compute correctly for concave quadrilaterals area = (length(nA) + length(nB) + length(nC) + length(nD)) / 4 return N, area exampleLrmGrid = deprecate_function(example_curvilinear_grid, "exampleLrmGrid", removal_version="1.0.0", future_warn=True) volTetra = deprecate_function(volume_tetrahedron, "volTetra", removal_version="1.0.0", future_warn=True) indexCube = deprecate_function(index_cube, "indexCube", removal_version="1.0.0", future_warn=True) faceInfo = deprecate_function(face_info, "faceInfo", removal_version="1.0.0", future_warn=True)
raise ValueError( "Input array does not have the same length as the number of cells in input mesh" ) if output is not None and len(output) != mesh_out.nC: raise ValueError( "Output array does not have the same length as the number of cells in output mesh" ) if values is not None: values = np.asarray(values, dtype=np.float64) if output is not None: output = np.asarray(output, dtype=np.float64) if in_type == "TENSOR": if out_type == "TENSOR": return _vol_interp(mesh_in, mesh_out, values, output) elif out_type == "TREE": return mesh_out._vol_avg_from_tens(mesh_in, values, output) elif in_type == "TREE": if out_type == "TENSOR": return mesh_in._vol_avg_to_tens(mesh_out, values, output) elif out_type == "TREE": return mesh_out._vol_avg_from_tree(mesh_in, values, output) else: raise TypeError("Unsupported mesh types") interpmat = deprecate_function( interpolation_matrix, "interpmat", removal_version="1.0.0", future_warn=False )
The origin of rotation. Returns ------- (n, 3) numpy.ndarray The rotated xyz locations. """ # Compute rotation matrix between v0 and v1 R = rotation_matrix_from_normals(v0, v1) if xyz.shape[1] != 3: raise ValueError("Grid of xyz points should be n x 3") if len(x0) != 3: raise ValueError("x0 should have length 3") # Define origin X0 = np.ones([xyz.shape[0], 1]) * mkvc(x0) return (xyz - X0).dot(R.T) + X0 # equivalent to (R*(xyz - X0)).T + X0 rotationMatrixFromNormals = deprecate_function(rotation_matrix_from_normals, "rotationMatrixFromNormals", removal_version="1.0.0", future_warn=True) rotatePointsFromNormals = deprecate_function(rotate_points_from_normals, "rotatePointsFromNormals", removal_version="1.0.0", future_warn=True)
# average the normals at each vertex. N = (nA + nB + nC + nD) / 4 # this is intrinsically weighted by area # normalize N = normalize(N) else: if normalize_normals: N = [normalize(nA), normalize(nB), normalize(nC), normalize(nD)] else: N = [nA, nB, nC, nD] # Area calculation # # Approximate by 4 different triangles, and divide by 2. # Each triangle is one half of the length of the cross product # # So also could be viewed as the average parallelogram. # # TODO: This does not compute correctly for concave quadrilaterals area = (length(nA) + length(nB) + length(nC) + length(nD)) / 4 return N, area volTetra = deprecate_function(volume_tetrahedron, "volTetra", removal_version="1.0.0") indexCube = deprecate_function(index_cube, "indexCube", removal_version="1.0.0") faceInfo = deprecate_function(face_info, "faceInfo", removal_version="1.0.0")
\mathbf{Q( x ) = 0.5 x A x + b x} + c """ def Quadratic(x, return_g=True, return_H=True): f = 0.5 * x.dot(A.dot(x)) + b.dot(x) + c out = (f, ) if return_g: g = A.dot(x) + b out += (g, ) if return_H: H = A out += (H, ) return out if len(out) > 1 else out[0] return Quadratic # DEPRECATIONS setupMesh = deprecate_function(setup_mesh, "setupMesh", removal_version="1.0.0") Rosenbrock = deprecate_function(rosenbrock, "Rosenbrock", removal_version="1.0.0") checkDerivative = deprecate_function(check_derivative, "checkDerivative", removal_version="1.0.0") getQuadratic = deprecate_function(get_quadratic, "getQuadratic", removal_version="1.0.0")
def __init__(self, val=None): self._val = val def __getitem__(self, key): if isinstance(key, slice): return _inftup(self._val) return self._val def __len__(self): return 0 def __repr__(self): return f"({self._val}, {self._val}, ...)" sdInv = deprecate_function(sdinv, "sdInv", removal_version="1.0.0") getSubArray = deprecate_function(get_subarray, "getSubArray", removal_version="1.0.0") inv3X3BlockDiagonal = deprecate_function(inverse_3x3_block_diagonal, "inv3X3BlockDiagonal", removal_version="1.0.0") inv2X2BlockDiagonal = deprecate_function(inverse_2x2_block_diagonal, "inv2X2BlockDiagonal", removal_version="1.0.0") makePropertyTensor = deprecate_function(make_property_tensor, "makePropertyTensor", removal_version="1.0.0") invPropertyTensor = deprecate_function(inverse_property_tensor, "invPropertyTensor", removal_version="1.0.0")
# Interpolate z values on CC or N z_xyz = z_interpolate(locations[:, :-1]).squeeze() # Apply nearest neighbour if in extrapolation ind_nan = np.isnan(z_xyz) if any(ind_nan): tree = cKDTree(xyz) _, ind = tree.query(locations[ind_nan, :]) z_xyz[ind_nan] = xyz[ind, dim] # Create an active bool of all True active = np.all((locations[:, dim] < z_xyz).reshape((mesh.nC, -1), order="F"), axis=1) return active.ravel() exampleLrmGrid = deprecate_function(example_curvilinear_grid, "exampleLrmGrid", removal_version="1.0.0") meshTensor = deprecate_function(unpack_widths, "meshTensor", removal_version="1.0.0") closestPoints = deprecate_function(closest_points_index, "closestPoints", removal_version="1.0.0") ExtractCoreMesh = deprecate_function(extract_core_mesh, "ExtractCoreMesh", removal_version="1.0.0")
raise ValueError( "Input array does not have the same length as the number of cells in input mesh" ) if output is not None and len(output) != mesh_out.nC: raise ValueError( "Output array does not have the same length as the number of cells in output mesh" ) if values is not None: values = np.asarray(values, dtype=np.float64) if output is not None: output = np.asarray(output, dtype=np.float64) if in_type == "TENSOR": if out_type == "TENSOR": return _vol_interp(mesh_in, mesh_out, values, output) elif out_type == "TREE": return mesh_out._vol_avg_from_tens(mesh_in, values, output) elif in_type == "TREE": if out_type == "TENSOR": return mesh_in._vol_avg_to_tens(mesh_out, values, output) elif out_type == "TREE": return mesh_out._vol_avg_from_tree(mesh_in, values, output) else: raise TypeError("Unsupported mesh types") interpmat = deprecate_function( interpolation_matrix, "interpmat", removal_version="1.0.0" )