ShapeList

class pyregion.ShapeList(shape_list, comment_list=None)[source]

Bases: list

A list of Shape objects.

Parameters:
shape_listlist

List of pyregion.Shape objects

comment_listlist, None

List of comment strings for each argument

Methods Summary

as_imagecoord(header)

New shape list in image coordinates.

check_imagecoord()

Are all shapes in image coordinates?

get_filter([header, origin])

Get filter.

get_mask([hdu, header, shape])

Create a 2-d mask.

get_mpl_patches_texts([properties_func, ...])

Often, the regions files implicitly assume the lower-left corner of the image as a coordinate (1,1).

write(outfile)

Write this shape list to a region file.

Methods Documentation

as_imagecoord(header)[source]

New shape list in image coordinates.

Parameters:
headerHeader

FITS header

Returns:
shape_listShapeList

New shape list, with coordinates of the each shape converted to the image coordinate using the given header information.

check_imagecoord()[source]

Are all shapes in image coordinates?

Returns True if yes, and False if not.

get_filter(header=None, origin=1)[source]

Get filter. Often, the regions files implicitly assume the lower-left corner of the image as a coordinate (1,1). However, the python convetion is that the array index starts from 0. By default (origin=1), coordinates of the returned mpl artists have coordinate shifted by (1, 1). If you do not want this shift, use origin=0.

Parameters:
headerastropy.io.fits.Header

FITS header

origin{0, 1}

Pixel coordinate origin

Returns:
filterTODO

Filter object

get_mask(hdu=None, header=None, shape=None)[source]

Create a 2-d mask.

Parameters:
hduastropy.io.fits.ImageHDU

FITS image HDU

headerHeader

FITS header

shapetuple

Image shape

Returns:
masknumpy.array

Boolean mask

Examples

get_mask(hdu=f[0]) get_mask(shape=(10,10)) get_mask(header=f[0].header, shape=(10,10))

get_mpl_patches_texts(properties_func=None, text_offset=5.0, origin=1)[source]

Often, the regions files implicitly assume the lower-left corner of the image as a coordinate (1,1). However, the python convetion is that the array index starts from 0. By default (origin=1), coordinates of the returned mpl artists have coordinate shifted by (1, 1). If you do not want this shift, use origin=0.

write(outfile)[source]

Write this shape list to a region file.

Parameters:
outfilestr

File name