davidwhogg / LensTractor

finding strong gravitationally lensed quasars in ground-based data
GNU General Public License v2.0
5 stars 4 forks source link

Supercool Nebula-->Lens initialisation #32

Closed aagnello closed 10 years ago

aagnello commented 10 years ago

At the moment we suppose the model is SIS, plus small shear, to initialise the astrometries and have a first guess of the unlensed source flux. This may not be the ideal case for quads or in general high shear//flattening cases. Solution: we have the astrometry (and fluxes) from Nebula, use the lens equation to solve for the source. This is for Phil's infinite spare time.

drphilmarshall commented 10 years ago

I had a go at this, and at least got an initial source position out of it. However, the initial lens model was still no good - perhaps because the Nebula galaxy is not in the right place/orientation. We might have to init the Lens model without the Nebula galaxy to help us...

drphilmarshall commented 10 years ago

PS the new code is in the "supercool" branch.

aagnello commented 10 years ago

:D

aagnello commented 10 years ago

I've coded a new version of spawn_lens, it guesses tE and then solves for the shear to minimize the source-plane chi2. At least it recognizes a quad when it sees it (i.e. the PS1 example), but it places source and galaxy in strange positions and the initialisation is borked. Three improvements to be included: solve for tE as well (although it seems it guesses it well), run it a few times until convergence. I need to re-check the formulae though. Some of it may also be related to ra/dec<-->pixel space, @drphilmarshall could you please have a look?

aagnello commented 10 years ago

I've pushed the new spawn, it's in model.py, I'm still working on the formulae but we must also convert ra,dec into pixel positions (to compute Ax, Ay, sum etc) and just at the end into ra,dec again. @drphilmarshall , would you please manage to do it? It'd take longer to me digging into the Tractor than to you simply writing the two necessary lines of code. We'd like to get to the next strides telecon with results! I'll refine the formulae in the meanwhile.

drphilmarshall commented 10 years ago

I just pushed back code with all angular separations dx, dy etc worked out in arcseconds, including the declination correction dx = (ra - ra0)*cos(dec0). Is this what you mean by "pixel positions"? The model exists on the sky, and is only realised onto image patches to be compared to the data - so the initialisation is in angular offsets, in arcsec (it looks like). The initialisation is not great though - I think you may have a bug somewhere:

​ The relevant stdout is at the bottom of the doc/notes.txt file. Hope this helps!

On Fri, May 23, 2014 at 1:43 PM, Adriano Agnello notifications@github.comwrote:

I've pushed the new spawn, it's in model.py, I'm still working on the formulae but we must also convert ra,dec into pixel positions (to compute Ax, Ay, sum etc) and just at the end into ra,dec again. @drphilmarshallhttps://github.com/drphilmarshall, would you please manage to do it? It'd take longer to me digging into the Tractor than to you simply writing the two necessary lines of code. We'd like to get to the next strides telecon with results! I'll refine the formulae in the meanwhile.

— Reply to this email directly or view it on GitHubhttps://github.com/davidwhogg/LensTractor/issues/32#issuecomment-44058148 .

aagnello commented 10 years ago

Thanks Phil! I blindly re-did the formulae yesterday, I'll check them (and the old ones) after breakfast. I think I'll need to include tE as a function of gamma, i.e. solving recursively for the three of them. I won't take long though. Cheers

aagnello commented 10 years ago

DONE! The new spawn does this: -- evaluate how trustworthy the galaxy position from Nebula is, possibly reposition it with a simple prescription -- solve for best Einstein radius and shear, via source-plane chi2-minimization -- for quads, find corrections to the lens repositioning (via s-p chi2-min) I've used the "manual" option to initialise Nebula4. For both Nebula and Lens, an important ingredient seems to be the initial guess for the fluxes: if they're too high (~2 or 4 times the true values), the Tractor doesn't seem to optimize properly for them, I don't know why. In general, the Tractor optimizer seems to get stuck after the first snapshot. @dstndstn , do you think it may have to do with too coarse step-sizes? Or the number of steps per optimizing round?