blob: 9711d7b44db5ff9358747f019a8066f1a587c400 (
plain) (
blame)
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
|
import os
import sys
import time
import numpy as np
from sphere import *
from test_util import *
def point_in_poly_lots():
poly1 = SphericalPolygon.from_wcs(
os.path.join(ROOT_DIR, '1904-66_TAN.fits'), 64, crval=[0, 87])
poly2 = SphericalPolygon.from_wcs(
os.path.join(ROOT_DIR, '1904-66_TAN.fits'), 64, crval=[20, 89])
poly3 = SphericalPolygon.from_wcs(
os.path.join(ROOT_DIR, '1904-66_TAN.fits'), 64, crval=[180, 89])
points = get_point_set(density=25)
count = 0
for point in points:
if poly1.contains_point(point) or poly2.contains_point(point) or \
poly3.contains_point(point):
count += 1
assert count == 5
assert poly1.intersects_poly(poly2)
assert not poly1.intersects_poly(poly3)
assert not poly2.intersects_poly(poly3)
if __name__ == '__main__':
for benchmark in [point_in_poly_lots]:
t = time.time()
sys.stdout.write(benchmark.__name__)
sys.stdout.write('...')
sys.stdout.flush()
benchmark()
sys.stdout.write(' %.03fs\n' % (time.time() - t))
sys.stdout.flush()
|