contours - contour calculation with matplotlib
The contours package exposes Matplotlib’s contour generators to the user providing an equivalent of MATLAB’s contourc function. This is done for grids (including curvilinear) as well as unstructured data via Delaunay triangulation (FUTURE).
Regular contours can be returned as NumPy arrays or as Shapely LineStrings and LinearRings. Filled contours can be returned as NumPy arrays or as Shapely Polygons.
Contour calculation without plotting is currently an open issue #367 for Matplotlib. In that discussion, the type of hackery done in this library is discouraged by the Matplotlib developers. As of this writing there has been no decision as to whether exposing contour calculations is a feature that should be included in Matplotlib or not. If such a refactoring in Matplotlib ever takes place, this library will be refactored to avoid using Matplotlib’s internal components.
Links
Features
Filled and non-filled contours.
Contours on regular grids.
TODO Contours on unstructured data.
Examples
A contrived example using QuadContourGenerator to compute the area and circumference of a circle and a ring.
>>> from contours.core import shapely_formatter as shapely_fmt
>>> from contours.quad import QuadContourGenerator
>>> import numpy as np
>>> x = np.arange(-1, 1+0.01, 0.01)
>>> y = np.arange(-1, 1+0.01, 0.01)
>>> z = np.sqrt(x[:, np.newaxis]**2 + y[np.newaxis, :]**2)
>>> c = QuadContourGenerator.from_rectilinear(x, y, z, shapely_fmt)
>>> contour = c.filled_contour(max=1.0)
>>> print('Area: {:0.2f}'.format(contour[0].area))
Area: 3.14
>>> print('Length: {:0.2f}'.format(contour[0].length))
Length: 6.28
>>> contour = c.filled_contour(min=0.5, max=1.0)
>>> print('Area: {:0.2f}'.format(contour[0].area))
Area: 2.36
>>> print('Length: {:0.2f}'.format(contour[0].exterior.length))
Length: 6.28
>>> print('Length: {:0.2f}'.format(contour[0].interiors[0].length))
Length: 3.14
Testing
TODO
Metadata
Release files for contours 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| contours-0.0.2.tar.gz | 7.4 kB | Without provenance | Details |
Release files / contours-0.0.2.tar.gz
| Download URL | contours-0.0.2.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
31098980739adc76ab38e03cb987906935b2b45d24a2004e020c60509d6eb70e
|
|
BLAKE2b-256 checksum How to use checksums |
553f3df63de14b03a4421c50e6a7653da12118690e86bb391befb5c8bbb7e1f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for contours 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.