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, center, normal, radius, height, fields=None, ds=None, field_parameters=None, data_source=None): 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, points, ds=None, field_parameters=None, data_source=None): validate_object(ds, Dataset) validate_object(field_parameters, dict) validate_object(data_source, YTSelectionContainer) validate_object(points, YTArray) points = fix_length(points, ds) if len(points) < 2: raise YTException( "Not enough points. Expected at least 2, got %s" % len(points)) mylog.debug('Building minimal sphere around points.') mb = _miniball.Miniball(points) if not mb.is_valid(): raise YTException("Could not build valid sphere around points.") center = ds.arr(mb.center(), points.units) radius = ds.quan(np.sqrt(mb.squared_radius()), points.units) super(YTMinimalSphere, self).__init__(center, ds, field_parameters, data_source) self.set_field_parameter('radius', radius) self.set_field_parameter("center", self.center) self.radius = radius
def test_fix_length(): """ Test fixing the length of an array. Used in spheres and other data objects """ ds = fake_random_ds(64, nprocs=1, length_unit=10) length = ds.quan(1.0, 'code_length') new_length = fix_length(length, ds=ds) yield assert_equal, YTQuantity(10, 'cm'), new_length
def test_fix_length(): """ Test fixing the length of an array. Used in spheres and other data objects """ ds = fake_random_ds(64, nprocs=1, length_unit=10) length = ds.quan(1.0, 'code_length') new_length = fix_length(length, ds=ds) yield assert_equal, YTQuantity(10, 'cm'), new_length
def __init__(self, center, radius, ds=None, field_parameters=None, data_source=None): 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, 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