summaryrefslogtreecommitdiff
path: root/stsci/sphere/test/benchmarks.py
diff options
context:
space:
mode:
authorsienkiew <sienkiew@stsci.edu>2014-03-25 10:53:08 -0400
committersienkiew <sienkiew@stsci.edu>2014-03-25 10:53:08 -0400
commit5d00dcb1a0123389d9759698a5c42828e17af9bc (patch)
treeecef07881ea7b6b661ee5f59847b00dafecf3409 /stsci/sphere/test/benchmarks.py
parent64be292044c4428b5908acf5cc2dda6693ed1afb (diff)
downloadstsci.sphere-5d00dcb1a0123389d9759698a5c42828e17af9bc.tar.gz
mod for d2to1 install
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci.sphere/trunk@30670 fe389314-cf27-0410-b35b-8c050e845b92 Former-commit-id: 91667828b7e01b5aae55679093564473a976e8a9
Diffstat (limited to 'stsci/sphere/test/benchmarks.py')
-rw-r--r--stsci/sphere/test/benchmarks.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/stsci/sphere/test/benchmarks.py b/stsci/sphere/test/benchmarks.py
new file mode 100644
index 0000000..91ef8db
--- /dev/null
+++ b/stsci/sphere/test/benchmarks.py
@@ -0,0 +1,39 @@
+import os
+import sys
+import time
+
+import numpy as np
+from sphere import *
+from test_util import *
+from test_shared import resolve_imagename
+
+def point_in_poly_lots():
+ image_name = resolve_imagename(ROOT_DIR,'1904-66_TAN.fits')
+
+ poly1 = SphericalPolygon.from_wcs(image_name, 64, crval=[0, 87])
+ poly2 = SphericalPolygon.from_wcs(image_name, 64, crval=[20, 89])
+ poly3 = SphericalPolygon.from_wcs(image_name, 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()
+