healpix-geo 0.0.7__cp312-cp312-musllinux_1_2_armv7l.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of healpix-geo might be problematic. Click here for more details.
- healpix_geo/__init__.py +3 -0
- healpix_geo/geometry.py +3 -0
- healpix_geo/healpix_geo.cpython-312-arm-linux-musleabihf.so +0 -0
- healpix_geo/nested.py +567 -0
- healpix_geo/ring.py +286 -0
- healpix_geo/slices.py +4 -0
- healpix_geo/tests/test_coverage.py +293 -0
- healpix_geo/tests/test_distances.py +81 -0
- healpix_geo/tests/test_index.py +290 -0
- healpix_geo/tests/test_inference.py +185 -0
- healpix_geo/tests/test_neighbours.py +40 -0
- healpix_geo/tests/test_slices.py +116 -0
- healpix_geo/tests/test_zoom.py +76 -0
- healpix_geo/utils.py +25 -0
- healpix_geo-0.0.7.dist-info/METADATA +23 -0
- healpix_geo-0.0.7.dist-info/RECORD +19 -0
- healpix_geo-0.0.7.dist-info/WHEEL +4 -0
- healpix_geo-0.0.7.dist-info/licenses/LICENSE +201 -0
- healpix_geo.libs/libgcc_s-0366c7ba.so.1 +0 -0
healpix_geo/__init__.py
ADDED
healpix_geo/geometry.py
ADDED
|
Binary file
|
healpix_geo/nested.py
ADDED
|
@@ -0,0 +1,567 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
|
|
3
|
+
from healpix_geo import healpix_geo
|
|
4
|
+
from healpix_geo.utils import _check_depth, _check_ipixels, _check_ring
|
|
5
|
+
|
|
6
|
+
RangeMOCIndex = healpix_geo.nested.RangeMOCIndex
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def create_empty(depth):
|
|
10
|
+
return RangeMOCIndex.create_empty(depth)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def healpix_to_lonlat(ipix, depth, ellipsoid, num_threads=0):
|
|
14
|
+
r"""Get the longitudes and latitudes of the center of some HEALPix cells.
|
|
15
|
+
|
|
16
|
+
Parameters
|
|
17
|
+
----------
|
|
18
|
+
ipix : `numpy.ndarray`
|
|
19
|
+
The HEALPix cell indexes given as a `np.uint64` numpy array.
|
|
20
|
+
depth : `numpy.ndarray`
|
|
21
|
+
The HEALPix cell depth given as a `np.uint8` numpy array.
|
|
22
|
+
ellipsoid : str, default: "sphere"
|
|
23
|
+
Reference ellipsoid to evaluate healpix on. If ``"sphere"``, this will return
|
|
24
|
+
the same result as :py:func:`cdshealpix.nested.healpix_to_lonlat`.
|
|
25
|
+
num_threads : int, optional
|
|
26
|
+
Specifies the number of threads to use for the computation. Default to 0 means
|
|
27
|
+
it will choose the number of threads based on the RAYON_NUM_THREADS environment variable (if set),
|
|
28
|
+
or the number of logical CPUs (otherwise)
|
|
29
|
+
|
|
30
|
+
Returns
|
|
31
|
+
-------
|
|
32
|
+
lon, lat : array-like
|
|
33
|
+
The coordinates of the center of the HEALPix cells given as a longitude, latitude tuple.
|
|
34
|
+
|
|
35
|
+
Raises
|
|
36
|
+
------
|
|
37
|
+
ValueError
|
|
38
|
+
When the HEALPix cell indexes given have values out of :math:`[0, 4^{29 - depth}[`.
|
|
39
|
+
ValueError
|
|
40
|
+
When the name of the ellipsoid is unknown.
|
|
41
|
+
|
|
42
|
+
Examples
|
|
43
|
+
--------
|
|
44
|
+
>>> from healpix_geo.nested import healpix_to_lonlat
|
|
45
|
+
>>> import numpy as np
|
|
46
|
+
>>> cell_ids = np.array([42, 6, 10])
|
|
47
|
+
>>> depth = 3
|
|
48
|
+
>>> lon, lat = healpix_to_lonlat(ipix, depth, ellipsoid="WGS84")
|
|
49
|
+
"""
|
|
50
|
+
_check_depth(depth)
|
|
51
|
+
ipix = np.atleast_1d(ipix)
|
|
52
|
+
_check_ipixels(data=ipix, depth=depth)
|
|
53
|
+
ipix = ipix.astype(np.uint64)
|
|
54
|
+
|
|
55
|
+
num_threads = np.uint16(num_threads)
|
|
56
|
+
|
|
57
|
+
latitude = np.empty_like(ipix, dtype="float64")
|
|
58
|
+
longitude = np.empty_like(ipix, dtype="float64")
|
|
59
|
+
|
|
60
|
+
healpix_geo.nested.healpix_to_lonlat(
|
|
61
|
+
depth, ipix, ellipsoid, longitude, latitude, num_threads
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
return longitude, latitude
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def lonlat_to_healpix(longitude, latitude, depth, ellipsoid="sphere", num_threads=0):
|
|
68
|
+
r"""Get the HEALPix indexes that contains specific points.
|
|
69
|
+
|
|
70
|
+
Parameters
|
|
71
|
+
----------
|
|
72
|
+
lon : array-like
|
|
73
|
+
The longitudes of the input points, in degrees.
|
|
74
|
+
lat : array-like
|
|
75
|
+
The latitudes of the input points, in degrees.
|
|
76
|
+
depth : int or array-like of int
|
|
77
|
+
The HEALPix cell depth given as a `np.uint8` numpy array.
|
|
78
|
+
ellipsoid : str, default: "sphere"
|
|
79
|
+
Reference ellipsoid to evaluate healpix on. If ``"sphere"``, this will return
|
|
80
|
+
the same result as :py:func:`cdshealpix.nested.lonlat_to_healpix`.
|
|
81
|
+
num_threads : int, optional
|
|
82
|
+
Specifies the number of threads to use for the computation. Default to 0 means
|
|
83
|
+
it will choose the number of threads based on the RAYON_NUM_THREADS environment variable (if set),
|
|
84
|
+
or the number of logical CPUs (otherwise)
|
|
85
|
+
|
|
86
|
+
Returns
|
|
87
|
+
-------
|
|
88
|
+
ipix : `numpy.ndarray`
|
|
89
|
+
A numpy array containing all the HEALPix cell indexes stored as `np.uint64`.
|
|
90
|
+
|
|
91
|
+
Raises
|
|
92
|
+
------
|
|
93
|
+
ValueError
|
|
94
|
+
When the number of longitudes and latitudes given do not match.
|
|
95
|
+
ValueError
|
|
96
|
+
When the name of the ellipsoid is unknown.
|
|
97
|
+
|
|
98
|
+
Examples
|
|
99
|
+
--------
|
|
100
|
+
>>> from cdshealpix.ring import lonlat_to_healpix
|
|
101
|
+
>>> import numpy as np
|
|
102
|
+
>>> lon = np.array([0, 50, 25], dtype="float64")
|
|
103
|
+
>>> lat = np.array([6, -12, 45], dtype="float64")
|
|
104
|
+
>>> depth = 3
|
|
105
|
+
>>> ipix = lonlat_to_healpix(lon, lat, depth, ellipsoid="WGS84")
|
|
106
|
+
"""
|
|
107
|
+
_check_depth(depth)
|
|
108
|
+
longitude = np.atleast_1d(longitude).astype("float64")
|
|
109
|
+
latitude = np.atleast_1d(latitude).astype("float64")
|
|
110
|
+
|
|
111
|
+
num_threads = np.uint16(num_threads)
|
|
112
|
+
|
|
113
|
+
ipix = np.empty_like(longitude, dtype="uint64")
|
|
114
|
+
|
|
115
|
+
healpix_geo.nested.lonlat_to_healpix(
|
|
116
|
+
depth, longitude, latitude, ellipsoid, ipix, num_threads
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
return ipix
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def vertices(ipix, depth, ellipsoid, num_threads=0):
|
|
123
|
+
"""Get the longitudes and latitudes of the vertices of some HEALPix cells at a given depth.
|
|
124
|
+
|
|
125
|
+
This method returns the 4 vertices of each cell in `ipix`.
|
|
126
|
+
|
|
127
|
+
Parameters
|
|
128
|
+
----------
|
|
129
|
+
ipix : `numpy.ndarray`
|
|
130
|
+
The HEALPix cell indexes given as a `np.uint64` numpy array.
|
|
131
|
+
depth : int, or `numpy.ndarray`
|
|
132
|
+
The depth of the HEALPix cells. If given as an array, should have the same shape than ipix
|
|
133
|
+
ellipsoid : str, default: "sphere"
|
|
134
|
+
Reference ellipsoid to evaluate healpix on. If ``"sphere"``, this will return
|
|
135
|
+
the same result as :py:func:`cdshealpix.nested.vertices`.
|
|
136
|
+
num_threads : int, optional
|
|
137
|
+
Specifies the number of threads to use for the computation. Default to 0 means
|
|
138
|
+
it will choose the number of threads based on the RAYON_NUM_THREADS environment variable (if set),
|
|
139
|
+
or the number of logical CPUs (otherwise)
|
|
140
|
+
|
|
141
|
+
Returns
|
|
142
|
+
-------
|
|
143
|
+
longitude, latitude : array-like
|
|
144
|
+
The sky coordinates of the 4 vertices of the HEALPix cells.
|
|
145
|
+
`lon` and `lat` are of shape :math:`N` x :math:`4` numpy arrays where N is the number of HEALPix cell given in `ipix`.
|
|
146
|
+
|
|
147
|
+
Raises
|
|
148
|
+
------
|
|
149
|
+
ValueError
|
|
150
|
+
When the HEALPix cell indexes given have values out of :math:`[0, 4^{29 - depth}[`.
|
|
151
|
+
|
|
152
|
+
Examples
|
|
153
|
+
--------
|
|
154
|
+
>>> from healpix_geo.nested import vertices
|
|
155
|
+
>>> import numpy as np
|
|
156
|
+
>>> ipix = np.array([42, 6, 10])
|
|
157
|
+
>>> depth = 12
|
|
158
|
+
>>> lon, lat = vertices(ipix, depth, ellipsoid="sphere")
|
|
159
|
+
"""
|
|
160
|
+
_check_depth(depth)
|
|
161
|
+
ipix = np.atleast_1d(ipix)
|
|
162
|
+
_check_ipixels(data=ipix, depth=depth)
|
|
163
|
+
ipix = ipix.astype(np.uint64)
|
|
164
|
+
|
|
165
|
+
num_threads = np.uint16(num_threads)
|
|
166
|
+
|
|
167
|
+
shape = ipix.shape + (4,)
|
|
168
|
+
longitude = np.empty(shape=shape, dtype="float64")
|
|
169
|
+
latitude = np.empty(shape=shape, dtype="float64")
|
|
170
|
+
|
|
171
|
+
healpix_geo.nested.vertices(
|
|
172
|
+
depth, ipix, ellipsoid, longitude, latitude, num_threads
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
return longitude, latitude
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def kth_neighbourhood(ipix, depth, ring, num_threads=0):
|
|
179
|
+
"""Get the kth ring neighbouring cells of some HEALPix cells at a given depth.
|
|
180
|
+
|
|
181
|
+
This method returns a :math:`N` x :math:`(2 k + 1)^2` `np.uint64` numpy array containing the neighbours of each cell of the :math:`N` sized `ipix` array.
|
|
182
|
+
This method is wrapped around the `kth_neighbourhood <https://docs.rs/cdshealpix/0.1.5/cdshealpix/nested/struct.Layer.html#method.kth_neighbourhood>`__
|
|
183
|
+
method from the `cdshealpix Rust crate <https://crates.io/crates/cdshealpix>`__.
|
|
184
|
+
|
|
185
|
+
Parameters
|
|
186
|
+
----------
|
|
187
|
+
ipix : `numpy.ndarray`
|
|
188
|
+
The HEALPix cell indexes given as a `np.uint64` numpy array.
|
|
189
|
+
depth : int
|
|
190
|
+
The depth of the HEALPix cells.
|
|
191
|
+
ring : int
|
|
192
|
+
The number of rings. `ring=0` returns just the input cell ids, `ring=1` returns the 8 (or 7) immediate
|
|
193
|
+
neighbours, `ring=2` returns the 8 (or 7) immediate neighbours plus their immediate neighbours (a total of 24 cells), and so on.
|
|
194
|
+
num_threads : int, optional
|
|
195
|
+
Specifies the number of threads to use for the computation. Default to 0 means
|
|
196
|
+
it will choose the number of threads based on the RAYON_NUM_THREADS environment variable (if set),
|
|
197
|
+
or the number of logical CPUs (otherwise)
|
|
198
|
+
|
|
199
|
+
Returns
|
|
200
|
+
-------
|
|
201
|
+
neighbours : `numpy.ndarray`
|
|
202
|
+
A :math:`N` x :math:`(2 k + 1)^2` `np.int64` numpy array containing the kth ring neighbours of each cell.
|
|
203
|
+
The :math:`5^{th}` element corresponds to the index of HEALPix cell from which the neighbours are evaluated.
|
|
204
|
+
All its 8 neighbours occup the remaining elements of the line.
|
|
205
|
+
|
|
206
|
+
Raises
|
|
207
|
+
------
|
|
208
|
+
ValueError
|
|
209
|
+
When the HEALPix cell indexes given have values out of :math:`[0, 4^{29 - depth}[`.
|
|
210
|
+
|
|
211
|
+
Examples
|
|
212
|
+
--------
|
|
213
|
+
>>> from cdshealpix import neighbours_in_kth_ring
|
|
214
|
+
>>> import numpy as np
|
|
215
|
+
>>> ipix = np.array([42, 6, 10])
|
|
216
|
+
>>> depth = 12
|
|
217
|
+
>>> ring = 3
|
|
218
|
+
>>> neighbours = neighbours_in_kth_ring(ipix, depth, ring)
|
|
219
|
+
"""
|
|
220
|
+
_check_depth(depth)
|
|
221
|
+
ipix = np.atleast_1d(ipix)
|
|
222
|
+
_check_ipixels(data=ipix, depth=depth)
|
|
223
|
+
ipix = ipix.astype(np.uint64)
|
|
224
|
+
_check_ring(depth, ring)
|
|
225
|
+
|
|
226
|
+
# Allocation of the array containing the neighbours
|
|
227
|
+
neighbours = np.full(
|
|
228
|
+
(*ipix.shape, (2 * ring + 1) ** 2), dtype=np.int64, fill_value=-1
|
|
229
|
+
)
|
|
230
|
+
num_threads = np.uint16(num_threads)
|
|
231
|
+
healpix_geo.nested.kth_neighbourhood(depth, ipix, ring, neighbours, num_threads)
|
|
232
|
+
|
|
233
|
+
return neighbours
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
def zoom_to(ipix, depth, new_depth, num_threads=0):
|
|
237
|
+
r"""Change the resolutions the given cell ids
|
|
238
|
+
|
|
239
|
+
Parameters
|
|
240
|
+
----------
|
|
241
|
+
ipix : numpy.ndarray
|
|
242
|
+
The HEALPix cell indexes given as a `np.uint64` numpy array.
|
|
243
|
+
depth : int
|
|
244
|
+
The depth of the HEALPix cells.
|
|
245
|
+
new_depth : int
|
|
246
|
+
The new depth of the HEALPix cells.
|
|
247
|
+
|
|
248
|
+
Returns
|
|
249
|
+
-------
|
|
250
|
+
cells : numpy.ndarray
|
|
251
|
+
A :math:`N` (`depth >= new_depth`) or :math:`N` x :math:`4^{\delta d}` `np.int64` numpy array containing the parents or children of the given cells.
|
|
252
|
+
If `depth == new_depth`, returns the input pixels
|
|
253
|
+
"""
|
|
254
|
+
_check_depth(depth)
|
|
255
|
+
_check_depth(new_depth)
|
|
256
|
+
|
|
257
|
+
if depth == new_depth:
|
|
258
|
+
return ipix
|
|
259
|
+
|
|
260
|
+
ipix = np.atleast_1d(ipix)
|
|
261
|
+
_check_ipixels(data=ipix, depth=depth)
|
|
262
|
+
ipix = ipix.astype(np.uint64)
|
|
263
|
+
|
|
264
|
+
num_threads = np.uint16(num_threads)
|
|
265
|
+
if depth > new_depth:
|
|
266
|
+
result = np.full_like(ipix, fill_value=0)
|
|
267
|
+
else:
|
|
268
|
+
relative_depth = new_depth - depth
|
|
269
|
+
shape = (*ipix.shape, 4**relative_depth)
|
|
270
|
+
result = np.full(shape, fill_value=0, dtype="uint64")
|
|
271
|
+
|
|
272
|
+
healpix_geo.nested.zoom_to(depth, ipix, new_depth, result, num_threads)
|
|
273
|
+
|
|
274
|
+
return result
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
def siblings(ipix, depth, num_threads=0):
|
|
278
|
+
r"""Find the siblings for every cell
|
|
279
|
+
|
|
280
|
+
Parameters
|
|
281
|
+
----------
|
|
282
|
+
ipix : numpy.ndarray
|
|
283
|
+
The HEALPix cell indexes given as a `np.uint64` numpy array.
|
|
284
|
+
depth : int
|
|
285
|
+
The depth of the HEALPix cells.
|
|
286
|
+
|
|
287
|
+
Returns
|
|
288
|
+
-------
|
|
289
|
+
cells : numpy.ndarray
|
|
290
|
+
A :math:`N` x :math:`4` or :math:`N` x :math:`12` `np.uint64` numpy array containing the siblings of the given cells.
|
|
291
|
+
If `depth == 0`, the siblings are the base cells.
|
|
292
|
+
"""
|
|
293
|
+
_check_depth(depth)
|
|
294
|
+
ipix = np.atleast_1d(ipix)
|
|
295
|
+
_check_ipixels(data=ipix, depth=depth)
|
|
296
|
+
ipix = ipix.astype(np.uint64)
|
|
297
|
+
|
|
298
|
+
num_threads = np.uint16(num_threads)
|
|
299
|
+
|
|
300
|
+
if depth != 0:
|
|
301
|
+
shape = (*ipix.shape, 4)
|
|
302
|
+
else:
|
|
303
|
+
shape = (*ipix.shape, 12)
|
|
304
|
+
|
|
305
|
+
result = np.full(shape, fill_value=0, dtype="uint64")
|
|
306
|
+
|
|
307
|
+
healpix_geo.nested.siblings(depth, ipix, result, num_threads)
|
|
308
|
+
|
|
309
|
+
return result
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
def angular_distances(from_, to_, depth, num_threads=0):
|
|
313
|
+
"""Compute the angular distances between cell centers
|
|
314
|
+
|
|
315
|
+
Parameters
|
|
316
|
+
----------
|
|
317
|
+
from_ : numpy.ndarray
|
|
318
|
+
The source Healpix cell indexes given as a ``np.uint64`` numpy array. Should be 1D.
|
|
319
|
+
to_ : numpy.ndarray
|
|
320
|
+
The destination Healpix cell indexes given as a ``np.uint64`` numpy array.
|
|
321
|
+
Should be 2D.
|
|
322
|
+
depth : int
|
|
323
|
+
The depth of the Healpix cells.
|
|
324
|
+
num_threads : int, default: 0
|
|
325
|
+
Specifies the number of threads to use for the computation. Default to 0 means
|
|
326
|
+
it will choose the number of threads based on the RAYON_NUM_THREADS environment variable (if set),
|
|
327
|
+
or the number of logical CPUs (otherwise)
|
|
328
|
+
|
|
329
|
+
Returns
|
|
330
|
+
-------
|
|
331
|
+
distances : numpy.ndarray
|
|
332
|
+
The angular distances in radians.
|
|
333
|
+
|
|
334
|
+
Raises
|
|
335
|
+
------
|
|
336
|
+
ValueError
|
|
337
|
+
When the Healpix cell indexes given have values out of :math:`[0, 4^{depth}[`.
|
|
338
|
+
"""
|
|
339
|
+
_check_depth(depth)
|
|
340
|
+
|
|
341
|
+
from_ = np.atleast_1d(from_)
|
|
342
|
+
_check_ipixels(data=from_, depth=depth)
|
|
343
|
+
from_ = from_.astype("uint64")
|
|
344
|
+
|
|
345
|
+
mask = to_ != -1
|
|
346
|
+
masked_to = np.where(mask, to_, 0)
|
|
347
|
+
|
|
348
|
+
to_ = np.atleast_1d(masked_to)
|
|
349
|
+
_check_ipixels(data=to_, depth=depth)
|
|
350
|
+
to_ = to_.astype("uint64")
|
|
351
|
+
|
|
352
|
+
if from_.shape != to_.shape and from_.shape != to_.shape[:-1]:
|
|
353
|
+
raise ValueError(
|
|
354
|
+
"The shape of `from_` must be compatible with the shape of `to_`:\n"
|
|
355
|
+
f"{to_.shape} or {to_.shape[:-1]} must be equal to {from_.shape}."
|
|
356
|
+
)
|
|
357
|
+
|
|
358
|
+
if from_.shape == to_.shape:
|
|
359
|
+
intermediate_shape = to_.shape + (1,)
|
|
360
|
+
else:
|
|
361
|
+
intermediate_shape = to_.shape
|
|
362
|
+
|
|
363
|
+
distances = np.full(intermediate_shape, dtype="float64", fill_value=np.nan)
|
|
364
|
+
num_threads = np.uint16(num_threads)
|
|
365
|
+
|
|
366
|
+
healpix_geo.nested.angular_distances(
|
|
367
|
+
depth, from_, np.reshape(to_, intermediate_shape), distances, num_threads
|
|
368
|
+
)
|
|
369
|
+
|
|
370
|
+
return np.where(mask, np.reshape(distances, to_.shape), np.nan)
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
def zone_coverage(bbox, depth, *, ellipsoid="sphere", flat=True):
|
|
374
|
+
"""Search the cells covering the given bounding box
|
|
375
|
+
|
|
376
|
+
Parameters
|
|
377
|
+
----------
|
|
378
|
+
bbox : tuple of float
|
|
379
|
+
The 2D bounding box to rasterize.
|
|
380
|
+
depth : int
|
|
381
|
+
The maximum depth of the cells to be returned.
|
|
382
|
+
ellipsoid : str, default: "sphere"
|
|
383
|
+
Reference ellipsoid to evaluate healpix on. If ``"sphere"``, this will return
|
|
384
|
+
the same result as :py:func:`cdshealpix.nested.healpix_to_lonlat`.
|
|
385
|
+
flat : bool, default: True
|
|
386
|
+
If ``True``, the cells returned will all be at the passed depth.
|
|
387
|
+
|
|
388
|
+
Returns
|
|
389
|
+
-------
|
|
390
|
+
cell_ids : numpy.ndarray
|
|
391
|
+
The rasterized cell ids.
|
|
392
|
+
depths : numpy.ndarray
|
|
393
|
+
The depths of the cell ids. If ``flat is True``, these will all have the same value.
|
|
394
|
+
fully_covered : numpy.ndarray
|
|
395
|
+
Boolean array marking whether the cells are fully covered by the bounding box.
|
|
396
|
+
"""
|
|
397
|
+
_check_depth(depth)
|
|
398
|
+
|
|
399
|
+
return healpix_geo.nested.zone_coverage(depth, bbox, ellipsoid=ellipsoid, flat=flat)
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
def box_coverage(center, size, angle, depth, *, ellipsoid="sphere", flat=True):
|
|
403
|
+
"""Search the cells covering the given box.
|
|
404
|
+
|
|
405
|
+
Parameters
|
|
406
|
+
----------
|
|
407
|
+
center : numpy.ndarray or tuple of float
|
|
408
|
+
The center of the box, either as a 2-sized array or as a 2-tuple of float.
|
|
409
|
+
size : numpy.ndarray or tuple of float
|
|
410
|
+
The size of the box, in degree.
|
|
411
|
+
angle : float
|
|
412
|
+
The angle by which the box is rotated, in degree.
|
|
413
|
+
depth : int
|
|
414
|
+
The maximum depth of the cells to be returned.
|
|
415
|
+
ellipsoid : str, default: "sphere"
|
|
416
|
+
Reference ellipsoid to evaluate healpix on. If ``"sphere"``, this will return
|
|
417
|
+
the same result as :py:func:`cdshealpix.nested.healpix_to_lonlat`.
|
|
418
|
+
flat : bool, default: True
|
|
419
|
+
If ``True``, the cells returned will all be at the passed depth.
|
|
420
|
+
|
|
421
|
+
Returns
|
|
422
|
+
-------
|
|
423
|
+
cell_ids : numpy.ndarray
|
|
424
|
+
The rasterized cell ids.
|
|
425
|
+
depths : numpy.ndarray
|
|
426
|
+
The depths of the cell ids. If ``flat is True``, these will all have the same value.
|
|
427
|
+
fully_covered : numpy.ndarray
|
|
428
|
+
Boolean array marking whether the cells are fully covered by the box.
|
|
429
|
+
"""
|
|
430
|
+
_check_depth(depth)
|
|
431
|
+
|
|
432
|
+
if not isinstance(center, tuple):
|
|
433
|
+
center = tuple(center)
|
|
434
|
+
if not isinstance(size, tuple):
|
|
435
|
+
size = tuple(size)
|
|
436
|
+
|
|
437
|
+
return healpix_geo.nested.box_coverage(
|
|
438
|
+
depth, center, size, angle, ellipsoid=ellipsoid, flat=flat
|
|
439
|
+
)
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
def polygon_coverage(vertices, depth, *, ellipsoid="sphere", flat=True):
|
|
443
|
+
"""Search the cells covering the given polygon.
|
|
444
|
+
|
|
445
|
+
Parameters
|
|
446
|
+
----------
|
|
447
|
+
vertices : numpy.ndarray
|
|
448
|
+
The vertices of the polygon without holes. Must be an array of shape ``(n, 2)``.
|
|
449
|
+
depth : int
|
|
450
|
+
The maximum depth of the cells to be returned.
|
|
451
|
+
ellipsoid : str, default: "sphere"
|
|
452
|
+
Reference ellipsoid to evaluate healpix on. If ``"sphere"``, this will return
|
|
453
|
+
the same result as :py:func:`cdshealpix.nested.healpix_to_lonlat`.
|
|
454
|
+
flat : bool, default: True
|
|
455
|
+
If ``True``, the cells returned will all be at the passed depth.
|
|
456
|
+
|
|
457
|
+
Returns
|
|
458
|
+
-------
|
|
459
|
+
cell_ids : numpy.ndarray
|
|
460
|
+
The rasterized cell ids.
|
|
461
|
+
depths : numpy.ndarray
|
|
462
|
+
The depths of the cell ids. If ``flat is True``, these will all have the same value.
|
|
463
|
+
fully_covered : numpy.ndarray
|
|
464
|
+
Boolean array marking whether the cells are fully covered by the polygon.
|
|
465
|
+
"""
|
|
466
|
+
_check_depth(depth)
|
|
467
|
+
|
|
468
|
+
return healpix_geo.nested.polygon_coverage(
|
|
469
|
+
depth, vertices, ellipsoid=ellipsoid, flat=flat
|
|
470
|
+
)
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
def cone_coverage(
|
|
474
|
+
center, radius, depth, *, delta_depth=0, ellipsoid="sphere", flat=True
|
|
475
|
+
):
|
|
476
|
+
"""Search the cells covering the given cone
|
|
477
|
+
|
|
478
|
+
Cone in this case means a circle on the surface of the reference ellipsoid.
|
|
479
|
+
|
|
480
|
+
Parameters
|
|
481
|
+
----------
|
|
482
|
+
center : numpy.ndarray or tuple of float
|
|
483
|
+
The center of the box, either as a 2-sized array or as a 2-tuple of float.
|
|
484
|
+
radius : float
|
|
485
|
+
The radius of the cone, in degree.
|
|
486
|
+
depth : int
|
|
487
|
+
The maximum depth of the cells to be returned.
|
|
488
|
+
ellipsoid : str, default: "sphere"
|
|
489
|
+
Reference ellipsoid to evaluate healpix on. If ``"sphere"``, this will return
|
|
490
|
+
the same result as :py:func:`cdshealpix.nested.healpix_to_lonlat`.
|
|
491
|
+
flat : bool, default: True
|
|
492
|
+
If ``True``, the cells returned will all be at the passed depth.
|
|
493
|
+
|
|
494
|
+
Returns
|
|
495
|
+
-------
|
|
496
|
+
cell_ids : numpy.ndarray
|
|
497
|
+
The rasterized cell ids.
|
|
498
|
+
depths : numpy.ndarray
|
|
499
|
+
The depths of the cell ids. If ``flat is True``, these will all have the same value.
|
|
500
|
+
fully_covered : numpy.ndarray
|
|
501
|
+
Boolean array marking whether the cells are fully covered by the circle.
|
|
502
|
+
"""
|
|
503
|
+
_check_depth(depth)
|
|
504
|
+
|
|
505
|
+
if not isinstance(center, tuple):
|
|
506
|
+
center = tuple(center)
|
|
507
|
+
|
|
508
|
+
return healpix_geo.nested.cone_coverage(
|
|
509
|
+
depth, center, radius, delta_depth=delta_depth, ellipsoid=ellipsoid, flat=flat
|
|
510
|
+
)
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
def elliptical_cone_coverage(
|
|
514
|
+
center,
|
|
515
|
+
ellipse_geometry,
|
|
516
|
+
position_angle,
|
|
517
|
+
depth,
|
|
518
|
+
*,
|
|
519
|
+
delta_depth=0,
|
|
520
|
+
ellipsoid="sphere",
|
|
521
|
+
flat=True,
|
|
522
|
+
):
|
|
523
|
+
"""Search the cells covering the given elliptical cone.
|
|
524
|
+
|
|
525
|
+
Elliptical cone in this case refers to an ellipse on the surface of the reference ellipsoid.
|
|
526
|
+
|
|
527
|
+
Parameters
|
|
528
|
+
----------
|
|
529
|
+
center : numpy.ndarray or tuple of float
|
|
530
|
+
The center of the box, either as a 2-sized array or as a 2-tuple of float.
|
|
531
|
+
ellipse_geometry : numpy.ndarray or tuple of float
|
|
532
|
+
The semimajor and semimajor axis, as a 2-sized array or as a 2-tuple of float.
|
|
533
|
+
position_angle : float
|
|
534
|
+
The orientation of the ellipse.
|
|
535
|
+
depth : int
|
|
536
|
+
The maximum depth of the cells to be returned.
|
|
537
|
+
ellipsoid : str, default: "sphere"
|
|
538
|
+
Reference ellipsoid to evaluate healpix on. If ``"sphere"``, this will return
|
|
539
|
+
the same result as :py:func:`cdshealpix.nested.healpix_to_lonlat`.
|
|
540
|
+
flat : bool, default: True
|
|
541
|
+
If ``True``, the cells returned will all be at the passed depth.
|
|
542
|
+
|
|
543
|
+
Returns
|
|
544
|
+
-------
|
|
545
|
+
cell_ids : numpy.ndarray
|
|
546
|
+
The rasterized cell ids.
|
|
547
|
+
depths : numpy.ndarray
|
|
548
|
+
The depths of the cell ids. If ``flat is True``, these will all have the same value.
|
|
549
|
+
fully_covered : numpy.ndarray
|
|
550
|
+
Boolean array marking whether the cells are fully covered by the ellipse.
|
|
551
|
+
"""
|
|
552
|
+
_check_depth(depth)
|
|
553
|
+
|
|
554
|
+
if not isinstance(center, tuple):
|
|
555
|
+
center = tuple(center)
|
|
556
|
+
if not isinstance(ellipse_geometry, tuple):
|
|
557
|
+
ellipse_geometry = tuple(ellipse_geometry)
|
|
558
|
+
|
|
559
|
+
return healpix_geo.nested.elliptical_cone_coverage(
|
|
560
|
+
depth,
|
|
561
|
+
center,
|
|
562
|
+
ellipse_geometry,
|
|
563
|
+
position_angle,
|
|
564
|
+
delta_depth=delta_depth,
|
|
565
|
+
ellipsoid=ellipsoid,
|
|
566
|
+
flat=flat,
|
|
567
|
+
)
|