Path

class pvextractor.Path(xy_or_coords, width=None)[source]

Bases: object

A curved path that may have a non-zero width and is used to extract slices from cubes.

Parameters:
xy_or_coordslist or Astropy coordinates

The points defining the path. This can be passed as a list of (x, y) tuples, which is interpreted as being pixel positions, or it can be an Astropy coordinate object containing an array of 2 or more coordinates.

widthNone or float or Quantity

The width of the path. If coords is passed as a list of pixel positions, the width should be given (if passed) as a floating-point value in pixels. If coords is a coordinate object, the width should be passed as a Quantity instance with units of angle. If None, interpolation is used at the position of the path.

Methods Summary

add_point(xy_or_coord)

Add a point to the path

as_artist(spacing[, wcs, facecolor])

Return the path as a matplotlib artist object that can be displayed on the image.

get_xy([wcs])

Return the pixel coordinates of the path.

sample_points(spacing[, wcs])

sample_points_edges(spacing[, wcs])

sample_polygons(spacing[, wcs])

show_on_axis(ax, spacing, **kwargs)

Show the path as a set of patches on the specified matplotlib axis.

to_patches(spacing[, wcs])

Methods Documentation

add_point(xy_or_coord)[source]

Add a point to the path

Parameters:
xy_or_coordtuple or Astropy coordinate

A tuple (x, y) containing the coordinates of the point to add (if the path is defined in pixel space), or an Astropy coordinate object (if it is defined in world coordinates).

as_artist(spacing, wcs=None, facecolor='none', **kwargs)[source]

Return the path as a matplotlib artist object that can be displayed on the image.

Parameters:
spacingfloat

The spacing between sample points to plot, in pixels

wcsastropy.wcs.WCS

A WCS instance to convert from celestial to pixel coordinates, or None if pixel coordinates are to be used.

facecolorstring

The facecolor of the patches. This will be ignored if lines are plotted and defaults to none (transparent) for patches.

kwargsdict

passed to matplotlib.lines.Line2D or both to_patches and matplotlib.collections.PatchCollection.

get_xy(wcs=None)[source]

Return the pixel coordinates of the path.

If the path is defined in world coordinates, the appropriate WCS transformation should be passed.

Parameters:
wcsWCS

The WCS transformation to assume in order to transform the path to pixel coordinates.

sample_points(spacing, wcs=None)[source]
sample_points_edges(spacing, wcs=None)[source]
sample_polygons(spacing, wcs=None)[source]
show_on_axis(ax, spacing, **kwargs)[source]

Show the path as a set of patches on the specified matplotlib axis.

Parameters:
axmatplotlib.axes._subplots.WCSAxesSubplot

An astropy WCSAxesSubplot axis to overplot onto

spacingfloat

The spacing between sample points to plot, in pixels

kwargsdict

passed to as_artist.

to_patches(spacing, wcs=None, **kwargs)[source]