# How to use the photutils.aperture.attributes.AngleOrPixelScalarQuantity function in photutils

## To help you get started, weâ€™ve selected a few photutils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

astropy / photutils / photutils / aperture / rectangle.py View on Github
``````is 0 degrees.

Examples
--------
>>> from astropy.coordinates import SkyCoord
>>> import astropy.units as u
>>> from photutils import SkyRectangularAnnulus
>>> positions = SkyCoord(ra=[10., 20.], dec=[30., 40.], unit='deg')
>>> aper = SkyRectangularAnnulus(positions, 3.0*u.arcsec, 8.0*u.arcsec,
...                              5.0*u.arcsec)
"""

_shape_params = ('w_in', 'w_out', 'h_out', 'theta')
positions = SkyCoordPositions('positions')
w_in = AngleOrPixelScalarQuantity('w_in')
w_out = AngleOrPixelScalarQuantity('w_out')
h_out = AngleOrPixelScalarQuantity('h_out')
theta = AngleScalarQuantity('theta')

def __init__(self, positions, w_in, w_out, h_out, theta=0.*u.deg):
if w_in.unit.physical_type != w_out.unit.physical_type:
raise ValueError("w_in and w_out should either both be angles or "
"in pixels")

if w_out.unit.physical_type != h_out.unit.physical_type:
raise ValueError("w_out and h_out should either both be angles "
"or in pixels")

self.positions = positions
self.w_in = w_in
self.w_out = w_out
self.h_out = h_out``````
astropy / photutils / photutils / aperture / ellipse.py View on Github
``````axis.  For a right-handed world coordinate system, the position
angle increases counterclockwise from North (PA=0).  The default
is 0 degrees.

Examples
--------
>>> from astropy.coordinates import SkyCoord
>>> import astropy.units as u
>>> from photutils import SkyEllipticalAperture
>>> positions = SkyCoord(ra=[10., 20.], dec=[30., 40.], unit='deg')
>>> aper = SkyEllipticalAperture(positions, 1.0*u.arcsec, 0.5*u.arcsec)
"""

_shape_params = ('a', 'b', 'theta')
positions = SkyCoordPositions('positions')
a = AngleOrPixelScalarQuantity('a')
b = AngleOrPixelScalarQuantity('b')
theta = AngleScalarQuantity('theta')

def __init__(self, positions, a, b, theta=0.*u.deg):
if a.unit.physical_type != b.unit.physical_type:
raise ValueError("a and b should either both be angles "
"or in pixels")

self.positions = positions
self.a = a
self.b = b
self.theta = theta

def to_pixel(self, wcs):
"""
Convert the aperture to an `EllipticalAperture` object defined``````
astropy / photutils / photutils / aperture / ellipse.py View on Github
``````angle increases counterclockwise from North (PA=0).  The default
is 0 degrees.

Examples
--------
>>> from astropy.coordinates import SkyCoord
>>> import astropy.units as u
>>> from photutils import SkyEllipticalAnnulus
>>> positions = SkyCoord(ra=[10., 20.], dec=[30., 40.], unit='deg')
>>> aper = SkyEllipticalAnnulus(positions, 0.5*u.arcsec, 2.0*u.arcsec,
...                             1.0*u.arcsec)
"""

_shape_params = ('a_in', 'a_out', 'b_out', 'theta')
positions = SkyCoordPositions('positions')
a_in = AngleOrPixelScalarQuantity('a_in')
a_out = AngleOrPixelScalarQuantity('a_out')
b_out = AngleOrPixelScalarQuantity('b_out')
theta = AngleScalarQuantity('theta')

def __init__(self, positions, a_in, a_out, b_out, theta=0.*u.deg):
if a_in.unit.physical_type != a_out.unit.physical_type:
raise ValueError("a_in and a_out should either both be angles "
"or in pixels")

if a_out.unit.physical_type != b_out.unit.physical_type:
raise ValueError("a_out and b_out should either both be angles "
"or in pixels")

self.positions = positions
self.a_in = a_in
self.a_out = a_out``````
astropy / photutils / photutils / aperture / rectangle.py View on Github
``````side.  For a right-handed world coordinate system, the position
angle increases counterclockwise from North (PA=0).  The default
is 0 degrees.

