healpix-geo 0.0.4__cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl → 0.0.5__cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.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.
- healpix_geo/healpix_geo.cpython-310-powerpc64le-linux-gnu.so +0 -0
- healpix_geo/nested.py +165 -0
- healpix_geo/ring.py +163 -0
- healpix_geo/tests/test_index.py +9 -1
- healpix_geo/tests/test_inference.py +185 -0
- {healpix_geo-0.0.4.dist-info → healpix_geo-0.0.5.dist-info}/METADATA +10 -1
- healpix_geo-0.0.5.dist-info/RECORD +14 -0
- {healpix_geo-0.0.4.dist-info → healpix_geo-0.0.5.dist-info}/WHEEL +1 -1
- healpix_geo-0.0.4.dist-info/RECORD +0 -13
- {healpix_geo-0.0.4.dist-info → healpix_geo-0.0.5.dist-info}/licenses/LICENSE +0 -0
|
Binary file
|
healpix_geo/nested.py
CHANGED
|
@@ -10,6 +10,171 @@ def create_empty(depth):
|
|
|
10
10
|
return RangeMOCIndex.create_empty(depth)
|
|
11
11
|
|
|
12
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
|
+
|
|
13
178
|
def kth_neighbourhood(ipix, depth, ring, num_threads=0):
|
|
14
179
|
"""Get the kth ring neighbouring cells of some HEALPix cells at a given depth.
|
|
15
180
|
|
healpix_geo/ring.py
CHANGED
|
@@ -4,6 +4,169 @@ from healpix_geo import healpix_geo
|
|
|
4
4
|
from healpix_geo.utils import _check_depth, _check_ipixels, _check_ring
|
|
5
5
|
|
|
6
6
|
|
|
7
|
+
def healpix_to_lonlat(ipix, depth, ellipsoid="sphere", num_threads=0):
|
|
8
|
+
r"""Get the longitudes and latitudes of the center of some HEALPix cells.
|
|
9
|
+
|
|
10
|
+
Parameters
|
|
11
|
+
----------
|
|
12
|
+
ipix : `numpy.ndarray`
|
|
13
|
+
The HEALPix cell indexes given as a `np.uint64` numpy array.
|
|
14
|
+
depth : `numpy.ndarray`
|
|
15
|
+
The HEALPix cell depth given as a `np.uint8` numpy array.
|
|
16
|
+
ellipsoid : str, default: "sphere"
|
|
17
|
+
Reference ellipsoid to evaluate healpix on. If ``"sphere"``, this will return
|
|
18
|
+
the same result as :py:func:`cdshealpix.ring.healpix_to_lonlat`.
|
|
19
|
+
num_threads : int, optional
|
|
20
|
+
Specifies the number of threads to use for the computation. Default to 0 means
|
|
21
|
+
it will choose the number of threads based on the RAYON_NUM_THREADS environment variable (if set),
|
|
22
|
+
or the number of logical CPUs (otherwise)
|
|
23
|
+
|
|
24
|
+
Returns
|
|
25
|
+
-------
|
|
26
|
+
lon, lat : array-like
|
|
27
|
+
The coordinates of the center of the HEALPix cells given as a longitude, latitude tuple.
|
|
28
|
+
|
|
29
|
+
Raises
|
|
30
|
+
------
|
|
31
|
+
ValueError
|
|
32
|
+
When the HEALPix cell indexes given have values out of :math:`[0, 4^{29 - depth}[`.
|
|
33
|
+
ValueError
|
|
34
|
+
When the name of the ellipsoid is unknown.
|
|
35
|
+
|
|
36
|
+
Examples
|
|
37
|
+
--------
|
|
38
|
+
>>> from healpix_geo.ring import healpix_to_lonlat
|
|
39
|
+
>>> import numpy as np
|
|
40
|
+
>>> cell_ids = np.array([42, 6, 10])
|
|
41
|
+
>>> depth = 3
|
|
42
|
+
>>> lon, lat = healpix_to_lonlat(ipix, depth, ellipsoid="WGS84")
|
|
43
|
+
"""
|
|
44
|
+
_check_depth(depth)
|
|
45
|
+
ipix = np.atleast_1d(ipix)
|
|
46
|
+
_check_ipixels(data=ipix, depth=depth)
|
|
47
|
+
ipix = ipix.astype(np.uint64)
|
|
48
|
+
|
|
49
|
+
num_threads = np.uint16(num_threads)
|
|
50
|
+
|
|
51
|
+
latitude = np.empty_like(ipix, dtype="float64")
|
|
52
|
+
longitude = np.empty_like(ipix, dtype="float64")
|
|
53
|
+
|
|
54
|
+
healpix_geo.ring.healpix_to_lonlat(
|
|
55
|
+
depth, ipix, ellipsoid, longitude, latitude, num_threads
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
return longitude, latitude
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def lonlat_to_healpix(longitude, latitude, depth, ellipsoid="sphere", num_threads=0):
|
|
62
|
+
r"""Get the HEALPix indexes that contains specific points.
|
|
63
|
+
|
|
64
|
+
Parameters
|
|
65
|
+
----------
|
|
66
|
+
lon : array-like
|
|
67
|
+
The longitudes of the input points, in degrees.
|
|
68
|
+
lat : array-like
|
|
69
|
+
The latitudes of the input points, in degrees.
|
|
70
|
+
depth : int or array-like of int
|
|
71
|
+
The HEALPix cell depth given as a `np.uint8` numpy array.
|
|
72
|
+
ellipsoid : str, default: "sphere"
|
|
73
|
+
Reference ellipsoid to evaluate healpix on. If ``"sphere"``, this will return
|
|
74
|
+
the same result as :py:func:`cdshealpix.ring.lonlat_to_healpix`.
|
|
75
|
+
num_threads : int, optional
|
|
76
|
+
Specifies the number of threads to use for the computation. Default to 0 means
|
|
77
|
+
it will choose the number of threads based on the RAYON_NUM_THREADS environment variable (if set),
|
|
78
|
+
or the number of logical CPUs (otherwise)
|
|
79
|
+
|
|
80
|
+
Returns
|
|
81
|
+
-------
|
|
82
|
+
ipix : `numpy.ndarray`
|
|
83
|
+
A numpy array containing all the HEALPix cell indexes stored as `np.uint64`.
|
|
84
|
+
|
|
85
|
+
Raises
|
|
86
|
+
------
|
|
87
|
+
ValueError
|
|
88
|
+
When the number of longitudes and latitudes given do not match.
|
|
89
|
+
ValueError
|
|
90
|
+
When the name of the ellipsoid is unknown.
|
|
91
|
+
|
|
92
|
+
Examples
|
|
93
|
+
--------
|
|
94
|
+
>>> from cdshealpix.ring import lonlat_to_healpix
|
|
95
|
+
>>> import numpy as np
|
|
96
|
+
>>> lon = np.array([0, 50, 25], dtype="float64")
|
|
97
|
+
>>> lat = np.array([6, -12, 45], dtype="float64")
|
|
98
|
+
>>> depth = 3
|
|
99
|
+
>>> ipix = lonlat_to_healpix(lon, lat, depth, ellipsoid="WGS84")
|
|
100
|
+
"""
|
|
101
|
+
_check_depth(depth)
|
|
102
|
+
longitude = np.atleast_1d(longitude).astype("float64")
|
|
103
|
+
latitude = np.atleast_1d(latitude).astype("float64")
|
|
104
|
+
|
|
105
|
+
num_threads = np.uint16(num_threads)
|
|
106
|
+
|
|
107
|
+
ipix = np.empty_like(longitude, dtype="uint64")
|
|
108
|
+
|
|
109
|
+
healpix_geo.ring.lonlat_to_healpix(
|
|
110
|
+
depth, longitude, latitude, ellipsoid, ipix, num_threads
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
return ipix
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def vertices(ipix, depth, ellipsoid, num_threads=0):
|
|
117
|
+
"""Get the longitudes and latitudes of the vertices of some HEALPix cells at a given depth.
|
|
118
|
+
|
|
119
|
+
This method returns the 4 vertices of each cell in `ipix`.
|
|
120
|
+
|
|
121
|
+
Parameters
|
|
122
|
+
----------
|
|
123
|
+
ipix : `numpy.ndarray`
|
|
124
|
+
The HEALPix cell indexes given as a `np.uint64` numpy array.
|
|
125
|
+
depth : int, or `numpy.ndarray`
|
|
126
|
+
The depth of the HEALPix cells. If given as an array, should have the same shape than ipix
|
|
127
|
+
ellipsoid : str, default: "sphere"
|
|
128
|
+
Reference ellipsoid to evaluate healpix on. If ``"sphere"``, this will return
|
|
129
|
+
the same result as :py:func:`cdshealpix.ring.vertices`.
|
|
130
|
+
num_threads : int, optional
|
|
131
|
+
Specifies the number of threads to use for the computation. Default to 0 means
|
|
132
|
+
it will choose the number of threads based on the RAYON_NUM_THREADS environment variable (if set),
|
|
133
|
+
or the number of logical CPUs (otherwise)
|
|
134
|
+
|
|
135
|
+
Returns
|
|
136
|
+
-------
|
|
137
|
+
longitude, latitude : array-like
|
|
138
|
+
The sky coordinates of the 4 vertices of the HEALPix cells.
|
|
139
|
+
`lon` and `lat` are of shape :math:`N` x :math:`4` numpy arrays where N is the number of HEALPix cell given in `ipix`.
|
|
140
|
+
|
|
141
|
+
Raises
|
|
142
|
+
------
|
|
143
|
+
ValueError
|
|
144
|
+
When the HEALPix cell indexes given have values out of :math:`[0, 4^{29 - depth}[`.
|
|
145
|
+
|
|
146
|
+
Examples
|
|
147
|
+
--------
|
|
148
|
+
>>> from healpix_geo.ring import vertices
|
|
149
|
+
>>> import numpy as np
|
|
150
|
+
>>> ipix = np.array([42, 6, 10])
|
|
151
|
+
>>> depth = 12
|
|
152
|
+
>>> lon, lat = vertices(ipix, depth, ellipsoid="sphere")
|
|
153
|
+
"""
|
|
154
|
+
_check_depth(depth)
|
|
155
|
+
ipix = np.atleast_1d(ipix)
|
|
156
|
+
_check_ipixels(data=ipix, depth=depth)
|
|
157
|
+
ipix = ipix.astype(np.uint64)
|
|
158
|
+
|
|
159
|
+
num_threads = np.uint16(num_threads)
|
|
160
|
+
|
|
161
|
+
shape = ipix.shape + (4,)
|
|
162
|
+
longitude = np.empty(shape=shape, dtype="float64")
|
|
163
|
+
latitude = np.empty(shape=shape, dtype="float64")
|
|
164
|
+
|
|
165
|
+
healpix_geo.ring.vertices(depth, ipix, ellipsoid, longitude, latitude, num_threads)
|
|
166
|
+
|
|
167
|
+
return longitude, latitude
|
|
168
|
+
|
|
169
|
+
|
|
7
170
|
def kth_neighbourhood(ipix, depth, ring, num_threads=0):
|
|
8
171
|
"""Get the kth ring neighbouring cells of some HEALPix cells at a given depth.
|
|
9
172
|
|
healpix_geo/tests/test_index.py
CHANGED
|
@@ -102,7 +102,15 @@ class TestRangeMOCIndex:
|
|
|
102
102
|
),
|
|
103
103
|
)
|
|
104
104
|
@pytest.mark.parametrize(
|
|
105
|
-
"indexer",
|
|
105
|
+
"indexer",
|
|
106
|
+
[
|
|
107
|
+
slice(None),
|
|
108
|
+
slice(None, 4),
|
|
109
|
+
slice(2, None),
|
|
110
|
+
slice(3, 7),
|
|
111
|
+
np.arange(5, dtype="uint64"),
|
|
112
|
+
np.array([1, 2, 4, 6, 8], dtype="uint64"),
|
|
113
|
+
],
|
|
106
114
|
)
|
|
107
115
|
def test_isel(self, level, cell_ids, indexer):
|
|
108
116
|
expected = cell_ids[indexer]
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import cdshealpix
|
|
2
|
+
import numpy as np
|
|
3
|
+
import pytest
|
|
4
|
+
from astropy.coordinates import Latitude, Longitude
|
|
5
|
+
|
|
6
|
+
import healpix_geo
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class TestHealpixToGeographic:
|
|
10
|
+
@pytest.mark.parametrize(
|
|
11
|
+
["cell_ids", "depth", "indexing_scheme"],
|
|
12
|
+
(
|
|
13
|
+
pytest.param(np.array([0, 4, 5, 7, 9]), 0, "ring", id="level0-ring"),
|
|
14
|
+
pytest.param(np.array([1, 2, 3, 8]), 0, "nested", id="level0-nested"),
|
|
15
|
+
pytest.param(
|
|
16
|
+
np.array([3, 19, 54, 63, 104, 127]), 4, "ring", id="level4-ring"
|
|
17
|
+
),
|
|
18
|
+
pytest.param(
|
|
19
|
+
np.array([22, 89, 134, 154, 190]), 4, "nested", id="level4-nested"
|
|
20
|
+
),
|
|
21
|
+
),
|
|
22
|
+
)
|
|
23
|
+
def test_spherical(self, cell_ids, depth, indexing_scheme):
|
|
24
|
+
if indexing_scheme == "ring":
|
|
25
|
+
param_cds = 2**depth
|
|
26
|
+
hg_healpix_to_lonlat = healpix_geo.ring.healpix_to_lonlat
|
|
27
|
+
cds_healpix_to_lonlat = cdshealpix.ring.healpix_to_lonlat
|
|
28
|
+
else:
|
|
29
|
+
param_cds = depth
|
|
30
|
+
hg_healpix_to_lonlat = healpix_geo.nested.healpix_to_lonlat
|
|
31
|
+
cds_healpix_to_lonlat = cdshealpix.nested.healpix_to_lonlat
|
|
32
|
+
|
|
33
|
+
actual_lon, actual_lat = hg_healpix_to_lonlat(
|
|
34
|
+
cell_ids, depth, ellipsoid="sphere"
|
|
35
|
+
)
|
|
36
|
+
expected_lon_, expected_lat_ = cds_healpix_to_lonlat(cell_ids, param_cds)
|
|
37
|
+
expected_lon = np.asarray(expected_lon_.to("degree"))
|
|
38
|
+
expected_lat = np.asarray(expected_lat_.to("degree"))
|
|
39
|
+
|
|
40
|
+
np.testing.assert_allclose(actual_lon, expected_lon)
|
|
41
|
+
np.testing.assert_allclose(actual_lat, expected_lat)
|
|
42
|
+
|
|
43
|
+
@pytest.mark.parametrize("ellipsoid", ["unitsphere", "sphere", "WGS84", "bessel"])
|
|
44
|
+
@pytest.mark.parametrize("depth", [0, 1, 9])
|
|
45
|
+
@pytest.mark.parametrize("indexing_scheme", ["ring", "nested"])
|
|
46
|
+
def test_ellipsoidal(self, depth, indexing_scheme, ellipsoid):
|
|
47
|
+
cell_ids = np.arange(12)
|
|
48
|
+
if indexing_scheme == "ring":
|
|
49
|
+
param_cds = 2**depth
|
|
50
|
+
hg_healpix_to_lonlat = healpix_geo.ring.healpix_to_lonlat
|
|
51
|
+
cds_healpix_to_lonlat = cdshealpix.ring.healpix_to_lonlat
|
|
52
|
+
else:
|
|
53
|
+
param_cds = depth
|
|
54
|
+
hg_healpix_to_lonlat = healpix_geo.nested.healpix_to_lonlat
|
|
55
|
+
cds_healpix_to_lonlat = cdshealpix.nested.healpix_to_lonlat
|
|
56
|
+
|
|
57
|
+
actual_lon, actual_lat = hg_healpix_to_lonlat(
|
|
58
|
+
cell_ids, depth, ellipsoid=ellipsoid
|
|
59
|
+
)
|
|
60
|
+
expected_lon_, expected_lat_ = cds_healpix_to_lonlat(cell_ids, param_cds)
|
|
61
|
+
expected_lon = np.asarray(expected_lon_.to("degree"))
|
|
62
|
+
expected_lat = np.asarray(expected_lat_.to("degree"))
|
|
63
|
+
|
|
64
|
+
np.testing.assert_allclose(actual_lon, expected_lon)
|
|
65
|
+
|
|
66
|
+
diff_lat = actual_lat - expected_lat
|
|
67
|
+
assert np.all(abs(diff_lat) < 0.3)
|
|
68
|
+
|
|
69
|
+
signs = np.array([-1, 1])
|
|
70
|
+
actual = signs[(actual_lat >= 0).astype(int)]
|
|
71
|
+
expected_ = np.sign(diff_lat)
|
|
72
|
+
expected = np.where(expected_ == 0, 1, expected_)
|
|
73
|
+
assert np.all(diff_lat == 0) or np.all(actual == expected)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class TestGeographicToHealpix:
|
|
77
|
+
@pytest.mark.parametrize(
|
|
78
|
+
["lon", "lat", "depth", "indexing_scheme"],
|
|
79
|
+
(
|
|
80
|
+
pytest.param(
|
|
81
|
+
np.array([-170.0, 10.0, 30.0, 124.0, 174.0]),
|
|
82
|
+
np.array([-48.0, -30.0, -5.0, 15.0, 30.0]),
|
|
83
|
+
0,
|
|
84
|
+
"ring",
|
|
85
|
+
id="level0-ring",
|
|
86
|
+
),
|
|
87
|
+
pytest.param(
|
|
88
|
+
np.array([-170.0, 10.0, 30.0, 124.0, 174.0]),
|
|
89
|
+
np.array([-48.0, -30.0, -5.0, 15.0, 30.0]),
|
|
90
|
+
0,
|
|
91
|
+
"nested",
|
|
92
|
+
id="level0-nested",
|
|
93
|
+
),
|
|
94
|
+
pytest.param(
|
|
95
|
+
np.array([-70.0, 135.0, 150.0]),
|
|
96
|
+
np.array([-65.0, 0.0, 65.0]),
|
|
97
|
+
4,
|
|
98
|
+
"ring",
|
|
99
|
+
id="level4-ring",
|
|
100
|
+
),
|
|
101
|
+
pytest.param(
|
|
102
|
+
np.array([-70.0, 135.0, 150.0]),
|
|
103
|
+
np.array([-65.0, 0.0, 65.0]),
|
|
104
|
+
4,
|
|
105
|
+
"nested",
|
|
106
|
+
id="level4-nested",
|
|
107
|
+
),
|
|
108
|
+
),
|
|
109
|
+
)
|
|
110
|
+
def test_spherical(self, lon, lat, depth, indexing_scheme):
|
|
111
|
+
if indexing_scheme == "ring":
|
|
112
|
+
param_cds = 2**depth
|
|
113
|
+
hg_lonlat_to_healpix = healpix_geo.ring.lonlat_to_healpix
|
|
114
|
+
cds_lonlat_to_healpix = cdshealpix.ring.lonlat_to_healpix
|
|
115
|
+
else:
|
|
116
|
+
param_cds = depth
|
|
117
|
+
hg_lonlat_to_healpix = healpix_geo.nested.lonlat_to_healpix
|
|
118
|
+
cds_lonlat_to_healpix = cdshealpix.nested.lonlat_to_healpix
|
|
119
|
+
|
|
120
|
+
actual = hg_lonlat_to_healpix(lon, lat, depth, ellipsoid="sphere")
|
|
121
|
+
lon_ = Longitude(lon, unit="degree")
|
|
122
|
+
lat_ = Latitude(lat, unit="degree")
|
|
123
|
+
expected = cds_lonlat_to_healpix(lon_, lat_, param_cds)
|
|
124
|
+
|
|
125
|
+
np.testing.assert_equal(actual, expected)
|
|
126
|
+
|
|
127
|
+
@pytest.mark.parametrize("ellipsoid", ["unitsphere", "sphere", "WGS84", "bessel"])
|
|
128
|
+
@pytest.mark.parametrize("depth", [0, 1, 9])
|
|
129
|
+
@pytest.mark.parametrize("indexing_scheme", ["ring", "nested"])
|
|
130
|
+
def test_ellipsoidal(self, ellipsoid, depth, indexing_scheme):
|
|
131
|
+
lat = np.linspace(-90, 90, 50)
|
|
132
|
+
lon = np.full_like(lat, fill_value=45.0)
|
|
133
|
+
|
|
134
|
+
if indexing_scheme == "ring":
|
|
135
|
+
param_cds = 2**depth
|
|
136
|
+
hg = healpix_geo.ring.lonlat_to_healpix
|
|
137
|
+
cds = cdshealpix.ring.lonlat_to_healpix
|
|
138
|
+
else:
|
|
139
|
+
param_cds = depth
|
|
140
|
+
hg = healpix_geo.nested.lonlat_to_healpix
|
|
141
|
+
cds = cdshealpix.nested.lonlat_to_healpix
|
|
142
|
+
|
|
143
|
+
actual = hg(lon, lat, depth, ellipsoid=ellipsoid)
|
|
144
|
+
|
|
145
|
+
lon_ = Longitude(lon, unit="degree")
|
|
146
|
+
lat_ = Latitude(lat, unit="degree")
|
|
147
|
+
expected = cds(lon_, lat_, param_cds)
|
|
148
|
+
|
|
149
|
+
assert actual.dtype == "uint64"
|
|
150
|
+
assert expected.dtype == "uint64"
|
|
151
|
+
|
|
152
|
+
# TODO: this is currently a smoke check, try more thorough checks
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
class TestVertices:
|
|
156
|
+
@pytest.mark.parametrize(
|
|
157
|
+
["cell_ids", "depth", "indexing_scheme"],
|
|
158
|
+
(
|
|
159
|
+
pytest.param(np.array([0, 4, 5, 7, 9]), 0, "ring", id="level0-ring"),
|
|
160
|
+
pytest.param(np.array([1, 2, 3, 8]), 0, "nested", id="level0-nested"),
|
|
161
|
+
pytest.param(
|
|
162
|
+
np.array([3, 19, 54, 63, 104, 127]), 4, "ring", id="level4-ring"
|
|
163
|
+
),
|
|
164
|
+
pytest.param(
|
|
165
|
+
np.array([22, 89, 134, 154, 190]), 4, "nested", id="level4-nested"
|
|
166
|
+
),
|
|
167
|
+
),
|
|
168
|
+
)
|
|
169
|
+
def test_spherical(self, cell_ids, depth, indexing_scheme):
|
|
170
|
+
if indexing_scheme == "ring":
|
|
171
|
+
param_cds = 2**depth
|
|
172
|
+
hg_vertices = healpix_geo.ring.vertices
|
|
173
|
+
cds_vertices = cdshealpix.ring.vertices
|
|
174
|
+
else:
|
|
175
|
+
param_cds = depth
|
|
176
|
+
hg_vertices = healpix_geo.nested.vertices
|
|
177
|
+
cds_vertices = cdshealpix.nested.vertices
|
|
178
|
+
|
|
179
|
+
actual_lon, actual_lat = hg_vertices(cell_ids, depth, ellipsoid="sphere")
|
|
180
|
+
expected_lon_, expected_lat_ = cds_vertices(cell_ids, param_cds)
|
|
181
|
+
expected_lon = np.asarray(expected_lon_.to("degree"))
|
|
182
|
+
expected_lat = np.asarray(expected_lat_.to("degree"))
|
|
183
|
+
|
|
184
|
+
np.testing.assert_allclose(actual_lon, expected_lon)
|
|
185
|
+
np.testing.assert_allclose(actual_lat, expected_lat)
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: healpix-geo
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.5
|
|
4
4
|
Classifier: Programming Language :: Rust
|
|
5
5
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
6
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
7
7
|
Requires-Dist: numpy
|
|
8
8
|
Requires-Dist: pytest ; extra == 'tests'
|
|
9
|
+
Requires-Dist: sphinx ; extra == 'docs'
|
|
10
|
+
Requires-Dist: pydata-sphinx-theme ; extra == 'docs'
|
|
11
|
+
Requires-Dist: myst-parser ; extra == 'docs'
|
|
12
|
+
Requires-Dist: jupyter-sphinx ; extra == 'docs'
|
|
13
|
+
Requires-Dist: matplotlib ; extra == 'docs'
|
|
14
|
+
Requires-Dist: sphinx-autobuild ; extra == 'docs'
|
|
15
|
+
Requires-Dist: markdown ; extra == 'docs'
|
|
16
|
+
Requires-Dist: tabulate ; extra == 'docs'
|
|
9
17
|
Provides-Extra: tests
|
|
18
|
+
Provides-Extra: docs
|
|
10
19
|
License-File: LICENSE
|
|
11
20
|
License: Apache-2.0
|
|
12
21
|
Requires-Python: >=3.10
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
healpix_geo-0.0.5.dist-info/METADATA,sha256=KuNwbByTsOnRPEjEG3bh_3Nqu3xavZ6T3zaLUVSrLB0,987
|
|
2
|
+
healpix_geo-0.0.5.dist-info/WHEEL,sha256=aYxdtiy9tnaVu6KxJq49enpEHZjjLfaDby2fywljTdU,131
|
|
3
|
+
healpix_geo-0.0.5.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
4
|
+
healpix_geo/__init__.py,sha256=5F9gFVhnatVc8JSUwXCNCwU1S3Cq6AmJiOE41BuXpWc,67
|
|
5
|
+
healpix_geo/healpix_geo.cpython-310-powerpc64le-linux-gnu.so,sha256=wNZkp_IVnGNFipJsUJVJD9H8ERH2wdkMeRfrcrg7CWM,2890600
|
|
6
|
+
healpix_geo/nested.py,sha256=j10mOG6-tYnwA_ITvOFu1MUbe3pOXQdq2MoeRaeAxUY,12613
|
|
7
|
+
healpix_geo/ring.py,sha256=twROKO2DobvBZLPdudAOwXIZEK5Hitb0kYGmdUFFxj0,10315
|
|
8
|
+
healpix_geo/tests/test_distances.py,sha256=2_0sya91zXHNskfgcyVl6baVtQFnAngff71IhzmxKKY,2502
|
|
9
|
+
healpix_geo/tests/test_index.py,sha256=oeIhp-bRgJhyV13-wIGrGWxoxiWctAR6BqcInUOASZg,4725
|
|
10
|
+
healpix_geo/tests/test_inference.py,sha256=OJ06XHO26_ZKD8DUgRB7NjO4u3CsGmY09ixexm0wQDQ,7182
|
|
11
|
+
healpix_geo/tests/test_neighbours.py,sha256=r4P8KE_B4Yp5yXWCUiEHIE0PUqD6PyQqoqHaEHtpsYs,1187
|
|
12
|
+
healpix_geo/tests/test_zoom.py,sha256=lua0ylP7kr_YlB_-H38P4toMXsPR-BgnwxJD-Dvoulk,2263
|
|
13
|
+
healpix_geo/utils.py,sha256=ZBJaXk-asV4ivdWKan65PiEUK3WWYIBuGWARW43rEj8,721
|
|
14
|
+
healpix_geo-0.0.5.dist-info/RECORD,,
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
healpix_geo-0.0.4.dist-info/METADATA,sha256=IpcpPXnLELUyEOoHz_pWk6ctyFBa4qqN5uOUN2f8nCw,602
|
|
2
|
-
healpix_geo-0.0.4.dist-info/WHEEL,sha256=tcpzD1g4ToMnQlfuMXekOJIS6uI85eEpTsulAetklgw,131
|
|
3
|
-
healpix_geo-0.0.4.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
4
|
-
healpix_geo/__init__.py,sha256=5F9gFVhnatVc8JSUwXCNCwU1S3Cq6AmJiOE41BuXpWc,67
|
|
5
|
-
healpix_geo/healpix_geo.cpython-310-powerpc64le-linux-gnu.so,sha256=-5EXdP0q1IT5RFJsHr5u7f7vY7T3bgS-LTTJAPjlRcA,2104776
|
|
6
|
-
healpix_geo/nested.py,sha256=2sh7oP2a2JblgZ0g6j3fdy5qUy_Ox_uNhxFM5fWoEZI,6845
|
|
7
|
-
healpix_geo/ring.py,sha256=4cmopmqpUHdewFjQhetRB10rZrbiY0Ndd_VZBKHGmTk,4568
|
|
8
|
-
healpix_geo/tests/test_distances.py,sha256=2_0sya91zXHNskfgcyVl6baVtQFnAngff71IhzmxKKY,2502
|
|
9
|
-
healpix_geo/tests/test_index.py,sha256=409ulgEgs53EuYNZYJb0aiSmG4e2mtUEMPbJJetUPpQ,4560
|
|
10
|
-
healpix_geo/tests/test_neighbours.py,sha256=r4P8KE_B4Yp5yXWCUiEHIE0PUqD6PyQqoqHaEHtpsYs,1187
|
|
11
|
-
healpix_geo/tests/test_zoom.py,sha256=lua0ylP7kr_YlB_-H38P4toMXsPR-BgnwxJD-Dvoulk,2263
|
|
12
|
-
healpix_geo/utils.py,sha256=ZBJaXk-asV4ivdWKan65PiEUK3WWYIBuGWARW43rEj8,721
|
|
13
|
-
healpix_geo-0.0.4.dist-info/RECORD,,
|
|
File without changes
|