Example #1
0
    def test_getAngleBetweenWcs(self):
        ras = [0, 0.1, 1, np.pi / 2, np.pi]
        decs = [0, 1, np.pi / 2]
        rotAngles1 = [0, 0.01, 45, 90, 180, 270, -10]
        epsilon = 0.5
        rotAngles2 = [r + epsilon for r in rotAngles1]
        flips = [True, False]

        nomPosition = lsst.geom.SpherePoint(1.2, 1.1, lsst.geom.radians)
        for ra, dec, rot1, rot2, flip in itertools.product(
                ras, decs, rotAngles1, rotAngles2, flips):
            nomRotation = lsst.geom.Angle(rot2, lsst.geom.degrees)
            nominalWcs = createInitialSkyWcsFromBoresight(nomPosition,
                                                          nomRotation,
                                                          self.detector,
                                                          flipX=flip)

            testPoint = lsst.geom.SpherePoint(ra, dec, lsst.geom.radians)
            testRot = lsst.geom.Angle(rot1, lsst.geom.degrees)
            testWcs = createInitialSkyWcsFromBoresight(testPoint,
                                                       testRot,
                                                       self.detector,
                                                       flipX=flip)

            result = nominalWcs.getRelativeRotationToWcs(testWcs).asDegrees()
            test = (rot2 - rot1) % 360
            self.assertAlmostEqual(result, test, 6)
Example #2
0
    def getDetectorWcs(self, detector):
        """
        Create a WCS for the detector with the initialized
        pointing information.

        Parameters
        ----------
        detector : lsst.afw.cameraGeom.Detector
            Detector for which we want to generate a source catalog.

        Returns
        -------
        lsst.afw.geom.SkyWcs
            Wcs object defining the pixel to sky (and inverse) transform for
            the supplied detector.
        """

        boresightPointing = lsst.geom.SpherePoint(self.boresightRa,
                                                  self.boresightDec,
                                                  lsst.geom.degrees)
        return createInitialSkyWcsFromBoresight(
            boresightPointing,
            self.boresightRotAng * lsst.geom.degrees,
            detector,
            flipX=False,
        )
    def testRunSelection(self):

        refCatList = self._getRefCat()
        camera = self.butler.get(
            "camera",
            dataId={"instrument": "LSSTCam"},
            collections=["LSSTCam/calib/unbounded"],
        )
        detector = camera["R22_S11"]

        self.config.referenceSelector.magLimit.maximum = 17.0
        self.config.referenceSelector.magLimit.fluxField = "g_flux"
        self.config.referenceSelector.doMagLimit = True
        self.config.doDonutSelection = False

        self.task = GenerateDonutCatalogWcsTask(config=self.config,
                                                name="Base Task")
        refObjLoader = self.task.getRefObjLoader(refCatList)
        wcs = createInitialSkyWcsFromBoresight(
            lsst.geom.SpherePoint(0.0, 0.0, lsst.geom.degrees),
            90.0 * lsst.geom.degrees,
            detector,
            flipX=False,
        )
        # If we have a magLimit at 17 we should cut out
        # the one source at 17.5.
        donutCatBrighterThan17 = self.task.runSelection(
            refObjLoader, detector, wcs, "g")
        self.assertEqual(len(donutCatBrighterThan17), 3)

        # If we increase the mag limit to 18 we should
        # get all the sources in the catalog.
        self.config.referenceSelector.magLimit.maximum = 18.0
        self.task = GenerateDonutCatalogWcsTask(config=self.config,
                                                name="Base Task")
        refObjLoader = self.task.getRefObjLoader(refCatList)
        donutCatFull = self.task.runSelection(refObjLoader, detector, wcs, "g")
        self.assertEqual(len(donutCatFull), 4)
Example #4
0
    def setObsMetaData(self, ra, dec, rotSkyPos, centerCcd="R22_S11"):
        """Set up the WCS by specifying the observation meta data.

        Parameters
        ----------
        ra : float
            Pointing ra in degree.
        dec : float
            Pointing decl in degree.
        rotSkyPos : float
            The orientation of the telescope in degrees.
        centerCcd: str, optional
            Center Ccd on the camera (the default is "R22_S11").
        """

        boresightPointing = lsst.geom.SpherePoint(ra, dec, lsst.geom.degrees)
        self.centerCcd = centerCcd
        self.skyWcs = createInitialSkyWcsFromBoresight(
            boresightPointing,
            (self.rotOffset - rotSkyPos) * lsst.geom.degrees,
            self._camera[self.centerCcd],
            flipX=False,
        )
Example #5
0
def ccd_xy_to_radec(x_px=[0],
                    y_px=[0],
                    boresight_ra=0,
                    boresight_dec=0,
                    rotskypos=0,
                    sensorNameList=['R22_S11']):
    # Use the actual elements of SkySim and WcsSol , so
    # it's more transparent  how CCD coordinates get translated into Ra, Deg catalog

    rotSkyPos = rotskypos
    # get all sensors from the LsstCam :
    #camera = obs_lsst.lsstCamMapper.LsstCamMapper().camera
    camera = LsstCam().getCamera()
    #setObsMetaData in bsc/WcsSol.py
    boresightPointing = lsst.geom.SpherePoint(boresight_ra, boresight_dec,
                                              lsst.geom.degrees)
    centerCcd = "R22_S11"
    skyWcs = createInitialSkyWcsFromBoresight(
        boresightPointing,
        (90 - rotSkyPos) * lsst.geom.degrees,
        camera[centerCcd],
        flipX=False,
    )

    # Get the pixel positions in DM team
    # pixelDmX, pixelDmY = self._sourProc.camXY2DmXY(xInpixelInCam, yInPixelInCam)
    # transpose - from DVCS to CCS
    xInPixelInCam = x_px
    yInPixelInCam = y_px
    pixelDmX, pixelDmY = yInPixelInCam, xInPixelInCam

    raList = []
    decList = []
    xPxList = []
    yPxList = []
    centerChip = camera[centerCcd]
    for sensorName in sensorNameList:
        # same sensorName for each pixel in the list
        chipNames = [sensorName for x in range(len(x_px))]
        for chipX, chipY, ccdX, ccdY, chipName in zip(pixelDmX, pixelDmY,
                                                      xInPixelInCam,
                                                      yInPixelInCam,
                                                      chipNames):
            #print(chipX,chipY,chipName, raPt,decPt)
            cameraChip = camera[chipName]
            # Get x,y on specified detector in terms of mm from center of cam
            camXyMm = cameraChip.transform(lsst.geom.Point2D(chipX, chipY),
                                           PIXELS, FOCAL_PLANE)
            # Convert mm to pixels
            camPoint = centerChip.transform(camXyMm, FOCAL_PLANE, PIXELS)

            # Calculate correct ra, dec
            raPt, decPt = skyWcs.pixelToSky(camPoint)

            raList.append(raPt.asDegrees())
            decList.append(decPt.asDegrees())
            xPxList.append(ccdX)
            yPxList.append(ccdY)

    raInDeg, declInDeg = np.array([raList, decList])

    return raInDeg, declInDeg, xPxList, yPxList