Wrap fitcircle - #1550
Conversation
|
Their combinations can lead to quite different output formats, as shown below: The current implementation always returns a pandas.DataFrame object, which is not Pythonic, and also makes it difficult to implement the As mentioned in #1550 (comment), I propose
Internally, we can just call |
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
| "@RidgeTest.prj", | ||
| "@RidgeTest.shp", | ||
| "@RidgeTest.shx", | ||
| "@sat_03.txt", |
There was a problem hiding this comment.
Please move this file to Line 130.
| Setting ``norm`` to ``"absolutes"`` approximates the minimization of the | ||
| sum of absolute values of cosines of angular distances. This solution | ||
| finds the mean position as the Fisher average of the data, and the pole | ||
| position as the Fisher average of the cross-products between the mean | ||
| and the data. Averaging cross-products gives weight to points in | ||
| proportion to their distance from the mean, analogous to the "leverage" | ||
| of distant points in linear regression in the plane. | ||
|
|
||
| Setting ``norm`` to ``"squares"`` approximates the minimization of the | ||
| sum of squares of cosines of angular distances. It creates a 3 by 3 | ||
| matrix of sums of squares of components of the data vectors. The | ||
| eigenvectors of this matrix give the mean and pole locations. This | ||
| method may be more subject to roundoff errors when there are thousands | ||
| of data. The pole is given by the eigenvector corresponding to the | ||
| smallest eigenvalue; it is the least-well represented factor in the data | ||
| and is not easily estimated by either method. |
There was a problem hiding this comment.
I'm re-reading the GMT documentation and feel that norm=1/norm=2 is more understandable than norm="absolutes"/norm="squares", assuming that most readers are already familiar with L1 and L2 norms. What do you think?
There was a problem hiding this comment.
Truth be told, I don't know how fitcircle would be used practically and never used the GMT module (or remember why I chose to wrap it 5 years ago). I'll defer to your judgement; my thought is absolutes and squares is more Pythonic, but if you think 1/2 is more understandable to users, that's fine with me.
There was a problem hiding this comment.
I still feel that norm=1 and norm=2 is more understandable than "absolutes"/"squares".
| - ``"small_circle_distance"``: the colatitude/distance in degrees | ||
| from the small circle pole to the small circle (a ``float``, not a | ||
| tuple) | ||
| """ |
There was a problem hiding this comment.
See comment https://github.com/GenericMappingTools/pygmt/pull/1550/changes#r3829465312. Need to check if norm is 1 or 2.
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
| Find mean position and great or small circle fit to points on sphere. | ||
|
|
||
| This method takes (longitude, latitude) values and converts them to Cartesian | ||
| three-vectors on the unit sphere. Then two locations are found: the mean | ||
| of the input positions, and the pole to the great circle which best fits | ||
| the input positions. | ||
|
|
||
| Setting ``norm`` to ``1`` (L1 norm) approximates the minimization of the | ||
| sum of absolute values of cosines of angular distances. This solution | ||
| finds the mean position as the Fisher average of the data, and the pole | ||
| position as the Fisher average of the cross-products between the mean | ||
| and the data. Averaging cross-products gives weight to points in | ||
| proportion to their distance from the mean, analogous to the "leverage" | ||
| of distant points in linear regression in the plane. | ||
|
|
||
| Setting ``norm`` to ``2`` (L2 norm) approximates the minimization of the | ||
| sum of squares of cosines of angular distances. It creates a 3 by 3 | ||
| matrix of sums of squares of components of the data vectors. The | ||
| eigenvectors of this matrix give the mean and pole locations. This | ||
| method may be more subject to roundoff errors when there are thousands | ||
| of data. The pole is given by the eigenvector corresponding to the | ||
| smallest eigenvalue; it is the least-well represented factor in the data | ||
| and is not easily estimated by either method. | ||
|
|
||
| When the data are closely grouped along a great circle both solutions | ||
| are similar. If the data have large dispersion, the pole to the great | ||
| circle will be less well determined than the mean. Compare both | ||
| solutions as a qualitative check by calling :func:`pygmt.fitcircle` | ||
| twice, once for each ``norm``. |
There was a problem hiding this comment.
Please rewrap these lines to ~88 characters per line.
This pull request wraps the module
fitcircle.Preview at https://pygmt-dev--1550.org.readthedocs.build/en/1550/api/generated/pygmt.fitcircle.html
Reminders
make formatandmake checkto make sure the code follows the style guide.doc/api/index.rst.Slash Commands
You can write slash commands (
/command) in the first line of a comment to performspecific operations. Supported slash commands are:
/format: automatically format and lint the code/test-gmt-dev: run full tests on the latest GMT development version