Kspace admom - #271
Conversation
The idea is to merge the nice features of pgauss with adaptive moments, so we get a shape for metacal and nice matched aperture colors This is not optimized at all.
numba kernels cache grids use the half-plane symmetry folding single pass rather than separate center moment pass. Use cen update approximation that converges at the fixed point lookups to avoid sin/cos every pass Also refactored into new subdir
Internally they are still padded to square. Apodization still works correctly.
The power spectrum of this field can be used to estimate errors even when the noise is correlated.
This is exactly a sqrt(2) for a round gaussian
Measure weighted moments and apply a modified adaptive step that works for a fixed mixture. Only tested for exp so far, and not optimized. Errors still not corrected Add a star type as well, which is similar to a template fit.
If this damping is repeatedlyh failing then it might look like it converged.
Also keep full e covariance for both mixture and gauss
Also more shared public for a deblender
To be consistent with PGauss
This speed increase means that for the deblender we are dominated by number of iters, which is currently higher for the exp adaptive-like updates
This greatly reduces the number of iterations needed, puts it on par with single gauss adaptive moments. References in the code
There were cases in the deblender where we were going outside the lookup table with chi2 < 0
shape_ok = Tgal > 0 and det2(Sgal) > 0
still need to clean up the exp specific names
It is equivalent, just changed so they don't look different at a quick glance
They are equivalent
this is verified to be byte identical to pre-refactor
also save deweighted moment shapes in all cases.
this is tricky due to the strong anti correlation of the flux split with T. a covariance term needed to be calculated.
The full covariance of the per band fluxes. The off diagonal is generated by the shared family response (the band sum noises are independent across bands) and is what color errors require
Unlike model_sandwich this stays calibrated under model mismatch, where the sandwich under-predicts T errors by ~17 percent and flux errors by ~11 percent for dev truth fit with exp However, it costs a factor of 3 for the gauss fit, so pull it out only when you need it.
Using threadpoolctl to force blas onto one core
the scalar half of prep_epoch, computable without any FFTs: dims, pad phase centers, weights and jacobian factors. Used by prep_epoch itself and by device-prep paths that compute the k arrays elsewhere and only need the epoch scalars on the host (the array entries of the returned epoch are None).
memory is leaking when i raise from within jitted functions. create non-raising version of some numba functions to avoid this. If a fix go in we can remove these
The fit uses all bands at once and structure is common. take this into account in S/N
|
the new numba |
|
@esheldon if you'd like code review here, it'd be very helpful to break this up into smaller PRs. |
|
I hear you and I'll give it a try. But it all flows together, and a lot of it won't work without the other parts. |
|
I will take a quick look later and see if I can find some ways to help break it up. |
|
For sure the |
|
The change to allow normal prePSF moments to use non-square images can also be its own PR. |
|
I'd also break out the Gaussian models from support for the exp/dev/bdf models. |
In extremely rare cases the determinant check was within precision of zero and caused an exception. Put in an explicity tolerance based on products
|
this is the same test failure with too tight a tolerance that failed in PR #272 will wait and merge that in |
beckermr
left a comment
There was a problem hiding this comment.
There is still way too much code here for me to review.
There are a few options:
-
We can break up the code further by separating out each of the models or the models versus the Gaussian into their own PRs
-
I can only look at the tests, which is still a lot, but is more manageable.
-
We can go without code review. I don't like this option, but at the end of the day this is your repo and I won't insist on code review.
I'm happy to work on 1), but my time is limited, and I have not gotten to it yet. It'd be helpful if you can turn on the setting that offers to update PR branches in the repo settings on github.
A small observation from my brief look already. Many of the doc strings are unintelligible (at least to me, but probably others). I get that there is some non-trivial math happening here, but I think they could be better.
K space adaptive moments.
Works across multiple bands/epochs.
Produces prepsfmom like results, as it is inspired by that work.
Can fit gauss, which uses exactly adaptive moments, or exp/dev/bdf which use a trick to make the fixed point method work for the "family" of fixed relative gaussians.
This also includes a fix that was needed along the way, non-square support