Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spergelets #628

Open
jmeyers314 opened this issue Jan 14, 2015 · 3 comments
Open

Spergelets #628

jmeyers314 opened this issue Jan 14, 2015 · 3 comments
Assignees
Labels
feature request Request for a new feature in GalSim

Comments

@jmeyers314
Copy link
Member

The next step in implementing the series representation of the Spergel profile (see issue #616 and PR #625) is the implementation of the series basis functions (which for now I'm deeming "Spergelets") and some framework for picking the appropriate coefficients for each Spergelet. I've already more or less got the Spergelets drawable on a local branch, but haven't started the rest of the framework yet. Here's my proposal though:

I think it would be nice if the implementation of the Spergel profile via Spergelets shares most of the same API as the directly implemented Spergel profile. For example:

psf = galsim.Moffat(beta=3, fwhm=0.67)

# Direct draw
gal1 = Spergel(nu=0.0, half_light_radius=0.5).shear(g1=0.2, g2=-0.3)
conv1 = galsim.Convolve(gal1, psf)
img1 = conv1.drawImage(nx=32, ny=32, scale=0.2)

# Series draw initiated by `jmax` keyword indicating order of the series expansion
# and `r1` indicating the fiducial radius about which to expand.
gal2 = Spergel(nu=0.0, half_light_radius=0.5, jmax=3, r1=0.4).shear(g1=0.2, g2=-0.3)
conv2 = galsim.Convolve(gal2, psf)
img2 = conv2.drawImage(nx=32, ny=32, scale=0.2)

My current plan to accomplish this, which is pretty close to the plan @mdschneider laid out in #616, is to create a GSObject subclass Series from which SpergelSeries would derive. SpergelSeries would then have methods: getCoeff((radial_index, azimuthal_index)), and getBasisFunc((radial_index, azimuthal_index)), and also override transformation methods like shear, dilate, etc. to implement these by changing the coefficients of the expansion. Similar to ChromaticConvolution, I would also imagine a SeriesConvolution subclass of Series with a drawImage method that does something like:

def SeriesConvolution.drawImage():
    #1) figure out nx, ny, scale
    #2) if not already precomputed, compute outer product of convolutions (at right 
         size/scale) of all series' terms and store for potential reuse (this uses 
         getBasisFunc).  For Spergelets, it's probably also useful to index these 
         convolutions by the fiducial profile size `r1` mentioned above.
    #3) determine outer product of all series' coefficients (uses getCoeff())
    #4) return appropriate linear combination of coefficients and basis functions.

There are at least two potential drawbacks that I can see:

  • The Spergel (2010) expansion does not expand in centroid position. This might not be a problem if the use case is to sample from the likelihood function since under reasonable assumptions the centroid conditional probability can be computed from the autocorrelation of the model image and the observed image as in Miller++13 (LensFit).
  • I can't see a way to avoid specifying an image size and scale. One could create an InterpolatedImage and redraw, I suppose, but that almost certainly destroys the speedup acquired from precomputing convolutions and making everything linear.
@mdschneider
Copy link

This looks like a very good plan.

Here are couple of further questions:

  • Storing the pre-computed basis functions and their convolutions with the PSF might get complicated as the order of the series, jmax, increases. Does this merit consideration of the dictionary or other data structure for storing all this information? Is it possible that looking up saved basis functions could contribute significantly to the computation time of SeriesConvolution.drawImage()?
  • To clarify, I think @jmeyers314 is proposing to assert a fixed centroid in the Spergelets implementation with the understanding that sampling of galaxy model parameters will proceed in two distinct steps: 1) sample from the Spergelet model likelihood, 2) sample galaxy centroid with all other galaxy model parameters fixed using the conditional probability determined from the auto-correlation of the data and model as in Miller et al. (2007) section 3.1.

@rmandelb
Copy link
Member

Just a quick comment on the user interface.

Perhaps I am being overly influenced by our recent discussion about the ChromaticObject interpolation stuff, but an alternative to the user interface that you proposed would be something like

# Direct draw
gal1 = Spergel(nu=0.0, half_light_radius=0.5).shear(g1=0.2, g2=-0.3)
conv1 = galsim.Convolve(gal1, psf)
img1 = conv1.drawImage(nx=32, ny=32, scale=0.2)

