示例#1
0
    def testHsmSourceMomentsRound(self):
        for (i, imageid) in enumerate(file_indices):
            source = self.runMeasurement("ext_shapeHSM_HsmSourceMomentsRound",
                                         imageid, x_centroid[i], y_centroid[i],
                                         sky_var[i])
            x = source.get("ext_shapeHSM_HsmSourceMomentsRound_x")
            y = source.get("ext_shapeHSM_HsmSourceMomentsRound_y")
            xx = source.get("ext_shapeHSM_HsmSourceMomentsRound_xx")
            yy = source.get("ext_shapeHSM_HsmSourceMomentsRound_yy")
            xy = source.get("ext_shapeHSM_HsmSourceMomentsRound_xy")
            flux = source.get("ext_shapeHSM_HsmSourceMomentsRound_Flux")

            # Centroids from GalSim use the FITS lower-left corner of 1,1
            offset = self.xy0 + self.offset
            self.assertAlmostEqual(x - offset.getX(),
                                   round_moments_expected[i][4] - 1, 3)
            self.assertAlmostEqual(y - offset.getY(),
                                   round_moments_expected[i][5] - 1, 3)

            expected = afwEll.Quadrupole(
                afwEll.SeparableDistortionDeterminantRadius(
                    round_moments_expected[i][1], round_moments_expected[i][2],
                    round_moments_expected[i][0]))
            self.assertAlmostEqual(xx, expected.getIxx(), SHAPE_DECIMALS)
            self.assertAlmostEqual(xy, expected.getIxy(), SHAPE_DECIMALS)
            self.assertAlmostEqual(yy, expected.getIyy(), SHAPE_DECIMALS)

            self.assertAlmostEqual(flux, round_moments_expected[i][3],
                                   SHAPE_DECIMALS)
示例#2
0
def main(rootDir, visit, ccd, n=5):

    # make a butler and specify your dataId
    butler = dafPersist.Butler(rootDir)
    dataId = {'visit': visit, 'ccd':ccd}

    # the x,y of a galaxy, as if we're computing galaxy-galaxy shear about the object at this coordinate.
    gx, gy = 1000.0, 1000.0
    
    # get the exposure from the butler
    sources = butler.get('src', dataId)

    for s in sources[:n]:

        # get the shape and coords, and get the angle wrt x-axis
        moment = s.getShape()
        x, y   = s.getX(), s.getY()
        dx, dy = x - gx, y - gy
        angle  = -math.atan2(dy, dx)*afwGeom.radians

        # make a rotation transform and apply it to the shape (moment)
        rotation       = afwGeom.LinearTransform.makeRotation(angle)
        moment_rotated = moment.transform(rotation)

        # convert that to a 'Separable' of a specified type of ellipticity and radius
        # --> Ellipticities: Distortion, ReducedShear, ConformalShear
        # --> Radii:         DeterminantRadius, TraceRadius, LogDeterminantRadius, LogTraceRadius
        # Constructors have the form 'Separable<ellipticity><radius>()' ... e.g.
        separable_dd = ellipses.SeparableDistortionDeterminantRadius(moment_rotated)

        # extract the ellipticity from the 'Separable' object
        e_dis = separable_dd.getEllipticity()

        # convert to other ellipticity types if you wish
        e_red = ellipses.ReducedShear(e_dis)
        e_con = ellipses.ConformalShear(e_dis)

        # output all the different types
        # Here +/- E1 are tangential and radial, respectively
        for e in (e_dis, e_red, e_con):
            print "%6.3f %6.3f  " % (e.getE1(), e.getE2()),
        print ""