LSSTDESC / imSim

GalSim based Rubin Observatory image simulation package
https://lsstdesc.org/imSim
BSD 3-Clause "New" or "Revised" License
37 stars 15 forks source link

Error running atmospheric/opt PSF with galsim v2.0.7 #163

Closed jchiang87 closed 6 years ago

jchiang87 commented 6 years ago

Running using galsm v2.0.7 in the lsst_sims 2.10.0 shifter image at NERSC, I'm getting this error:

raceback (most recent call last):                                               
  File "/opt/lsst/stack/python/miniconda3-4.5.4/envs/lsst-scipipe-fcd27eb/lib/python3.6/multiprocessing/pool.py", line 119, in worker                             
    result = (True, func(*args, **kwds))                                         
  File "/global/cscratch1/sd/jchiang8/desc/tmp/imSim/python/desc/imsim/ImageSimulator.py", line 292, in __call__                                                  
    gs_interpreter.drawObject(gs_obj)                                            
  File "/global/cscratch1/sd/jchiang8/desc/tmp/sims_GalSimInterface/python/lsst/sims/GalSimInterface/galSimInterpreter.py", line 799, in drawObject               
    centeredObj = self.findAllDetectors(gsObject)                                
  File "/global/cscratch1/sd/jchiang8/desc/tmp/sims_GalSimInterface/python/lsst/sims/GalSimInterface/galSimInterpreter.py", line 191, in findAllDetectors         
    centeredObj = self.createCenteredObject(gsObject)                            
  File "/global/cscratch1/sd/jchiang8/desc/tmp/sims_GalSimInterface/python/lsst/sims/GalSimInterface/galSimInterpreter.py", line 529, in createCenteredObject     
    centeredObj = self.drawPointSource(gsObject, psf=psf)                        
  File "/global/cscratch1/sd/jchiang8/desc/tmp/sims_GalSimInterface/python/lsst/sims/GalSimInterface/galSimInterpreter.py", line 411, in drawPointSource          
    return psf.applyPSF(xPupil=gsObject.xPupilArcsec, yPupil=gsObject.yPupilArcsec)                                                                               
  File "/global/cscratch1/sd/jchiang8/desc/tmp/sims_GalSimInterface/python/lsst/sims/GalSimInterface/galSimPSF.py", line 69, in applyPSF                          
    psf = self._getPSF(xPupil=xPupil, yPupil=yPupil, **kwargs)                   
  File "/global/cscratch1/sd/jchiang8/desc/tmp/imSim/python/desc/imsim/atmPSF.py", line 182, in _getPSF                                                           
    gsparams=gsparams)                                                           
  File "/opt/lsst/stack/stack/miniconda3-4.5.4-fcd27eb/Linux64/galsim/2.0.7.lsst2/lib/python/galsim/phase_psf.py", line 1006, in makePSF                          
    return PhaseScreenPSF(self, lam, **kwargs)                                   
  File "/opt/lsst/stack/stack/miniconda3-4.5.4-fcd27eb/Linux64/galsim/2.0.7.lsst2/lib/python/galsim/phase_psf.py", line 1217, in __init__                         
    self.scale = aper._sky_scale(self.lam, self.scale_unit)                      
  File "/opt/lsst/stack/stack/miniconda3-4.5.4-fcd27eb/Linux64/galsim/2.0.7.lsst2/lib/python/galsim/phase_psf.py", line 688, in _sky_scale                        
    return (lam*1e-9) / self.pupil_plane_size * radians/scale_unit               
  File "/opt/lsst/stack/stack/miniconda3-4.5.4-fcd27eb/Linux64/galsim/2.0.7.lsst2/lib/python/galsim/phase_psf.py", line 271, in pupil_plane_size
    self._illuminated
  File "/opt/lsst/stack/stack/miniconda3-4.5.4-fcd27eb/Linux64/galsim/2.0.7.lsst2/lib/python/galsim/utilities.py", line 1395, in __get__
    value = self.fget(obj)
  File "/opt/lsst/stack/stack/miniconda3-4.5.4-fcd27eb/Linux64/galsim/2.0.7.lsst2/lib/python/galsim/phase_psf.py", line 338, in _illuminated
    self._pupil_plane_scale = self.good_pupil_scale
  File "/opt/lsst/stack/stack/miniconda3-4.5.4-fcd27eb/Linux64/galsim/2.0.7.lsst2/lib/python/galsim/phase_psf.py", line 318, in good_pupil_scale
    gsparams=self.gsparams))
  File "/opt/lsst/stack/stack/miniconda3-4.5.4-fcd27eb/Linux64/galsim/2.0.7.lsst2/lib/python/galsim/phase_psf.py", line 1033, in _getStepK
    return np.sum([layer._getStepK(**kwargs)**(-5./3) for layer in self])**(-3./5)
  File "/opt/lsst/stack/stack/miniconda3-4.5.4-fcd27eb/Linux64/galsim/2.0.7.lsst2/lib/python/galsim/phase_psf.py", line 1033, in <listcomp>
    return np.sum([layer._getStepK(**kwargs)**(-5./3) for layer in self])**(-3./5)
AttributeError: 'OptWF' object has no attribute '_getStepK'
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/global/cscratch1/sd/jchiang8/desc/tmp/imSim/bin/imsim.py", line 87, in <module>
    image_simulator.run(processes=args.processes)
  File "/global/cscratch1/sd/jchiang8/desc/tmp/imSim/python/desc/imsim/ImageSimulator.py", line 233, in run
    res.get()
  File "/opt/lsst/stack/python/miniconda3-4.5.4/envs/lsst-scipipe-fcd27eb/lib/python3.6/multiprocessing/pool.py", line 644, in get
    raise self._value
AttributeError: 'OptWF' object has no attribute '_getStepK'

This is using the u/jchiang/instcat_memory_fix branch of imSim (2bf5c5b0) @jmeyers314 Could you have a look please?

danielsf commented 6 years ago

If you look at commit e56afee683 in GalSim, it looks like what used to be called _stepK() (which OptWF does have), is now called _getStepK().

So... we can probably just rename OptWF._stepK() to OptWF._getStepK() and it will just work...?

jchiang87 commented 6 years ago

Thanks, Scott! I can give it a try.

jchiang87 commented 6 years ago

Yes, that's fixed it. Thanks!

danielsf commented 6 years ago

Object Oriented Programming: "make this thing look like that other thing; that'll probably do it..."

jchiang87 commented 6 years ago

Hey, if it quacks like a duck....it's good enough for python.

rmjarvis commented 6 years ago

Yes. Sorry about that. We probably thought that was a non-public change that didn't need to be advertised. I think the old _stepK function clashed with a different use that was incompatible, so we needed to change it.

cwwalter commented 6 years ago

Is there a PR associated with this one? I can't find it so, is it in one of the others?

jchiang87 commented 6 years ago

There's no specific PR. In the interest of expediency, I folded it into the changes in the u/jchiang/instcat_memory_fix branch. Here are the two relevant commits: 27b82579b 89e28f9

cwwalter commented 6 years ago

Got it thanks.

cwwalter commented 6 years ago

This was fixed as part of the big 2.0i release candidate branch merge. The commits are 27b8257 89e28f9.