TextPixelRegion#
- class regions.TextPixelRegion(center, text, meta=None, visual=None)[source]#
Bases:
PointPixelRegionA text string in pixel coordinates.
- Parameters:
- center
PixCoord The leftmost point of the text string before rotation.
- textstr
The text string.
- meta
RegionMetaordict, optional A dictionary that stores the meta attributes of the region.
- visual
RegionVisualordict, optional A dictionary that stores the visual meta attributes of the region.
- center
Examples
import matplotlib.pyplot as plt from regions import PixCoord, RegionVisual, TextPixelRegion fig, ax = plt.subplots() center = PixCoord(x=15, y=10) visual = RegionVisual({'textangle': 30}) reg = TextPixelRegion(center=center, text='Hello World!', visual=visual) reg.plot(ax=ax) ax.set_xlim(10, 30) ax.set_ylim(2.5, 20) ax.set_aspect('equal')
(
Source code,png,hires.png,pdf,svg)
Attributes Summary
The leftmost pixel position (before rotation) as a
PixCoord.The meta attributes as a
RegionMetaThe visual attributes as a
RegionVisual.Methods Summary
as_artist([origin])Return a matplotlib Text object for this region (
matplotlib.text.Text).to_sky(wcs)Return a region defined in sky coordinates.
to_spherical_sky(wcs, *[, ...])Convert to an equivalent spherical
SphericalSkyRegioninstance.Attributes Documentation
- meta#
The meta attributes as a
RegionMeta
- visual#
The visual attributes as a
RegionVisual.
Methods Documentation
- as_artist(origin=(0, 0), **kwargs)[source]#
Return a matplotlib Text object for this region (
matplotlib.text.Text).
- to_sky(wcs)[source]#
Return a region defined in sky coordinates.
- Parameters:
- wcs
WCS The world coordinate system transformation to use to convert from pixels to sky coordinates.
- wcs
- Returns:
- sky_region
SkyRegion The sky region.
- sky_region
Notes
The conversion between pixel and sky coordinates is an approximation. The pixel region shape is mapped to a sky region shape using the local pixel scale and angle at the region center. Projection effects over the extent of the region are not accounted for. The region shape type is always preserved (e.g., a
CirclePixelRegionconverts to aCircleSkyRegion).For WCS with distortions (e.g., SIP), the local Jacobian matrix of the WCS transformation is used to compute directional scale factors and angle. For WCS without distortions, a local pixel scale and angle are computed using offset-based methods.
- to_spherical_sky(wcs, *, boundary_distortions=False, n_vertices=None)[source]#
Convert to an equivalent spherical
SphericalSkyRegioninstance.- Parameters:
- wcs
WCSinstance The world coordinate system transformation to use to convert between pixel and sky coordinates.
- boundary_distortionsbool, optional
If
True, the projection-induced distortions of the region’s boundary are preserved by discretizing the boundary into a polygon and transforming that polygon. IfFalse(default), the region is converted to an equivalent idealized shape that ignores these boundary distortions.- n_verticesint, optional
The number of polygon vertices for boundary discretization. This keyword will have no effect unless
boundary_distortions=True. Default is 100.
- wcs
- Returns:
- spherical_sky_region
SphericalSkyRegion A spherical sky region, with an equivalent shape (if
boundary_distortionsis False), or a discretized polygon of the boundary (ifboundary_distortionsis True).
- spherical_sky_region