LSST Applications g044012fb7c+304891ab8a,g04a91732dc+4e1b87f259,g07dc498a13+f701f15b83,g114c6a66ad+c7887c1284,g1409bbee79+f701f15b83,g1a7e361dbc+f701f15b83,g1fd858c14a+6ebd102b59,g35bb328faa+0eb18584fe,g3bd4b5ce2c+e83bf4edc8,g4e0f332c67+976ceb6bc8,g53246c7159+0eb18584fe,g5477a8d5ce+51234355ef,g60b5630c4e+c7887c1284,g623d845a50+c7887c1284,g6f0c2978f1+98123c34b6,g71fabbc107+c7887c1284,g75b6c65c88+ce466f4385,g78460c75b0+85633614c8,g786e29fd12+02b9b86fc9,g8852436030+cfe5cf5b7b,g89139ef638+f701f15b83,g9125e01d80+0eb18584fe,g95236ca021+d4f98599f0,g974caa22f6+0eb18584fe,g989de1cb63+f701f15b83,g9f33ca652e+b4908f5dcd,gaaedd4e678+f701f15b83,gabe3b4be73+543c3c03c9,gace736f484+07e57cea59,gb1101e3267+487fd1b06d,gb58c049af0+492386d360,gc99c83e5f0+a513197d39,gcf25f946ba+cfe5cf5b7b,gd0fa69b896+babbe6e5fe,gd6cbbdb0b4+3fef02d88a,gde0f65d7ad+e8379653a2,ge278dab8ac+ae64226a64,gfba249425e+0eb18584fe,w.2025.07
LSST Data Management Base Package
Loading...
Searching...
No Matches
lsst.sphgeom._continue_class.Region Class Reference

Public Member Functions

Region from_ivoa_pos (cls, str pos)
 
str to_ivoa_pos (self)
 

Detailed Description

A minimal interface for 2-dimensional regions on the unit sphere.

Definition at line 101 of file _continue_class.py.

Member Function Documentation

◆ from_ivoa_pos()

Region lsst.sphgeom._continue_class.Region.from_ivoa_pos ( cls,
str pos )
Create a Region from an IVOA POS string.

Parameters
----------
pos : `str`
    A string using the IVOA SIAv2 POS syntax.

Returns
-------
region : `Region`
    A region equivalent to the POS string.

Notes
-----
See
https://ivoa.net/documents/SIA/20151223/REC-SIA-2.0-20151223.html#toc12
for a description of the POS parameter but in summary the options are:

* ``CIRCLE <longitude> <latitude> <radius>``
* ``RANGE <longitude1> <longitude2> <latitude1> <latitude2>``
* ``POLYGON <longitude1> <latitude1> ... (at least 3 pairs)``

Units are degrees in all coordinates.

Definition at line 105 of file _continue_class.py.

105 def from_ivoa_pos(cls, pos: str) -> Region:
106 """Create a Region from an IVOA POS string.
107
108 Parameters
109 ----------
110 pos : `str`
111 A string using the IVOA SIAv2 POS syntax.
112
113 Returns
114 -------
115 region : `Region`
116 A region equivalent to the POS string.
117
118 Notes
119 -----
120 See
121 https://ivoa.net/documents/SIA/20151223/REC-SIA-2.0-20151223.html#toc12
122 for a description of the POS parameter but in summary the options are:
123
124 * ``CIRCLE <longitude> <latitude> <radius>``
125 * ``RANGE <longitude1> <longitude2> <latitude1> <latitude2>``
126 * ``POLYGON <longitude1> <latitude1> ... (at least 3 pairs)``
127
128 Units are degrees in all coordinates.
129 """
130 shape, *coordinates = pos.split()
131 coordinates = tuple(float(c) for c in coordinates)
132 n_floats = len(coordinates)
133 if shape == "CIRCLE":
134 if n_floats != 3:
135 raise ValueError(f"CIRCLE requires 3 numbers but got {n_floats} in '{pos}'.")
136 center = LonLat.fromDegrees(coordinates[0], coordinates[1])
137 radius = Angle.fromDegrees(coordinates[2])
138 return Circle(UnitVector3d(center), radius)
139
140 if shape == "RANGE":
141 if n_floats != 4:
142 raise ValueError(f"RANGE requires 4 numbers but got {n_floats} in '{pos}'.")
143 # POS allows +Inf and -Inf in ranges. These are not allowed by
144 # Box and so must be converted.
145 return Box(
146 LonLat.fromDegrees(_inf_to_lon(coordinates[0]), _inf_to_lat(coordinates[2])),
147 LonLat.fromDegrees(_inf_to_lon(coordinates[1]), _inf_to_lat(coordinates[3])),
148 )
149
150 if shape == "POLYGON":
151 if n_floats % 2 != 0:
152 raise ValueError(f"POLYGON requires even number of floats but got {n_floats} in '{pos}'.")
153 if n_floats < 6:
154 raise ValueError(
155 f"POLYGON specification requires at least 3 coordinates, got {n_floats // 2} in '{pos}'"
156 )
157 # Coordinates are x1, y1, x2, y2, x3, y3...
158 # Get pairs by skipping every other value.
159 pairs = list(zip(coordinates[0::2], coordinates[1::2], strict=True))
160 vertices = [LonLat.fromDegrees(lon, lat) for lon, lat in pairs]
161 return ConvexPolygon([UnitVector3d(c) for c in vertices])
162
163 raise ValueError(f"Unrecognized shape in POS string '{pos}'")
164

◆ to_ivoa_pos()

str lsst.sphgeom._continue_class.Region.to_ivoa_pos ( self)
Represent the region as an IVOA POS string.

Returns
-------
pos : `str`
    The region in ``POS`` format.

Definition at line 165 of file _continue_class.py.

165 def to_ivoa_pos(self) -> str:
166 """Represent the region as an IVOA POS string.
167
168 Returns
169 -------
170 pos : `str`
171 The region in ``POS`` format.
172 """
173 raise NotImplementedError("This region can not be converted to an IVOA POS string.")
174
175
176@_continueClass

The documentation for this class was generated from the following file: