Wrap fitcircle - #1550
Conversation
| S="small_circle", | ||
| ) | ||
| def fitcircle( | ||
| data: PathLike | TableLike, |
There was a problem hiding this comment.
Should support parameters x/y, too.
| $table_classes. | ||
| $output_type | ||
| $outfile | ||
| norm : int or bool |
There was a problem hiding this comment.
1, 2, 3 are not readable arguments. GMT recommends absolutes/squares/both instead.
As for the parameter, GMT supports norm and solution, while GMT.jl uses norm (https://www.generic-mapping-tools.org/GMTjl_doc/documentation/modules/fitcircle.html).
|
@willschlitzer Could you please an issue for tracking this module, using the template at https://github.com/GenericMappingTools/pygmt/blob/main/.github/ISSUE_TEMPLATE/3-module_request.md |
|
|
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.
| tuple) | ||
| """ | ||
| aliasdict = AliasSystem( | ||
| L=Alias(norm, name="norm", mapping={"absolutes": 1, "squares": 2}), |
There was a problem hiding this comment.
See comment https://github.com/GenericMappingTools/pygmt/pull/1550/changes#r3829465312
| L=Alias(norm, name="norm", mapping={"absolutes": 1, "squares": 2}), | |
| L=Alias(norm, name="norm"), |
| - ``"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.
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