Skip to content

Commit

Permalink
Add tests of actual separation in spherical geom in WCS tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rmjarvis committed Nov 22, 2021
1 parent 0dcabea commit fe4cac6
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions tests/test_instcat_parser.py
Original file line number Diff line number Diff line change
@@ -12,6 +12,8 @@
import imsim
from lsst.afw.cameraGeom import DetectorType

from test_batoid_wcs import sphere_dist

def sources_from_list(lines, obs_md, phot_params, file_name):
"""Return a two-item tuple containing
* a list of GalSimCelestialObjects for each object entry in `lines`
@@ -196,12 +198,19 @@ def test_object_extraction_stars(self):

ra_arr = np.array([pos.ra.rad for cat in all_cats.values() for pos in cat.world_pos])
dec_arr = np.array([pos.dec.rad for cat in all_cats.values() for pos in cat.world_pos])
# XXX: These are only within 1.e-4 radians, which is kind of a lot.
# XXX: These are only within 10 arcsec, which is kind of a lot.
# I (MJ) think this is probalby related to differences in convention from how we
# used to do the WCS, so it's probably fine. But someone who knows better might
# want to update how this test is done.
# cf. Issue #262
print("ra diff = ",ra_arr[index]-truth_data['raJ2000'])
print("dec diff = ",dec_arr[index]-truth_data['decJ2000'])
dist = sphere_dist(ra_arr[index], dec_arr[index],
truth_data['raJ2000'], truth_data['decJ2000'])
print("sphere dist = ",dist)
print('max dist = ',np.max(dist))
print('max dist (arcsec) = ',np.max(dist) * 180/np.pi * 3600)
np.testing.assert_array_less(dist * 180/np.pi * 3600, 10.) # largest is 9.97 arcscec.
np.testing.assert_allclose(truth_data['raJ2000'], ra_arr[index], rtol=1.e-4)
np.testing.assert_allclose(truth_data['decJ2000'], dec_arr[index], rtol=1.e-4)

@@ -309,6 +318,7 @@ def test_object_extraction_galaxies(self):
# XXX: There are more differences here. I think mostly because of the WCS mismatch.
# We should probably figure this out to make sure the Batoid WCS isn't missing some
# bit of physics that the LSST WCS included...
# cf. Issue #262
assert len(set(id_arr)^set(truth_data['uniqueId'])) <= 10
index = np.argsort(id_arr)
index1 = np.where(np.in1d(truth_data['uniqueId'], id_arr[index]))
@@ -359,7 +369,15 @@ def test_object_extraction_galaxies(self):

ra_arr = np.array([pos.ra.rad for cat in all_cats.values() for pos in cat.world_pos])
dec_arr = np.array([pos.dec.rad for cat in all_cats.values() for pos in cat.world_pos])
# XXX: Again, only good to ~1.e-4 radians. (!)
# XXX: These are slightly better than the stars actually. But still max out at a few
# arcsec separation differences, which seems like a lot.
# cf. Issue #262
dist = sphere_dist(ra_arr[index2], dec_arr[index2],
truth_data['raJ2000'][index1], truth_data['decJ2000'][index1])
print("sphere dist = ",dist)
print('max dist = ',np.max(dist))
print('max dist (arcsec) = ',np.max(dist) * 180/np.pi * 3600)
np.testing.assert_array_less(dist * 180/np.pi * 3600, 5.) # largest is 3.3 arcsec
np.testing.assert_allclose(truth_data['raJ2000'][index1], ra_arr[index2], rtol=1.e-4)
np.testing.assert_allclose(truth_data['decJ2000'][index1], dec_arr[index2], rtol=1.e-4)

0 comments on commit fe4cac6

Please sign in to comment.