@@ -636,8 +636,6 @@ def run(self, fakeCat, image, wcs, photoCalib):
636636
637637 band = image .getFilterLabel ().bandLabel
638638 fakeCat = self ._standardizeColumns (fakeCat , band )
639-
640- fakeCat = self .addPixCoords (fakeCat , image )
641639 fakeCat = self .trimFakeCat (fakeCat , image )
642640
643641 if len (fakeCat ) > 0 :
@@ -948,6 +946,9 @@ def processImagesForInsertion(self, fakeCat, wcs, psf, photoCalib, band, pixelSc
948946
949947 self .log .info ("Processing %d fake images" , len (fakeCat ))
950948
949+ if 'x' not in fakeCat .columns :
950+ fakeCat = self .addPixCoords (fakeCat , wcs = wcs )
951+
951952 for (imFile , sourceType , mag , x , y ) in zip (fakeCat [band + "imFilename" ].array ,
952953 fakeCat ["sourceType" ].array ,
953954 fakeCat ['mag' ].array ,
@@ -994,22 +995,25 @@ def processImagesForInsertion(self, fakeCat, wcs, psf, photoCalib, band, pixelSc
994995
995996 return galImages , starImages
996997
997- def addPixCoords (self , fakeCat , image ):
998+ def addPixCoords (self , fakeCat , image = None , wcs = None ):
998999
9991000 """Add pixel coordinates to the catalog of fakes.
10001001
10011002 Parameters
10021003 ----------
10031004 fakeCat : `pandas.core.frame.DataFrame`
10041005 The catalog of fake sources to be input
1005- image : `lsst.afw.image.exposure.exposure.ExposureF`
1006+ image : `lsst.afw.image.exposure.exposure.ExposureF`, optional
10061007 The image into which the fake sources should be added
1008+ wcs : `lsst.afw.geom.SkyWcs`, optional
1009+ WCS to use to add fake sources
10071010
10081011 Returns
10091012 -------
10101013 fakeCat : `pandas.core.frame.DataFrame`
10111014 """
1012- wcs = image .getWcs ()
1015+ if wcs is None :
1016+ wcs = image .getWcs ()
10131017 ras = fakeCat ['ra' ].values
10141018 decs = fakeCat ['dec' ].values
10151019 xs , ys = wcs .skyToPixelArray (ras , decs )
@@ -1086,6 +1090,9 @@ def mkFakeGalsimGalaxies(self, fakeCat, band, photoCalib, pixelScale, psf, image
10861090
10871091 self .log .info ("Making %d fake galaxy images" , len (fakeCat ))
10881092
1093+ if 'x' not in fakeCat .columns :
1094+ fakeCat = self .addPixCoords (fakeCat , image )
1095+
10891096 for (index , row ) in fakeCat .iterrows ():
10901097 xy = geom .Point2D (row ["x" ], row ["y" ])
10911098
@@ -1159,6 +1166,9 @@ def mkFakeStars(self, fakeCat, band, photoCalib, psf, image):
11591166
11601167 self .log .info ("Making %d fake star images" , len (fakeCat ))
11611168
1169+ if 'x' not in fakeCat .columns :
1170+ fakeCat = self .addPixCoords (fakeCat , image )
1171+
11621172 for (index , row ) in fakeCat .iterrows ():
11631173 xy = geom .Point2D (row ["x" ], row ["y" ])
11641174
0 commit comments