LSST Applications g0265f82a02+d6b5cd48b5,g02d81e74bb+7bcba2e4e8,g2079a07aa2+14824f138e,g212a7c68fe+4b38ad7149,g2305ad1205+906def1e41,g295015adf3+564da5d084,g2bbee38e9b+d6b5cd48b5,g337abbeb29+d6b5cd48b5,g3ddfee87b4+cff7e20090,g487adcacf7+50712f9db4,g50ff169b8f+5929b3527e,g52b1c1532d+a6fc98d2e7,g591dd9f2cf+d19d1a10d7,g5a732f18d5+66d966b544,g64a986408d+7bcba2e4e8,g858d7b2824+7bcba2e4e8,g8a8a8dda67+a6fc98d2e7,g99cad8db69+808e2eeadf,g9ddcbc5298+d4bad12328,ga1e77700b3+246acaaf9c,ga8c6da7877+9e3c062e8e,gb0e22166c9+3863383f4c,gb6a65358fc+d6b5cd48b5,gb983acf43b+60bb7664b7,gba4ed39666+9664299f35,gbb8dafda3b+6623599aa9,gc07e1c2157+f6e5778202,gc120e1dc64+6e28925a4e,gc28159a63d+d6b5cd48b5,gcf0d15dbbd+cff7e20090,gdaeeff99f8+a38ce5ea23,ge6526c86ff+bcc88f9437,ge79ae78c31+d6b5cd48b5,gee10cc3b42+a6fc98d2e7,gf1cff7945b+7bcba2e4e8,v24.1.5.rc1
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
lsst.meas.base.tests.TransformTestCase Class Reference
Inheritance diagram for lsst.meas.base.tests.TransformTestCase:
lsst.meas.base.tests.CentroidTransformTestCase lsst.meas.base.tests.FluxTransformTestCase

Public Member Functions

 setUp (self)
 
 tearDown (self)
 
 testTransform (self, baseNames=None)
 
 testRegistration (self)
 

Public Attributes

 calexp
 
 inputCat
 
 outputCat
 

Static Public Attributes

str name = "MeasurementTransformTest"
 
 controlClass = None
 
 algorithmClass = None
 
 transformClass = None
 
tuple flagNames = ("flag",)
 
tuple singleFramePlugins = ()
 
tuple forcedPlugins = ()
 

Protected Member Functions

 _populateCatalog (self, baseNames)
 
 _checkOutput (self, baseNames)
 
 _runTransform (self, doExtend=True)
 
 _checkRegisteredTransform (self, registry, name)
 

Protected Attributes

 _runTransform
 

Detailed Description

Base class for testing measurement transformations.

Notes
-----
We test both that the transform itself operates successfully (fluxes are
converted to magnitudes, flags are propagated properly) and that the
transform is registered as the default for the appropriate measurement
algorithms.

In the simple case of one-measurement-per-transformation, the developer
need not directly write any tests themselves: simply customizing the class
variables is all that is required. More complex measurements (e.g.
multiple aperture fluxes) require extra effort.

Definition at line 771 of file tests.py.

Member Function Documentation

◆ _checkOutput()

lsst.meas.base.tests.TransformTestCase._checkOutput ( self,
baseNames )
protected

Definition at line 833 of file tests.py.

833 def _checkOutput(self, baseNames):
834 for inSrc, outSrc in zip(self.inputCat, self.outputCat):
835 for baseName in baseNames:
836 self._compareFieldsInRecords(inSrc, outSrc, baseName)
837 for flagName in self.flagNames:
838 keyName = outSrc.schema.join(baseName, flagName)
839 if keyName in inSrc.schema:
840 self.assertEqual(outSrc.get(keyName), inSrc.get(keyName))
841 else:
842 self.assertFalse(keyName in outSrc.schema)
843

◆ _checkRegisteredTransform()

lsst.meas.base.tests.TransformTestCase._checkRegisteredTransform ( self,
registry,
name )
protected

Definition at line 882 of file tests.py.

882 def _checkRegisteredTransform(self, registry, name):
883 # If this is a Python-based transform, we can compare directly; if
884 # it's wrapped C++, we need to compare the wrapped class.
885 self.assertEqual(registry[name].PluginClass.getTransformClass(), self.transformClass)
886

◆ _populateCatalog()

lsst.meas.base.tests.TransformTestCase._populateCatalog ( self,
baseNames )
protected

Definition at line 823 of file tests.py.

823 def _populateCatalog(self, baseNames):
824 records = []
825 for flagValue in (True, False):
826 records.append(self.inputCat.addNew())
827 for baseName in baseNames:
828 for flagName in self.flagNames:
829 if records[-1].schema.join(baseName, flagName) in records[-1].schema:
830 records[-1].set(records[-1].schema.join(baseName, flagName), flagValue)
831 self._setFieldsInRecords(records, baseName)
832
daf::base::PropertySet * set
Definition fits.cc:931

◆ _runTransform()

lsst.meas.base.tests.TransformTestCase._runTransform ( self,
doExtend = True )
protected

Definition at line 844 of file tests.py.

844 def _runTransform(self, doExtend=True):
845 if doExtend:
846 self.outputCat.extend(self.inputCat, mapper=self.mapper)
847 self.transform(self.inputCat, self.outputCat, self.calexp.getWcs(), self.calexp.getPhotoCalib())
848

