Skip to content

Commit

Permalink
Attempt to fix padding issues
Browse files Browse the repository at this point in the history
  • Loading branch information
djreiss committed Aug 9, 2017
1 parent fe07bf8 commit 2708160
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions python/lsst/ip/diffim/zogy.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,10 @@ def selectPsf(psf, exposure):
self.im2_psf = selectPsf(psf2, self.science)

# Make sure PSFs are the same size.
if self.im1_psf.shape[0] < self.im2_psf.shape[0]:
self.im1_psf = np.pad(self.im1_psf, (((self.im2_psf.shape[0] - self.im1_psf.shape[0])//2,
(self.im2_psf.shape[1] - self.im1_psf.shape[1])//2)),
mode='constant', constant_values=0)
elif self.im2_psf.shape[0] < self.im1_psf.shape[0]:
self.im2_psf = np.pad(self.im2_psf, (((self.im1_psf.shape[0] - self.im2_psf.shape[0])//2,
(self.im1_psf.shape[1] - self.im2_psf.shape[1])//2)),
mode='constant', constant_values=0)
if len(self.im1_psf.shape) < len(self.im2_psf.shape):
self.im1_psf = ZogyTask._padPsfToSize(self.im1_psf, self.im2_psf.shape)
elif len(self.im2_psf) < len(self.im1_psf):
self.im2_psf = ZogyTask._padPsfToSize(self.im2_psf, self.im1_psf.shape)

self.sig1 = np.sqrt(self._computeVarianceMean(self.template)) if sig1 is None else sig1
self.sig2 = np.sqrt(self._computeVarianceMean(self.science)) if sig2 is None else sig2
Expand Down Expand Up @@ -891,11 +887,11 @@ def run(self, subExposure, expandedSubExposure, fullBBox, template,
sig1, sig2 = sigmas[0], sigmas[1]

def _makePsfSquare(psf):
# Sometimes CoaddPsf does this. Make it square.
if psf.shape[0] < psf.shape[1]:
# Sometimes CoaddPsf does this. Make it square.
psf = np.pad(psf, ((1, 1), (0, 0)), mode='constant')
psf = ZogyTask._padPsfToSize(psf, (psf.shape[1], psf.shape[1]))
elif psf.shape[0] > psf.shape[1]:
psf = np.pad(psf, ((0, 0), (1, 1)), mode='constant')
psf = ZogyTask._padPsfToSize(psf, (psf.shape[0], psf.shape[0]))
return psf

psf2 = subExp2.getPsf().computeKernelImage(center).getArray()
Expand Down

0 comments on commit 2708160

Please sign in to comment.