2. Point operations module (symmetrize.pointops)¶
@author: R. Patrick Xian
-
symmetrize.pointops.arm(Aold, Anew)[source]¶ Calculate the area retainment measure (ARM).
Parameters: - Aold, Anew : numeric/numeric
The area before (old) and after (new) symmetrization.
Return: - s : numeric
The value of the ARM.
-
symmetrize.pointops.cart2homo(points, dtyp='float32')[source]¶ Transform points from Cartesian to homogeneous coordinates.
Parameter: - points : tuple/list/array
Pixel coordinates of the points in Cartesian coordinates, (x, y).
Return: - pts_homo : 2D array
Pixel coordinates of the points (pts) in homogeneous coordinates, (x, y, 1).
-
symmetrize.pointops.csm(pcent, pvert, rotsym=None, type='rotation')[source]¶ Computation of the continuous (a)symmetry measure (CSM) for a set of polygon vertices exhibiting a degree of rotational symmetry. The value is bounded within [0, 1].
When csm = 0, the point set is completely symmetric.
When csm = 1, the point set is completely asymmetric.
Parameters: - pcent : tuple/list
Pixel coordinates of the center position.
- pvert : numpy array
Pixel coordinates of the vertices.
- rotsym : int | None
Order of rotational symmetry.
- type : str | ‘rotation’
The type of the symmetry operation.
- Return:
- s : float
- Calculated continuous (a)symmetry measure.
-
symmetrize.pointops.cvdist(verts, center)[source]¶ Calculate the center-vertex distance.
Parameters: - verts : tuple/list
Pixel coordinates of the vertices.
- center : tuple/list
Pixel coordinates of the center.
-
symmetrize.pointops.gridplot(xgrid, ygrid, ax=None, subsamp=5, **kwds)[source]¶ Plotting transform grid with downsampling. Adapted from the StackOverflow post, https://stackoverflow.com/questions/47295473/how-to-plot-using-matplotlib-python-colahs-deformed-grid
Parameters: - xgrid, ygrid : 2D array, 2D array
Coordinate grids along the x and y directions.
- ax : AxesObject
Axes object to anchor the plot.
- subsamp : int | 5
Subsampling portion.
**kwds: keyword argumentsPlotting keywords.
-
symmetrize.pointops.homo2cart(points)[source]¶ Transform points from homogeneous to Cartesian coordinates.
Parameter: - points : tuple/list/array
Pixel coordinates of the points in homogeneous coordinates, (x, y, 1).
Return: - pts_cart : array
Pixel coordinates of the points (pts) in Cartesian coordinates, (x, y).
-
symmetrize.pointops.peakdetect2d(img, method='daofind', **kwds)[source]¶ Peak detection in 2D image.
Parameters: - img : 2D array
Image matrix.
- method : str | ‘daofind’
Detection method (‘daofind’ or ‘maxlist’).
**kwds: keyword argumentsAdditional arguments passed to the specific methods chosen.
'daofind'Seeastropy.stats.sigma_clipped_stats()and
photutils.detection.DAOStarFinder().
'maxlist'Seeskimage.feature.peak_local_max().
Return: - pks : 2D array
Pixel coordinates of detected peaks, in (column, row) ordering.
-
symmetrize.pointops.pointset_center(pset, method='centroidnn', ret='cnc')[source]¶ Determine the center position of a point set and separate it from the rest.
Parameters: - pset : 2D array
Pixel coordinates of the point set.
- method : str | ‘centroidnn’ (the nearest neighbor of centroid)
Method to determine the point set center.
'centroidnn'Use the point with the minimal distance to the centroid as the center.'centroid'Use the centroid as the center.- ret : str | ‘cnc’
Condition to extract the center position.
'cnc'Return the pixel positions of the center (c) and the non-center (nc) points.'all'Return the pixel positions of the center, the non-center points and the centroid.
-
symmetrize.pointops.pointset_order(pset, center=None, direction='ccw')[source]¶ Order a point set around a center in a clockwise or counterclockwise way.
Parameters: - pset : 2D array
Pixel coordinates of the point set.
- center : list/tuple/1D array | None
Pixel coordinates of the putative shape center.
- direction : str | ‘ccw’
Direction of the ordering (‘cw’ or ‘ccw’).
Return: - pset_ordered : 2D array
Sorted pixel coordinates of the point set.
-
symmetrize.pointops.polyarea(x=[], y=[], coords=[], coord_order='rc')[source]¶ Calculate the area of a convex polygon area from its vertex coordinates, using the surveyor’s formula (also called the shoelace formula). The vertices are ordered in a clockwise or counterclockwise fashions.
Parameters: - x, y : tuple/list/1D array | [], []
Collection of vertex coordinates along the x and y coordinates.
- coords : list/2D array | []
Vertex coordinates.
- coord_order : str | ‘rc’
The ordering of coordinates in the coords array, choose from ‘rc’ or ‘yx’, ‘cr’ or ‘xy’. Here r = row (y), c = column (x).
Return: - A : numeric
The area of the convex polygon bounded by the given vertices.
-
symmetrize.pointops.reorder(points, itemid, axis=0)[source]¶ Reorder a point set along an axis.
Parameters: - points : tuple/list
Collection of the pixel coordinates of points.
- itemid : int
Index of the entry to be placed at the start.
- axis : int | 1
The axis to apply the shift.
Return: - pts_rolled : tuple/list
The points’ pixel coordinates after position shift.
-
symmetrize.pointops.rotmat(theta, to_rad=True, coordsys='cartesian')[source]¶ Rotation matrix in 2D in different coordinate systems.
Parameters: - theta : numeric
Rotation angle.
- to_rad : bool | True
Specify the option to convert the angle to radians.
- coordsys : str | ‘cartesian’
Coordinate system specification (‘cartesian’ or ‘homogen’).