def __init__( self, center, normal, radius, height, fields=None, ds=None, field_parameters=None, data_source=None, ): validate_center(center) validate_3d_array(normal) validate_float(radius) validate_float(height) validate_sequence(fields) validate_object(ds, Dataset) validate_object(field_parameters, dict) validate_object(data_source, YTSelectionContainer) YTSelectionContainer3D.__init__(self, center, ds, field_parameters, data_source) self._norm_vec = np.array(normal) / np.sqrt(np.dot(normal, normal)) self.set_field_parameter("normal", self._norm_vec) self.set_field_parameter("center", self.center) self.height = fix_length(height, self.ds) self.radius = fix_length(radius, self.ds) self._d = -1.0 * np.dot(self._norm_vec, self.center)
def __init__( self, center, left_edge, right_edge, fields=None, ds=None, field_parameters=None, data_source=None, ): if center is not None: validate_center(center) validate_3d_array(left_edge) validate_3d_array(right_edge) validate_iterable(fields) validate_object(ds, Dataset) validate_object(field_parameters, dict) validate_object(data_source, YTSelectionContainer) YTSelectionContainer3D.__init__(self, center, ds, field_parameters, data_source) if not isinstance(left_edge, YTArray): self.left_edge = self.ds.arr(left_edge, "code_length", dtype="float64") else: # need to assign this dataset's unit registry to the YTArray self.left_edge = self.ds.arr(left_edge.copy(), dtype="float64") if not isinstance(right_edge, YTArray): self.right_edge = self.ds.arr(right_edge, "code_length", dtype="float64") else: # need to assign this dataset's unit registry to the YTArray self.right_edge = self.ds.arr(right_edge.copy(), dtype="float64")
def __init__(self, data_objects, ds=None, field_parameters=None, data_source=None): validate_sequence(data_objects) for obj in data_objects: validate_object(obj, YTSelectionContainer) validate_object(ds, Dataset) validate_object(field_parameters, dict) validate_object(data_source, YTSelectionContainer) YTSelectionContainer3D.__init__(self, None, ds, field_parameters, data_source) self.data_objects = list(always_iterable(data_objects))
def __init__( self, op, dobj1, dobj2, ds=None, field_parameters=None, data_source=None ): YTSelectionContainer3D.__init__(self, None, ds, field_parameters, data_source) self.op = op.upper() self.dobj1 = dobj1 self.dobj2 = dobj2 name = f"Boolean{self.op}Selector" sel_cls = getattr(yt.geometry.selection_routines, name) self._selector = sel_cls(self)
def __init__(self, obj_list, ds=None, field_parameters=None, data_source=None, center=None): validate_sequence(obj_list) validate_object(ds, Dataset) validate_object(field_parameters, dict) validate_object(data_source, YTSelectionContainer) if center is not None: validate_center(center) YTSelectionContainer3D.__init__(self, center, ds, field_parameters, data_source) self._obj_ids = np.array([o.id - o._id_offset for o in obj_list], dtype="int64") self._obj_list = obj_list
def __init__(self, data_objects, ds=None, field_parameters=None, data_source=None): validate_iterable(data_objects) for obj in data_objects: validate_object(obj, YTSelectionContainer) validate_object(ds, Dataset) validate_object(field_parameters, dict) validate_object(data_source, YTSelectionContainer) YTSelectionContainer3D.__init__(self, None, ds, field_parameters, data_source) # ensure_list doesn't check for tuples if isinstance(data_objects, tuple): data_objects = list(data_objects) self.data_objects = ensure_list(data_objects)
def __init__( self, center, A, B, C, e0, tilt, fields=None, ds=None, field_parameters=None, data_source=None, ): validate_center(center) validate_float(A) validate_float(B) validate_float(C) validate_3d_array(e0) validate_float(tilt) validate_sequence(fields) validate_object(ds, Dataset) validate_object(field_parameters, dict) validate_object(data_source, YTSelectionContainer) YTSelectionContainer3D.__init__(self, center, ds, field_parameters, data_source) # make sure the magnitudes of semi-major axes are in order if A < B or B < C: raise YTEllipsoidOrdering(ds, A, B, C) # make sure the smallest side is not smaller than dx self._A = self.ds.quan(A, "code_length") self._B = self.ds.quan(B, "code_length") self._C = self.ds.quan(C, "code_length") if self._C < self.index.get_smallest_dx(): raise YTSphereTooSmall(self.ds, self._C, self.index.get_smallest_dx()) self._e0 = e0 = e0 / (e0 ** 2.0).sum() ** 0.5 self._tilt = tilt # find the t1 angle needed to rotate about z axis to align e0 to x t1 = np.arctan(e0[1] / e0[0]) # rotate e0 by -t1 RZ = get_rotation_matrix(t1, (0, 0, 1)).transpose() r1 = (e0 * RZ).sum(axis=1) # find the t2 angle needed to rotate about y axis to align e0 to x t2 = np.arctan(-r1[2] / r1[0]) """ calculate the original e1 given the tilt about the x axis when e0 was aligned to x after t1, t2 rotations about z, y """ RX = get_rotation_matrix(-tilt, (1, 0, 0)).transpose() RY = get_rotation_matrix(-t2, (0, 1, 0)).transpose() RZ = get_rotation_matrix(-t1, (0, 0, 1)).transpose() e1 = ((0, 1, 0) * RX).sum(axis=1) e1 = (e1 * RY).sum(axis=1) e1 = (e1 * RZ).sum(axis=1) e2 = np.cross(e0, e1) self._e1 = e1 self._e2 = e2 self.set_field_parameter("A", A) self.set_field_parameter("B", B) self.set_field_parameter("C", C) self.set_field_parameter("e0", e0) self.set_field_parameter("e1", e1) self.set_field_parameter("e2", e2)