Scalar3D.cut

badgearrow-up-right

Scalar3D.cut(self, n_cut=1, mode='equal'):


Description

Cuts the scalar field.

Parameters

  • n_cut (int or tuple, optional): The number of samples to cut at the extrema. If mode is 'equal', n_cut is an integer specifying the number of samples to cut from each side. If mode is 'xyz', n_cut is a tuple specifying the number of samples to cut for each dimension. Default is 1.

  • mode ({'equal', 'xyz'}, optional): The mode of cutting. 'equal' cuts the same number of samples from each side, 'xyz' allows specifying the number of samples to cut for each dimension. Default is 'equal'.

Returns

  • array-like: The cut scalar field.

Example

# Example of cutting a scalar field
field = Scalar3D(shape=[10, 10, 10], value=np.random.rand(10, 10, 10))
# Cut the field with equal number of samples removed from each side
cut_field_equal = field.cut(n_cut=2, mode='equal')
print("Cut field with equal mode:")
print(cut_field_equal)
# Cut the field with specified number of samples removed for each dimension
cut_field_xyz = field.cut(n_cut=(1, 2, 3), mode='xyz')
print("\nCut field with xyz mode:")
print(cut_field_xyz)

Last updated