Skip to content

Commit

Permalink
update tests to use new Region interface
Browse files Browse the repository at this point in the history
  • Loading branch information
jchiang87 committed Jan 10, 2025
1 parent 5566a02 commit ff6bbcd
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 24 deletions.
2 changes: 1 addition & 1 deletion skycatalogs/scripts/rotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from skycatalogs.skyCatalogs import open_catalog
from skycatalogs.utils.parquet_schema_utils import make_galaxy_schema
from skycatalogs.utils.creator_utils import make_MW_extinction_av
from skycatalogs.utils.shapes import Disk
from skycatalogs.utils import Disk

DC2_RA = [68, 64, 58,
68.5, 62, 55,
Expand Down
14 changes: 3 additions & 11 deletions tests/test_API.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,8 @@
import os
from pathlib import Path
import numpy as np

# Not currently used
#import pandas as pd


from skycatalogs.skyCatalogs import SkyCatalog, open_catalog
from skycatalogs.skyCatalogs import Box, Disk, PolygonalRegion
from skycatalogs.skyCatalogs import _get_intersecting_hps
from skycatalogs.utils import Box, Disk, PolygonalRegion
from skycatalogs.objects.base_object import BaseObject

class APITester(unittest.TestCase):
Expand Down Expand Up @@ -57,8 +51,7 @@ def testAPI_region(self):
dec_max_small = -35.9

rgn = Box(ra_min_small, ra_max_small, dec_min_small, dec_max_small)

intersect_hps = _get_intersecting_hps('ring', 32, rgn)
intersect_hps = rgn.get_intersecting_hps(32, 'ring')

print("For region ", rgn)
print("intersecting pixels are ", intersect_hps)
Expand Down Expand Up @@ -115,6 +108,7 @@ def testAPI_region(self):
(ra_max_small, dec_max_small),
(ra_max_small, dec_min_small)]
rgn_poly = PolygonalRegion(vertices_radec=vertices)
intersect_hps = rgn_poly.get_intersecting_hps(32, 'ring')
print("For polygonal region ", rgn_poly)
print("intersecting pixels are ", intersect_hps)
assert(set(intersect_hps) == {9683, 9684, 9812})
Expand All @@ -124,8 +118,6 @@ def testAPI_region(self):
obj_type_set=set(['galaxy']) )
t_end = time.time()
print("Time to get box-like polygon objects: ", t_end - t0)


print('Number of collections returned for polygon: ',
object_list.collection_count)
assert(object_list.collection_count == 2)
Expand Down
3 changes: 2 additions & 1 deletion tests/test_gaia_direct.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lsst.daf.butler as daf_butler
from skycatalogs import skyCatalogs
from skycatalogs.objects import GaiaCollection
from skycatalogs.utils import Disk


PACKAGE_DIR = os.path.dirname(os.path.abspath(str(Path(__file__).parent)))
Expand Down Expand Up @@ -44,7 +45,7 @@ def tearDown(self):
def test_proper_motion(self):
ra, dec = 0, 0
radius = 1
region = skyCatalogs.Disk(ra, dec, radius*3600.0)
region = Disk(ra, dec, radius*3600.0)

# make a quadrilateral in case we want to try out
# masking for a polygonal region
Expand Down
3 changes: 2 additions & 1 deletion tests/test_gaia_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lsst.daf.butler as daf_butler
from skycatalogs import skyCatalogs
from skycatalogs.objects import GaiaCollection
from skycatalogs.utils import Disk


PACKAGE_DIR = os.path.dirname(os.path.abspath(str(Path(__file__).parent)))
Expand Down Expand Up @@ -51,7 +52,7 @@ def tearDown(self):
def test_proper_motion(self):
ra, dec = 0, 0
radius = 1
region = skyCatalogs.Disk(ra, dec, radius*3600.0)
region = Disk(ra, dec, radius*3600.0)

# Use start of proper motion epoch, so ra, dec values should
# be unchanged from refcat values.
Expand Down
11 changes: 3 additions & 8 deletions tests/test_schema_1_3_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,11 @@
import os
from pathlib import Path
import numpy as np

# Not currently used
#import pandas as pd


from skycatalogs.skyCatalogs import SkyCatalog, open_catalog
from skycatalogs.skyCatalogs import Box, Disk, PolygonalRegion
from skycatalogs.skyCatalogs import _get_intersecting_hps
from skycatalogs.utils import Box, Disk, PolygonalRegion
from skycatalogs.objects.base_object import BaseObject


class SchemaTester(unittest.TestCase):
'''
Same as test_API but use new-style config, schema version 1.3.0, to
Expand Down Expand Up @@ -62,7 +57,7 @@ def testAPI_region_1_3_0(self):

rgn = Box(ra_min_small, ra_max_small, dec_min_small, dec_max_small)

intersect_hps = _get_intersecting_hps('ring', 32, rgn)
intersect_hps = rgn.get_intersecting_hps(32, 'ring')

print("For region ", rgn)
print("intersecting pixels are ", intersect_hps)
Expand Down
3 changes: 1 addition & 2 deletions tests/test_snana.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import numpy as np

from skycatalogs.skyCatalogs import SkyCatalog, open_catalog
from skycatalogs.skyCatalogs import Box, Disk, PolygonalRegion
from skycatalogs.skyCatalogs import _get_intersecting_hps
from skycatalogs.utils import Box
from skycatalogs.objects.base_object import BaseObject


Expand Down

0 comments on commit ff6bbcd

Please sign in to comment.