pygmt.fitcircle

pygmt.fitcircle(data=None, x=None, y=None, output_type='pandas', outfile=None, norm=None, small_circle=False, verbose=False, **kwargs)[source]

Find mean position and great [or small] circle fit to points on sphere.

fitcircle reads (longitude, latitude) or (latitude, longitude) values from the first two columns of the input data. These are converted 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. The user may choose one or both of two possible solutions to this problem. 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.

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.

Takes a matrix, (x, y) pairs, or a file name as input.

Must provide either data or x and y.

Full GMT docs at https://docs.generic-mapping-tools.org/6.6/fitcircle.html.

$aliases
  • V = verbose

Parameters:
  • data (str | PathLike | dict | ndarray | DataFrame | Dataset | GeoDataFrame | None, default: None) – Pass in (longitude, latitude) or (latitude, longitude) values by providing a file name to an ASCII data table, a 2-D numpy.ndarray, a pandas.DataFrame, an xarray.Dataset made up of 1-D xarray.DataArray data variables, or a geopandas.GeoDataFrame containing the tabular data.

  • x/y (1-D arrays) – Arrays of x and y coordinates of the data points.

  • output_type (Literal['pandas', 'numpy', 'file'], default: 'pandas') –

    Desired output type of the result data.

    • pandas will return a pandas.DataFrame object.

    • numpy will return a numpy.ndarray object.

    • file will save the result to the file specified by the outfile parameter.

  • outfile (str | PathLike | None, default: None) – File name for saving the result data. Required if output_type="file". If specified, output_type will be forced to be "file".

  • norm (Literal['absolutes', 'squares', 'both'] | None, default: None) – Specify the desired norm. Use "absolutes" or "squares" to select a single solution, or "both" to see both solutions. Note that output_type="pandas" is not supported when norm is "both"; use output_type="numpy" or output_type="file" instead.

  • small_circle (bool | float, default: False) – Attempt to fit a small circle instead of a great circle. The pole will be constrained to lie on the great circle connecting the pole of the best-fit great circle and the mean location of the data. Optionally append the desired fixed latitude of the small circle [Default will determine the optimal latitude].

  • verbose (Literal['quiet', 'error', 'warning', 'timing', 'info', 'compat', 'debug'] | bool, default: False) – Select verbosity level [Full usage].

Return type:

DataFrame | ndarray | None

Returns:

ret – Return type depends on outfile and output_type:

  • None if outfile is set (output will be stored in the file set by outfile)

  • pandas.DataFrame or numpy.ndarray if outfile is not set (depends on output_type)