get_rectangle_coordinates#
- sunpy.coordinates.utils.get_rectangle_coordinates(
- bottom_left,
- *,
- top_right=None,
- width=None,
- height=None,
Specify a rectangular region of interest in longitude and latitude in a given coordinate frame.
- Parameters:
bottom_left (
BaseCoordinateFrameorSkyCoord) – The bottom-left coordinate of the rectangle. Supports passing both the bottom left and top right coordinates by passing with a shape of(2,).top_right (
BaseCoordinateFrameorSkyCoord) – The top-right coordinate of the rectangle. If in a different frame thanbottom_leftand all required metadata for frame conversion is present,top_rightwill be transformed tobottom_leftframe.width (
Quantity) – The width of the rectangle. Must be omitted if the coordinates of both corners have been specified.height (
Quantity) – The height of the rectangle. Must be omitted if the coordinates of both corners have been specified.
- Returns:
BaseCoordinateFrameorSkyCoord– The bottom left coordinate of the rectangular region of interest.BaseCoordinateFrameorSkyCoord– The top right coordinate of the rectangular region of interest.
Examples
>>> import astropy.units as u >>> from astropy.coordinates import SkyCoord >>> from sunpy.coordinates.frames import HeliographicStonyhurst >>> from sunpy.coordinates.utils import get_rectangle_coordinates
>>> # With bottom left as a SkyCoord, width and height >>> bottom_left = SkyCoord(0 * u.arcsec, 0 * u.arcsec, frame='heliographic_stonyhurst') >>> width = 10 * u.arcsec >>> height = 10 * u.arcsec >>> bottom_left, top_right = get_rectangle_coordinates(bottom_left, width=width, height=height)
>>> # With bottom left of shape (2,) >>> bottom_left_vector = SkyCoord([0 * u.arcsec, 10 * u.arcsec], [0 * u.arcsec, 10 * u.arcsec], frame='heliographic_stonyhurst') >>> bottom_left, top_right = get_rectangle_coordinates(bottom_left_vector)
>>> # With bottom left as a BaseCoordinateFrame instance, width and height >>> bottom_left = HeliographicStonyhurst(0 * u.arcsec, 0 * u.arcsec) >>> width = 10 * u.arcsec >>> height = 10 * u.arcsec >>> bottom_left, top_right = get_rectangle_coordinates(bottom_left, width=width, height=height)
Notes
widthis always treated as an increase in longitude, butbottom_leftmay have a higher value of longitude thantop_rightdue to the wrapping of the longitude angle. Appropriate care should be taken when using this function’s output to define a range of longitudes.heightis always treated as an increase in latitude, but this function does not enforce thatbottom_lefthas a lower value of latitude thantop_right, in case that orientation is valid for the intended use.