diff --git a/sunkit_image/asda.py b/sunkit_image/asda.py index f97b875c..6cb1df68 100644 --- a/sunkit_image/asda.py +++ b/sunkit_image/asda.py @@ -9,7 +9,7 @@ import numpy as np from skimage import measure -from sunkit_image.utils import calc_gamma, points_in_poly, reform2d, remove_duplicate +from sunkit_image.utils import calculate_gamma, points_in_poly, reform2d, remove_duplicate __all__ = ["Asda", "Lamb_Oseen"] @@ -134,7 +134,7 @@ def gamma_values(self): for d, (i, j) in enumerate( product(np.arange(self.r, self.dshape[0] - self.r, 1), np.arange(self.r, self.dshape[1] - self.r, 1)) ): - self.gamma[i, j, 0], self.gamma[i, j, 1] = calc_gamma(pm, vel[..., d], pnorm, N) + self.gamma[i, j, 0], self.gamma[i, j, 1] = calculate_gamma(pm, vel[..., d], pnorm, N) # Transpose back vx & vy self.vx = self.vx.T self.vy = self.vy.T @@ -206,16 +206,15 @@ def vortex_property(self, image=None): Has to have the same shape as ``self.vx`` observational image, which will be used to calculate the average observational values of all swirls. - Outputs + Returns ------- `tuple` - The returned tuple has four components, each component in order is - ``ve``: expanding speed, in the same unit as ``self.vx`` or ``self.vy``. - ``vr``: rotational speed, in the same unit as ``self.vx`` or ``self.vy``. - ``vc``: velocity of the center, in the form of ``[vx, vy]``. - ``ia``: average of the observational values (intensity or magnetic - field strength etc) within the vortices if the parameter - image is given. + The returned tuple has four components, which are: + + ``ve`` : expanding speed, in the same unit as ``self.vx`` or ``self.vy``. + ``vr`` : rotational speed, in the same unit as ``self.vx`` or ``self.vy``. + ``vc`` : velocity of the center, in the form of ``[vx, vy]``. + ``ia`` : average of the observational values within the vortices if the parameter image is given. """ ve, vr, vc, ia = (), (), (), () for i in range(len(self.edge_prop["center"])): diff --git a/sunkit_image/utils/tests/test_utils.py b/sunkit_image/utils/tests/test_utils.py index acd3b3e8..a07bb2c0 100644 --- a/sunkit_image/utils/tests/test_utils.py +++ b/sunkit_image/utils/tests/test_utils.py @@ -139,7 +139,7 @@ def test_calculate_gamma(): vel_norm = np.linalg.norm(vel[..., 0], axis=2) sint = cross / (pnorm * vel_norm + 1e-10) expected = np.nansum(sint, axis=1) / N - assert np.allclose(expected, utils.calc_gamma(pm, vel[..., 0], pnorm, N)) + assert np.allclose(expected, utils.calculate_gamma(pm, vel[..., 0], pnorm, N)) def test_remove_duplicate(): diff --git a/sunkit_image/utils/utils.py b/sunkit_image/utils/utils.py index 684f22f4..7eb305b8 100644 --- a/sunkit_image/utils/utils.py +++ b/sunkit_image/utils/utils.py @@ -12,7 +12,7 @@ __all__ = [ "bin_edge_summary", - "calc_gamma", + "calculate_gamma", "equally_spaced_bins", "find_pixel_radii", "get_radial_intensity_summary", @@ -252,7 +252,7 @@ def remove_duplicate(edge): return new_edge -def calc_gamma(pm, vel, pnorm, N): +def calculate_gamma(pm, vel, pnorm, n): """ Calculate gamma values. @@ -264,7 +264,7 @@ def calc_gamma(pm, vel, pnorm, N): Velocity vector. pnorm : `numpy.ndarray` Mode of ``pm``. - N : `int` + n : `int` Number of points. Returns @@ -288,4 +288,4 @@ def calc_gamma(pm, vel, pnorm, N): cross = np.cross(pm, vel) vel_norm = np.linalg.norm(vel, axis=2) sint = cross / (pnorm * vel_norm + 1e-10) - return np.nansum(sint, axis=1) / N + return np.nansum(sint, axis=1) / n