On Mar 18, 2013, at 9:58 AM, Mike Jarvis <notifications@github.com> wrote:

> In galsim/lensing.py:
> 
> >              else:
> >                  g1.append(sbii_g1.xValue(pos+self.offset))
> >                  g2.append(sbii_g2.xValue(pos+self.offset))
> > +                if get_kappa:
> > +                    kappa.append(sbii_kappa.xValue(pos+self.offset))
> > +                else:
> > +                    kappa.append(0.)
> so essentially they are getting the shear twice. That means they are doing 5 interpolations instead of 3.
> 
> I think this amounts to premature optimization. These functions don't take any significant amount of time compared to the subsequent draw routine that applies the shear and magnification to a whole lot of pixel locations (either in real or fourier space).
> 
> That said, I'm fine with a combined routine that would return both reduced shear and magnification. Maybe getLensing, which would return something that can be directly sent to applyLensing:
> 
> obj.applyLensing(ps.getLensing(pos))
> And that function could use the utility function you proposed, which would also then be available to users if they wanted it.
> 
Cool. Sounds like we're converging.  I might not get to all this until after my lecture tomorrow (which I am completely unprepared for, sigh) so that will give others a chance to comment.

To summarize my current understanding of this restructuring:
* the current buildGriddedShears will become buildGrid, and will by default get grids for shear, kappa.  (this will mean changing a bunch of places in the python scripts that get g1, g2 out of buildGriddedShears, but that's okay)

* getShear() will only get shears gamma1, gamma2 -> and I do think if we're distinguishing now between shear and reduced shear, we should change all the g1, g2 to gamma1, gamma2 since people usually use g for reduced shear.  Do you agree?

* getConvergence() will get convergence kappa

* new methods called getReducedShear() and getMagnification() will separately get the observable quantities, reduced shear and magnification

* getLensing() will call getShear() and getConvergence() to get gamma1, gamma2, and kappa, then use a new utility function to return reduced shear and magnification.  This new utility will be something like theoryToObserved(), for converting the gammas and kappas to numbers that get applied to the data.

* Users who want to apply buildGrid outputs directly to galaxies (without calls to getShear() etc.) can then apply theoryToObserved() to the outputs of buildGrid.

* functions like NFWHalo.getMag() will be renamed to getMagnification, for clarity.

* there will be new GSObject methods called applyLensing() and createLensed() that apply reduced shear and magnification.  At least, the dox will say they are for reduced shear and magnification, though if someone wants to apply gamma1 and gamma2 directly then that's up to them.

* I will make sure this is all working out sanely in config.

BTW, I'm not ignoring your other comments on this PR that I've so far failed to respond to, I just have to think about them more.