Example #1
0
    def testCopyDetector(self):
        """Test copyDetector() method
        """
        #
        # Make a copy without any modifications
        #
        detector = DetectorWrapper().detector
        ndetector = cameraGeom.copyDetector(detector)

        self.assertEqual(detector.getName(), ndetector.getName())
        self.assertEqual(detector.getBBox(), ndetector.getBBox())
        for amp, namp in zip(detector, ndetector):
            self.assertEqual(amp.getBBox(), namp.getBBox())
            self.assertEqual(amp.getRawXYOffset(), namp.getRawXYOffset())
        #
        # Now make a copy with a hacked-up set of amps
        #
        ampInfoCatalog = detector.getAmpInfoCatalog().copy(deep=True)
        for i, amp in enumerate(ampInfoCatalog, 1):
            amp.setRawXYOffset(i * lsst.geom.ExtentI(1, 1))

        ndetector = cameraGeom.copyDetector(detector,
                                            ampInfoCatalog=ampInfoCatalog)

        self.assertEqual(detector.getName(), ndetector.getName())
        self.assertEqual(detector.getBBox(), ndetector.getBBox())
        for i, (amp, namp) in enumerate(zip(detector, ndetector), 1):
            self.assertEqual(amp.getBBox(), namp.getBBox())
            self.assertNotEqual(amp.getRawXYOffset(), namp.getRawXYOffset())
            self.assertEqual(namp.getRawXYOffset()[0], i)
Example #2
0
    def testCopyDetector(self):
        """Test copyDetector() method
        """
        #
        # Make a copy without any modifications
        #
        detector = DetectorWrapper().detector
        ndetector = cameraGeom.copyDetector(detector)

        self.assertEqual(detector.getName(), ndetector.getName())
        self.assertEqual(detector.getBBox(), ndetector.getBBox())
        self.assertEqual(detector.getPhysicalType(), ndetector.getPhysicalType())
        for amp, namp in zip(detector, ndetector):
            self.assertEqual(amp.getBBox(), namp.getBBox())
            self.assertEqual(amp.getRawXYOffset(), namp.getRawXYOffset())
        #
        # Now make a copy with a hacked-up set of amps
        #
        ampInfoCatalog = detector.getAmpInfoCatalog().copy(deep=True)
        for i, amp in enumerate(ampInfoCatalog, 1):
            amp.setRawXYOffset(i*lsst.geom.ExtentI(1, 1))

        ndetector = cameraGeom.copyDetector(
            detector, ampInfoCatalog=ampInfoCatalog)

        self.assertEqual(detector.getName(), ndetector.getName())
        self.assertEqual(detector.getBBox(), ndetector.getBBox())
        for i, (amp, namp) in enumerate(zip(detector, ndetector), 1):
            self.assertEqual(amp.getBBox(), namp.getBBox())
            self.assertNotEqual(amp.getRawXYOffset(), namp.getRawXYOffset())
            self.assertEqual(namp.getRawXYOffset()[0], i)
Example #3
0
    def std_raw(self, item, dataId):
        """Method for performing any necessary manipulation of the raw files.

        @param[in,out] item afwImage exposure object with associated metadata and detector info
        @param[in] dataId
        """
        md = item.getMetadata()

        # Note that setting these must be done before the call to super below
        md.set('CTYPE1', 'RA---TAN')  # add missing keywords
        md.set('CTYPE2', 'DEC--TAN')  # add missing keywords
        md.set('CRVAL2',
               decStrToDeg(md.get('DEC')))  # translate RA/DEC from header
        md.set('CRVAL1', raStrToDeg(md.get('RA')))
        md.set('CRPIX1', 210.216)  # set reference pixels
        md.set('CRPIX2', 344.751)
        md.set('CD1_1', -0.000111557869436)  # set nominal CD matrix
        md.set('CD1_2', 1.09444409144E-07)
        md.set('CD2_1', 6.26180926869E-09)
        md.set('CD2_2', -0.000111259259893)

        item = super(Ctio0m9Mapper, self).std_raw(item, dataId)
        #
        # We may need to hack up the cameraGeom
        #
        # There doesn't seem to be a way to get the extended register, so I don't update it.
        # We could do this by detecting extra overscan and adjusting things cleverly; probably
        # we need to so so.
        #
        ccd = item.getDetector()
        rawBBoxFromMetadata = bboxFromIraf(md.get("ASEC11"))
        rawBBox = ccd[0].getRawBBox()

        if rawBBoxFromMetadata != rawBBox:
            extraSerialOverscan = rawBBoxFromMetadata.getWidth(
            ) - rawBBox.getWidth()  # extra overscan pixels
            extraParallelOverscan = rawBBoxFromMetadata.getHeight(
            ) - rawBBox.getHeight()  # vertical

            ccd = cameraGeom.copyDetector(
                ccd, ampInfoCatalog=ccd.getAmpInfoCatalog().copy(deep=True))
            item.setDetector(ccd)

            for a in ccd:
                ix, iy = [int(_) for _ in a.getName()]
                irafName = "%d%d" % (iy, ix)
                a.setRawBBox(bboxFromIraf(md.get("ASEC%s" % irafName)))
                a.setRawDataBBox(bboxFromIraf(md.get("TSEC%s" % irafName)))

                if extraSerialOverscan != 0 or extraParallelOverscan != 0:
                    #
                    # the number of overscan pixels has been changed from camera.yaml
                    #
                    # First adjust the overscan
                    #
                    rawHorizontalOverscanBBox = a.getRawHorizontalOverscanBBox(
                    )

                    rawHorizontalOverscanBBox.shift(
                        afwGeom.ExtentI((ix - 1) * extraSerialOverscan,
                                        (iy - 1) * extraParallelOverscan))

                    xy0 = rawHorizontalOverscanBBox.getMin()
                    xy1 = rawHorizontalOverscanBBox.getMax()

                    xy1.shift(
                        afwGeom.ExtentI(extraSerialOverscan,
                                        extraParallelOverscan))

                    a.setRawHorizontalOverscanBBox(afwGeom.BoxI(xy0, xy1))
                    #
                    # And now move the extended register to allow for the extra overscan pixels
                    #
                    rawPrescanBBox = a.getRawPrescanBBox()
                    rawPrescanBBox.shift(
                        afwGeom.ExtentI(2 * (ix - 1) * extraSerialOverscan,
                                        (iy - 1) * extraParallelOverscan))

                    xy0 = rawPrescanBBox.getMin()
                    xy1 = rawPrescanBBox.getMax()

                    xy1.shift(afwGeom.ExtentI(0, extraParallelOverscan))
                    a.setRawPrescanBBox(afwGeom.BoxI(xy0, xy1))

        return item