◆ setUp()

lsst.meas.base.tests.TransformTestCase.setUp ( self)

Definition at line 811 of file tests.py.

811 def setUp(self):
813 self.calexp = TestDataset.makeEmptyExposure(bbox)
814 self._setupTransform()
815
An integer coordinate rectangle.
Definition Box.h:55

◆ tearDown()

lsst.meas.base.tests.TransformTestCase.tearDown ( self)

Definition at line 816 of file tests.py.

816 def tearDown(self):
817 del self.calexp
818 del self.inputCat
819 del self.mapper
820 del self.transform
821 del self.outputCat
822

◆ testRegistration()

lsst.meas.base.tests.TransformTestCase.testRegistration ( self)
Test that the transformation is appropriately registered.

Definition at line 887 of file tests.py.

887 def testRegistration(self):
888 """Test that the transformation is appropriately registered.
889 """
890 for pluginName in self.singleFramePlugins:
891 self._checkRegisteredTransform(lsst.meas.base.SingleFramePlugin.registry, pluginName)
892 for pluginName in self.forcedPlugins:
893 self._checkRegisteredTransform(lsst.meas.base.ForcedPlugin.registry, pluginName)
894
895

◆ testTransform()

lsst.meas.base.tests.TransformTestCase.testTransform ( self,
baseNames = None )
Test the transformation on a catalog containing random data.

Parameters
----------
baseNames : iterable of `str`
    Iterable of the initial parts of measurement field names.

Notes
-----
We check that:

- An appropriate exception is raised on an attempt to transform
  between catalogs with different numbers of rows;
- Otherwise, all appropriate conversions are properly appled and that
  flags have been propagated.

The ``baseNames`` argument requires some explanation. This should be
an iterable of the leading parts of the field names for each
measurement; that is, everything that appears before ``_instFlux``,
``_flag``, etc. In the simple case of a single measurement per plugin,
this is simply equal to ``self.name`` (thus measurements are stored as
``self.name + "_instFlux"``, etc). More generally, the developer may
specify whatever iterable they require. For example, to handle
multiple apertures, we could have ``(self.name + "_0", self.name +
"_1", ...)``.

Definition at line 849 of file tests.py.

849 def testTransform(self, baseNames=None):
850 """Test the transformation on a catalog containing random data.
851
852 Parameters
853 ----------
854 baseNames : iterable of `str`
855 Iterable of the initial parts of measurement field names.
856
857 Notes
858 -----
859 We check that:
860
861 - An appropriate exception is raised on an attempt to transform
862 between catalogs with different numbers of rows;
863 - Otherwise, all appropriate conversions are properly appled and that
864 flags have been propagated.
865
866 The ``baseNames`` argument requires some explanation. This should be
867 an iterable of the leading parts of the field names for each
868 measurement; that is, everything that appears before ``_instFlux``,
869 ``_flag``, etc. In the simple case of a single measurement per plugin,
870 this is simply equal to ``self.name`` (thus measurements are stored as
871 ``self.name + "_instFlux"``, etc). More generally, the developer may
872 specify whatever iterable they require. For example, to handle
873 multiple apertures, we could have ``(self.name + "_0", self.name +
874 "_1", ...)``.
875 """
876 baseNames = baseNames or [self.name]
877 self._populateCatalog(baseNames)
878 self.assertRaises(lsst.pex.exceptions.LengthError, self._runTransform, False)
879 self._runTransform()
880 self._checkOutput(baseNames)
881
Reports attempts to exceed implementation-defined length limits for some classes.
Definition Runtime.h:76

Member Data Documentation

◆ _runTransform

lsst.meas.base.tests.TransformTestCase._runTransform
protected

Definition at line 878 of file tests.py.

◆ algorithmClass

lsst.meas.base.tests.TransformTestCase.algorithmClass = None
static

Definition at line 798 of file tests.py.

◆ calexp

lsst.meas.base.tests.TransformTestCase.calexp

Definition at line 813 of file tests.py.

◆ controlClass

lsst.meas.base.tests.TransformTestCase.controlClass = None
static

Definition at line 797 of file tests.py.

◆ flagNames

tuple lsst.meas.base.tests.TransformTestCase.flagNames = ("flag",)
static

Definition at line 801 of file tests.py.

◆ forcedPlugins

tuple lsst.meas.base.tests.TransformTestCase.forcedPlugins = ()
static

Definition at line 809 of file tests.py.

◆ inputCat

lsst.meas.base.tests.TransformTestCase.inputCat

Definition at line 834 of file tests.py.

◆ name

str lsst.meas.base.tests.TransformTestCase.name = "MeasurementTransformTest"
static

Definition at line 786 of file tests.py.

◆ outputCat

lsst.meas.base.tests.TransformTestCase.outputCat

Definition at line 834 of file tests.py.

◆ singleFramePlugins

tuple lsst.meas.base.tests.TransformTestCase.singleFramePlugins = ()
static

Definition at line 808 of file tests.py.

◆ transformClass

lsst.meas.base.tests.TransformTestCase.transformClass = None
static

Definition at line 799 of file tests.py.


The documentation for this class was generated from the following file: