def get_mask(region, hdu, origin=1): """Get mask. Parameters ---------- region : `~pyregion.ShapeList` List of `~pyregion.Shape` hdu : `~astropy.io.fits.ImageHDU` FITS image HDU origin : float TODO: document me Returns ------- mask : `~numpy.array` Boolean mask Examples -------- >>> from astropy.io import fits >>> from pyregion import read_region_as_imagecoord, get_mask >>> hdu = fits.open("test.fits")[0] >>> region = "test01.reg" >>> reg = read_region_as_imagecoord(open(region), f[0].header) >>> mask = get_mask(reg, hdu) """ from pyregion.region_to_filter import as_region_filter data = hdu.data region_filter = as_region_filter(region, origin=origin) mask = region_filter.mask(data) return mask
def get_filter(self, header=None, origin=1): """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 ---------- header : `astropy.io.fits.Header` FITS header origin : {0, 1} Pixel coordinate origin Returns ------- filter : TODO Filter object """ from .region_to_filter import as_region_filter if header is None: if not self.check_imagecoord(): raise RuntimeError("the region has non-image coordinate. header is required.") reg_in_imagecoord = self else: reg_in_imagecoord = self.as_imagecoord(header) region_filter = as_region_filter(reg_in_imagecoord, origin=origin) return region_filter
def get_mask(region, hdu, origin=1): """Get mask. Parameters ---------- region : `~pyregion.ShapeList` List of `~pyregion.Shape` hdu : `~astropy.io.fits.ImageHDU` FITS image HDU origin : float TODO: document me Returns ------- mask : `~numpy.array` Boolean mask Examples -------- >>> from astropy.io import fits >>> from pyregion import read_region_as_imagecoord, get_mask >>> f = fits.read("test.fits") >>> region = "test01.reg" >>> reg = read_region_as_imagecoord(open(region), f[0].header) >>> mask = get_mask(reg, f[0]) """ from pyregion.region_to_filter import as_region_filter data = hdu.data region_filter = as_region_filter(region, origin=origin) mask = region_filter.mask(data) return mask
def get_filter(self, header=None, origin=1): """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 ---------- header : `astropy.io.fits.Header` FITS header origin : {0, 1} Pixel coordinate origin Returns ------- filter : TODO Filter object """ from .region_to_filter import as_region_filter if header is None: if not self.check_imagecoord(): raise RuntimeError("the region has non-image coordinate. header is required.") reg_in_imagecoord = self else: reg_in_imagecoord = self.as_imagecoord(header) region_filter = as_region_filter(reg_in_imagecoord, origin=origin) return region_filter
def get_mask(region, hdu, origin=1): """ f = pyfits.read("test.fits") reg = read_region_as_imagecoord(s, f[0].header) mask = get_mask(reg, f[0]) """ from pyregion.region_to_filter import as_region_filter data = hdu.data region_filter = as_region_filter(region, origin=origin) mask = region_filter.mask(data) return mask
def get_mask(region, hdu, origin=1): """ f = pyfits.read("test.fits") reg = read_region_as_imagecoord(s, f[0].header) mask = get_mask(reg, f[0]) """ from pyregion.region_to_filter import as_region_filter data = hdu.data region_filter = as_region_filter(region, origin=origin) mask = region_filter.mask(data) return mask
def get_mask(region, hdu, origin=1): """ Examples -------- >>> from astropy.io import fits >>> from pyregion import read_region_as_imagecoord, get_mask >>> f = fits.read("test.fits") >>> region = "test01.reg" >>> reg = read_region_as_imagecoord(open(region), f[0].header) >>> mask = get_mask(reg, f[0]) """ from pyregion.region_to_filter import as_region_filter data = hdu.data region_filter = as_region_filter(region, origin=origin) mask = region_filter.mask(data) return mask
def get_mask(region, hdu, origin=1): """ Examples -------- >>> from astropy.io import fits >>> from pyregion import read_region_as_imagecoord, get_mask >>> f = fits.read("test.fits") >>> region = "test01.reg" >>> reg = read_region_as_imagecoord(open(region), f[0].header) >>> mask = get_mask(reg, f[0]) """ from pyregion.region_to_filter import as_region_filter data = hdu.data region_filter = as_region_filter(region, origin=origin) mask = region_filter.mask(data) return mask
def get_filter(self, header=None, origin=1, rot_wrt_axis=1): """ 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``. """ from .region_to_filter import as_region_filter if header is None: if not self.check_imagecoord(): raise RuntimeError("the region has non-image coordinate. header is required.") reg_in_imagecoord = self else: reg_in_imagecoord = self.as_imagecoord(header, rot_wrt_axis=rot_wrt_axis) region_filter = as_region_filter(reg_in_imagecoord, origin=1) return region_filter
def get_filter(self, header=None, origin=1, rot_wrt_axis=1): """ 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. """ from .region_to_filter import as_region_filter if header is None: if not self.check_imagecoord(): raise RuntimeError( "the region has non-image coordinate. header is required.") reg_in_imagecoord = self else: reg_in_imagecoord = self.as_imagecoord(header, rot_wrt_axis=rot_wrt_axis) region_filter = as_region_filter(reg_in_imagecoord, origin=1) return region_filter