# Series draw 
gal1.setupSeries(jmax=3)
conv2 = galsim.Convolve(gal1, psf)
img2 = conv2.drawImage(nx=32, ny=32, scale=0.2)

So the basic idea is that it's the same object, but you're changing how you do the internal calculations and image rendering to use the series approximation.

jmeyers314 added a commit that referenced this issue Jan 19, 2015
jmeyers314 added a commit that referenced this issue Jan 20, 2015
rmandelb added a commit that referenced this issue Jan 20, 2015
rmandelb added a commit that referenced this issue Jan 22, 2015
jmeyers314 added a commit that referenced this issue Jan 27, 2015
jmeyers314 added a commit that referenced this issue Jan 30, 2015
jmeyers314 added a commit that referenced this issue Jan 30, 2015
jmeyers314 added a commit that referenced this issue Feb 16, 2015
Conflicts:
	CHANGELOG.md
jmeyers314 added a commit that referenced this issue Feb 16, 2015
jmeyers314 added a commit that referenced this issue Feb 18, 2015
jmeyers314 added a commit that referenced this issue Feb 18, 2015
jmeyers314 added a commit that referenced this issue Feb 20, 2015
jmeyers314 added a commit that referenced this issue Feb 24, 2015
jmeyers314 added a commit that referenced this issue Feb 24, 2015
rmandelb added a commit that referenced this issue Feb 25, 2015
jmeyers314 added a commit that referenced this issue Feb 25, 2015
jmeyers314 added a commit that referenced this issue Feb 25, 2015
jmeyers314 added a commit that referenced this issue Feb 25, 2015
jmeyers314 added a commit that referenced this issue Feb 26, 2015
jmeyers314 added a commit that referenced this issue Feb 26, 2015
jmeyers314 added a commit that referenced this issue Feb 26, 2015
jmeyers314 added a commit that referenced this issue Feb 26, 2015
jmeyers314 added a commit that referenced this issue Feb 26, 2015
jmeyers314 added a commit that referenced this issue Feb 27, 2015
jmeyers314 added a commit that referenced this issue Mar 3, 2015
jmeyers314 added a commit that referenced this issue Mar 12, 2015
jmeyers314 added a commit that referenced this issue Mar 12, 2015
jmeyers314 added a commit that referenced this issue Mar 12, 2015
jmeyers314 added a commit that referenced this issue Mar 12, 2015
jmeyers314 added a commit that referenced this issue Mar 13, 2015
jmeyers314 added a commit that referenced this issue Mar 13, 2015
jmeyers314 added a commit that referenced this issue Mar 13, 2015
jmeyers314 added a commit that referenced this issue Mar 13, 2015
jmeyers314 added a commit that referenced this issue Mar 17, 2015
jmeyers314 added a commit that referenced this issue Mar 17, 2015
jmeyers314 added a commit that referenced this issue Apr 13, 2015
jmeyers314 added a commit that referenced this issue Jun 17, 2015
jmeyers314 added a commit that referenced this issue Jun 18, 2015
jmeyers314 added a commit that referenced this issue Jun 19, 2015
jmeyers314 added a commit that referenced this issue Jun 21, 2015
jmeyers314 added a commit that referenced this issue Jun 21, 2015
jmeyers314 added a commit that referenced this issue Jun 24, 2015
jmeyers314 added a commit that referenced this issue Jun 24, 2015
jmeyers314 added a commit that referenced this issue Jun 25, 2015
…ction static. Also, created Series.drawImages() method.

(#628)
jmeyers314 added a commit that referenced this issue Jul 6, 2015
jmeyers314 added a commit that referenced this issue Jul 6, 2015
jmeyers314 added a commit that referenced this issue Jul 7, 2015
@rmjarvis rmjarvis added the feature request Request for a new feature in GalSim label Jul 28, 2015
@rmandelb
Copy link
Member

rmandelb commented Jun 8, 2016

@jmeyers314 , what ever happened with this? I know the initial implementation was merged to master, then there was a bunch more work on this, but then it just kind of stopped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Request for a new feature in GalSim
Projects
None yet
Development

No branches or pull requests

4 participants