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_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) 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, axis, coords, ds=None, field_parameters=None, data_source=None): validate_axis(ds, axis) validate_iterable(coords) for c in coords: validate_float(c) validate_object(ds, Dataset) validate_object(field_parameters, dict) validate_object(data_source, YTSelectionContainer) super(YTOrthoRay, self).__init__(ds, field_parameters, data_source) self.axis = fix_axis(axis, self.ds) xax = self.ds.coordinates.x_axis[self.axis] yax = self.ds.coordinates.y_axis[self.axis] self.px_ax = xax self.py_ax = yax # Even though we may not be using x,y,z we use them here. self.px_dx = 'd%s' % ('xyz'[self.px_ax]) self.py_dx = 'd%s' % ('xyz'[self.py_ax]) # Convert coordinates to code length. if isinstance(coords[0], YTQuantity): self.px = self.ds.quan(coords[0]).to("code_length") else: self.px = self.ds.quan(coords[0], "code_length") if isinstance(coords[1], YTQuantity): self.py = self.ds.quan(coords[1]).to("code_length") else: self.py = self.ds.quan(coords[1], "code_length") self.sort_by = 'xyz'[self.axis]
def __init__( self, axis, coord, center=None, ds=None, field_parameters=None, data_source=None ): validate_axis(ds, axis) validate_float(coord) # center is an optional parameter if center is not None: validate_center(center) validate_object(ds, Dataset) validate_object(field_parameters, dict) validate_object(data_source, YTSelectionContainer) YTSelectionContainer2D.__init__(self, axis, ds, field_parameters, data_source) self._set_center(center) self.coord = coord
def __init__(self, center, radius, ds=None, field_parameters=None, data_source=None): validate_center(center) validate_float(radius) validate_object(ds, Dataset) validate_object(field_parameters, dict) validate_object(data_source, YTSelectionContainer) super(YTSphere, self).__init__(center, ds, field_parameters, data_source) # Unpack the radius, if necessary radius = fix_length(radius, self.ds) if radius < self.index.get_smallest_dx(): raise YTSphereTooSmall(ds, radius.in_units("code_length"), self.index.get_smallest_dx().in_units("code_length")) self.set_field_parameter('radius', radius) self.set_field_parameter("center", self.center) self.radius = radius
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_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) # 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)