-
Notifications
You must be signed in to change notification settings - Fork 0
/
healpix_test.go
116 lines (107 loc) · 3.04 KB
/
healpix_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package healpix
import (
"testing"
)
func TestHealpixOrderNSide(t *testing.T) {
testCases := []struct {
name string
order int
nside int
}{
{"0 order = 1 nside", 0, 1},
{"1 order = 2 nside", 1, 2},
{"2 order = 4 nside", 2, 4},
{"3 order = 8 nside", 3, 8},
{"4 order = 16 nside", 4, 16},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
hpo := NewHealpixOrder(tc.order)
hpn := NewHealpixSide(tc.nside)
if hpo.Order() != hpn.Order() {
t.Errorf("Side config expected order %v, got %v instead", hpo.Order(), hpn.Order())
}
if hpn.FaceSidePixels() != hpo.FaceSidePixels() {
t.Errorf("Order config expected side pixels %v, got %v instead", hpn.FaceSidePixels(), hpo.FaceSidePixels())
}
})
}
}
func TestHealpixPixels(t *testing.T) {
testCases := []struct {
name string
order int
nside int
pixels int
}{
{"0 order = 1 nside = 12 pixels", 0, 1, 12},
{"1 order = 2 nside = 48 pixels", 1, 2, 48},
{"2 order = 4 nside = 192 pixels", 2, 4, 192},
{"3 order = 8 nside = 768 pixels", 3, 8, 768},
{"4 order = 16 nside = 3072 pixels", 4, 16, 3072},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
hpo := NewHealpixOrder(tc.order)
hpn := NewHealpixSide(tc.nside)
if hpo.Pixels() != tc.pixels {
t.Errorf("Order config expected pixels %v, got %v instead", tc.pixels, hpo.Pixels())
}
if hpn.Pixels() != tc.pixels {
t.Errorf("Side config expected pixels %v, got %v instead", tc.pixels, hpn.Pixels())
}
})
}
}
func TestHealpixRings(t *testing.T) {
testCases := []struct {
name string
order int
nside int
rings int
}{
{"0 order = 1 nside = 3 rings", 0, 1, 3},
{"1 order = 2 nside = 7 rings", 1, 2, 7},
{"2 order = 4 nside = 15 rings", 2, 4, 15},
{"3 order = 8 nside = 31 rings", 3, 8, 31},
{"4 order = 16 nside = 63 rings", 4, 16, 63},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
hpo := NewHealpixOrder(tc.order)
hpn := NewHealpixSide(tc.nside)
if hpo.Rings() != tc.rings {
t.Errorf("Order config expected rings %v, got %v instead", tc.rings, hpo.Rings())
}
if hpn.Rings() != tc.rings {
t.Errorf("Side config expected rings %v, got %v instead", tc.rings, hpn.Rings())
}
})
}
}
func TestHealpixPolarRegionPixels(t *testing.T) {
testCases := []struct {
name string
order int
nside int
polar int
}{
{"0 order = 1 nside = 0 polar", 0, 1, 0},
{"1 order = 2 nside = 4 polar", 1, 2, 4},
{"2 order = 4 nside = 24 polar", 2, 4, 24},
{"3 order = 8 nside = 112 polar", 3, 8, 112},
{"4 order = 16 nside = 480 polar", 4, 16, 480},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
hpo := NewHealpixOrder(tc.order)
hpn := NewHealpixSide(tc.nside)
if hpo.PolarRegionPixels() != tc.polar {
t.Errorf("Order config expected polar pixels %v, got %v instead", tc.polar, hpo.PolarRegionPixels())
}
if hpn.PolarRegionPixels() != tc.polar {
t.Errorf("Side config expected polar pixels %v, got %v instead", tc.polar, hpn.PolarRegionPixels())
}
})
}
}