Examples
--------
>>> from astropy.coordinates import SkyCoord
>>> import astropy.units as u
>>> from photutils import SkyRectangularAperture
>>> positions = SkyCoord(ra=[10., 20.], dec=[30., 40.], unit='deg')
>>> aper = SkyRectangularAperture(positions, 1.0*u.arcsec, 0.5*u.arcsec)
"""

_shape_params = ('w', 'h', 'theta')
positions = SkyCoordPositions('positions')
w = AngleOrPixelScalarQuantity('w')
h = AngleOrPixelScalarQuantity('h')
theta = AngleScalarQuantity('theta')

def __init__(self, positions, w, h, theta=0.*u.deg):
if w.unit.physical_type != h.unit.physical_type:
raise ValueError("'w' and 'h' should either both be angles or "
"in pixels")

self.positions = positions
self.w = w
self.h = h
self.theta = theta

def to_pixel(self, wcs):
"""
Convert the aperture to a `RectangularAperture` object defined``````
astropy / photutils / photutils / aperture / ellipse.py View on Github
``````Examples
--------
>>> from astropy.coordinates import SkyCoord
>>> import astropy.units as u
>>> from photutils import SkyEllipticalAnnulus
>>> positions = SkyCoord(ra=[10., 20.], dec=[30., 40.], unit='deg')
>>> aper = SkyEllipticalAnnulus(positions, 0.5*u.arcsec, 2.0*u.arcsec,
...                             1.0*u.arcsec)
"""

_shape_params = ('a_in', 'a_out', 'b_out', 'theta')
positions = SkyCoordPositions('positions')
a_in = AngleOrPixelScalarQuantity('a_in')
a_out = AngleOrPixelScalarQuantity('a_out')
b_out = AngleOrPixelScalarQuantity('b_out')
theta = AngleScalarQuantity('theta')

def __init__(self, positions, a_in, a_out, b_out, theta=0.*u.deg):
if a_in.unit.physical_type != a_out.unit.physical_type:
raise ValueError("a_in and a_out should either both be angles "
"or in pixels")

if a_out.unit.physical_type != b_out.unit.physical_type:
raise ValueError("a_out and b_out should either both be angles "
"or in pixels")

self.positions = positions
self.a_in = a_in
self.a_out = a_out
self.b_out = b_out
self.b_in = self.b_out * self.a_in / self.a_out``````
astropy / photutils / photutils / aperture / circle.py View on Github
``````r : scalar `~astropy.units.Quantity`
The radius of the circle, either in angular or pixel units.

Examples
--------
&gt;&gt;&gt; from astropy.coordinates import SkyCoord
&gt;&gt;&gt; import astropy.units as u
&gt;&gt;&gt; from photutils import SkyCircularAperture
&gt;&gt;&gt; positions = SkyCoord(ra=[10., 20.], dec=[30., 40.], unit='deg')
&gt;&gt;&gt; aper = SkyCircularAperture(positions, 0.5*u.arcsec)
"""

_shape_params = ('r',)
positions = SkyCoordPositions('positions')
r = AngleOrPixelScalarQuantity('r')

def __init__(self, positions, r):
self.positions = positions
self.r = r

def to_pixel(self, wcs):
"""
Convert the aperture to a `CircularAperture` object defined in
pixel coordinates.

Parameters
----------
wcs : WCS object
A world coordinate system (WCS) transformation that supports
the `astropy shared interface for WCS
`_ (e.g.``````
astropy / photutils / photutils / aperture / ellipse.py View on Github
``````angle increases counterclockwise from North (PA=0).  The default
is 0 degrees.

Examples
--------
>>> from astropy.coordinates import SkyCoord
>>> import astropy.units as u
>>> from photutils import SkyEllipticalAperture
>>> positions = SkyCoord(ra=[10., 20.], dec=[30., 40.], unit='deg')
>>> aper = SkyEllipticalAperture(positions, 1.0*u.arcsec, 0.5*u.arcsec)
"""

_shape_params = ('a', 'b', 'theta')
positions = SkyCoordPositions('positions')
a = AngleOrPixelScalarQuantity('a')
b = AngleOrPixelScalarQuantity('b')
theta = AngleScalarQuantity('theta')

