Skip to content

Commit

Permalink
Add tests for property maps units and descriptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
erykoff committed Oct 3, 2023
1 parent e9ba9fa commit eda6bcf
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/test_makeSurveyPropertyMaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import esutil
import warnings
import logging
from astropy import units

import lsst.utils.tests
import lsst.daf.butler
Expand All @@ -50,6 +51,8 @@
class DistTimesPsfAreaPropertyMap(BasePropertyMap):
"""Property map to compute the distance from the boresight center
by the psf area. Do not try this at home."""
description = "Distance times psf area"
unit = "deg*pixel**2"
requires_psf = True

def _compute(self, row, ra, dec, scalings, psf_array=None):
Expand Down Expand Up @@ -190,26 +193,51 @@ def testPropertyMapCreation(self):
if map_config.do_min:
self.assertTrue(hasattr(property_map, 'min_map'))
np.testing.assert_array_equal(property_map.min_map.valid_pixels, valid_pixels)
metadata = property_map.min_map.metadata
self.assertIsNotNone(metadata["DESCRIPTION"])
self.assertEqual(metadata["OPERATION"], "minimum")
unit = units.Unit(metadata["UNIT"])
self.assertIsNotNone(unit)
else:
self.assertFalse(hasattr(property_map, 'min_map'))
if map_config.do_max:
self.assertTrue(hasattr(property_map, 'max_map'))
np.testing.assert_array_equal(property_map.max_map.valid_pixels, valid_pixels)
metadata = property_map.max_map.metadata
self.assertIsNotNone(metadata["DESCRIPTION"])
self.assertEqual(metadata["OPERATION"], "maximum")
unit = units.Unit(metadata["UNIT"])
self.assertIsNotNone(unit)
else:
self.assertFalse(hasattr(property_map, 'max_map'))
if map_config.do_mean:
self.assertTrue(hasattr(property_map, 'mean_map'))
np.testing.assert_array_equal(property_map.mean_map.valid_pixels, valid_pixels)
metadata = property_map.mean_map.metadata
self.assertIsNotNone(metadata["DESCRIPTION"])
self.assertEqual(metadata["OPERATION"], "mean")
unit = units.Unit(metadata["UNIT"])
self.assertIsNotNone(unit)
else:
self.assertFalse(hasattr(property_map, 'mean_map'))
if map_config.do_weighted_mean:
self.assertTrue(hasattr(property_map, 'weighted_mean_map'))
np.testing.assert_array_equal(property_map.weighted_mean_map.valid_pixels, valid_pixels)
metadata = property_map.weighted_mean_map.metadata
self.assertIsNotNone(metadata["DESCRIPTION"])
self.assertEqual(metadata["OPERATION"], "weighted mean")
unit = units.Unit(metadata["UNIT"])
self.assertIsNotNone(unit)
else:
self.assertFalse(hasattr(property_map, 'weighted_mean_map'))
if map_config.do_sum:
self.assertTrue(hasattr(property_map, 'sum_map'))
np.testing.assert_array_equal(property_map.sum_map.valid_pixels, valid_pixels)
metadata = property_map.sum_map.metadata
self.assertIsNotNone(metadata["DESCRIPTION"])
self.assertEqual(metadata["OPERATION"], "sum")
unit = units.Unit(metadata["UNIT"])
self.assertIsNotNone(unit)
else:
self.assertFalse(hasattr(property_map, 'sum_map'))

Expand Down

0 comments on commit eda6bcf

Please sign in to comment.