Skip to content

Commit

Permalink
Add AtmosphericPSF.__eq__
Browse files Browse the repository at this point in the history
  • Loading branch information
jmeyers314 committed Aug 20, 2018
1 parent ec92416 commit 065f478
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
15 changes: 15 additions & 0 deletions python/desc/imsim/atmPSF.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ def __init__(self, rng, wavelength, gsparams=None):
obj = galsim.Airy(lam=wavelength, diam=8.36, obscuration=0.61, gsparams=gsparams)
self.stepk = obj.stepk

def __eq__(self, rhs):
return (isinstance(rhs, OptWF)
and np.array_equal(self.deviations, rhs.deviations)
and self.stepk == rhs.stepk)

def _wavefront_gradient(self, u, v, t, theta):
z = self.oz.cartesian_coeff(theta[0].rad, theta[1].rad)
Z = galsim.OpticalScreen(diam=8.36, obscuration=0.61, aberrations=[0]*4+list(z))
Expand Down Expand Up @@ -82,6 +87,16 @@ def __init__(self, airmass, rawSeeing, band, rng, t0=0.0, exptime=30.0, kcrit=0.
if doOpt:
self.atm.append(OptWF(rng, self.wlen_eff))

def __eq__(self, rhs):
return (isinstance(rhs, AtmosphericPSF)
and self.airmass == rhs.airmass
and self.rawSeeing == rhs.rawSeeing
and self.wlen_eff == rhs.wlen_eff
and self.t0 == rhs.t0
and self.exptime == rhs.exptime
and self.atm == rhs.atm
and self.aper == rhs.aper)

@staticmethod
def _seeing_resid(r0_500, wavelength, L0, target):
"""Residual function to use with `_r0_500` below."""
Expand Down
3 changes: 1 addition & 2 deletions tests/test_psf.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ def are_psfs_equal(psf1, psf2):
if not isinstance(psf1, desc.imsim.atmPSF.AtmosphericPSF):
# Compare cached galsim objects.
return psf1._cached_psf == psf2._cached_psf
# See issue #117 for an explanation of these comparisons:
return (psf1.atm[:-1] == psf2.atm[:-1]) and (psf1.aper == psf2.aper)
return psf1 == psf2


class PsfTestCase(unittest.TestCase):
Expand Down

0 comments on commit 065f478

Please sign in to comment.