def __init__(self, positions, a, b, theta=0.*u.deg):
if a.unit.physical_type != b.unit.physical_type:
raise ValueError("a and b should either both be angles "
"or in pixels")

self.positions = positions
self.a = a
self.b = b
self.theta = theta

def to_pixel(self, wcs):
"""
Convert the aperture to an `EllipticalAperture` object defined
in pixel coordinates.``````
astropy / photutils / photutils / aperture / circle.py View on Github
``````The outer radius of the circular annulus, either in angular or
pixel units.

Examples
--------
>>> from astropy.coordinates import SkyCoord
>>> import astropy.units as u
>>> from photutils import SkyCircularAnnulus
>>> positions = SkyCoord(ra=[10., 20.], dec=[30., 40.], unit='deg')
>>> aper = SkyCircularAnnulus(positions, 0.5*u.arcsec, 1.0*u.arcsec)
"""

_shape_params = ('r_in', 'r_out')
positions = SkyCoordPositions('positions')
r_in = AngleOrPixelScalarQuantity('r_in')
r_out = AngleOrPixelScalarQuantity('r_out')

def __init__(self, positions, r_in, r_out):
if r_in.unit.physical_type != r_out.unit.physical_type:
raise ValueError("r_in and r_out should either both be angles "
"or in pixels.")

self.positions = positions
self.r_in = r_in
self.r_out = r_out

def to_pixel(self, wcs):
"""
Convert the aperture to a `CircularAnnulus` object defined in
pixel coordinates.

Parameters``````
astropy / photutils / photutils / aperture / rectangle.py View on Github
``````angle increases counterclockwise from North (PA=0).  The default
is 0 degrees.

Examples
--------
>>> from astropy.coordinates import SkyCoord
>>> import astropy.units as u
>>> from photutils import SkyRectangularAperture
>>> positions = SkyCoord(ra=[10., 20.], dec=[30., 40.], unit='deg')
>>> aper = SkyRectangularAperture(positions, 1.0*u.arcsec, 0.5*u.arcsec)
"""

_shape_params = ('w', 'h', 'theta')
positions = SkyCoordPositions('positions')
w = AngleOrPixelScalarQuantity('w')
h = AngleOrPixelScalarQuantity('h')
theta = AngleScalarQuantity('theta')

def __init__(self, positions, w, h, theta=0.*u.deg):
if w.unit.physical_type != h.unit.physical_type:
raise ValueError("'w' and 'h' should either both be angles or "
"in pixels")

self.positions = positions
self.w = w
self.h = h
self.theta = theta

def to_pixel(self, wcs):
"""
Convert the aperture to a `RectangularAperture` object defined
in pixel coordinates.``````
astropy / photutils / photutils / aperture / rectangle.py View on Github
``````Examples
--------
>>> from astropy.coordinates import SkyCoord
>>> import astropy.units as u
>>> from photutils import SkyRectangularAnnulus
>>> positions = SkyCoord(ra=[10., 20.], dec=[30., 40.], unit='deg')
>>> aper = SkyRectangularAnnulus(positions, 3.0*u.arcsec, 8.0*u.arcsec,
...                              5.0*u.arcsec)
"""

_shape_params = ('w_in', 'w_out', 'h_out', 'theta')
positions = SkyCoordPositions('positions')
w_in = AngleOrPixelScalarQuantity('w_in')
w_out = AngleOrPixelScalarQuantity('w_out')
h_out = AngleOrPixelScalarQuantity('h_out')
theta = AngleScalarQuantity('theta')

def __init__(self, positions, w_in, w_out, h_out, theta=0.*u.deg):
if w_in.unit.physical_type != w_out.unit.physical_type:
raise ValueError("w_in and w_out should either both be angles or "
"in pixels")

if w_out.unit.physical_type != h_out.unit.physical_type:
raise ValueError("w_out and h_out should either both be angles "
"or in pixels")

self.positions = positions
self.w_in = w_in
self.w_out = w_out
self.h_out = h_out
self.h_in = self.w_in * self.h_out / self.w_out``````

## photutils

An Astropy package for source detection and photometry

BSD-3-Clause