Repository navigation
Conversation
|
@darafferty, I lack the domain knowledge to judge if this PR is eligible for merging. Can you review this one, please? |
|
@AlexKurek, the current branch has conflicts. Please have a look. |
darafferty
left a comment
There was a problem hiding this comment.
I think the fixes are correct (although I did not write the original code and am not an expert on it either). Nice to see the comparison of the old and new fits, though I think many of the sources shown there are not really extended so perhaps not very useful... But I do see in my tests that a number of complex sources are better fit with the fixes, which gives me confidence they are correct.
There was a problem hiding this comment.
I let Claude have a look at this PR, because both David and I don't feel comfortable enough to give it a thorough review. Feel free to provide feedback.
Thanks for this — the variance-based derivation is sound: the a-trous kernel at scale k is the base kernel dilated by 2^(k-1), so cumulative variance is var · (4^j − 1)/3, which matches atrous(). The resulting wavelet beam is roughly 2.5–3× smaller than the old formula, so this is a substantial behaviour change. A few points:
1. Reference outputs not updated (blocking)
The branch predates #576 and does not regenerate test/reference_outputs/wavelet. Since tbdsf_process_image.py compares wavelet images (check_images=True), and the new beam changes rms_box_bright (rmsimage.py:189), initial fit guesses (gausfit.py:357) and flagging limits, the regression test should fail once merged with master. Please rebase and regenerate the references.
2. Beam models c_j, but the fitted plane is w_j = c_{j−1} − c_j (wavelet_atrous.py:166)
filter_var_total is the variance of the smoothed image c_j. With the default atrous_sum=False, the fitted image is the band-pass difference c_{j−1} − c_j, whose sources are narrower than that. So the assumed beam is systematically too large there; only atrous_sum=True matches the derivation. Could you either document this as a deliberate approximation or use something in between (e.g. geometric mean of the c_{j−1} and c_j variances)?
3. Non-square pixels (wavelet_atrous.py:168)
An isotropic pixel-space variance is added to the beam's major/minor sigmas, which beam2pix converted with cdelt1/cdelt2 respectively. If |cdelt1| ≠ |cdelt2| and the beam is rotated, the kernel's sky-frame variance along the beam axes depends on bpa, so the result is not the true convolved beam. Probably minor in practice, but worth a comment.
4. Position angle changed from 0° to original bpa (wavelet_atrous.py:172)
Previously the wavelet beam PA was hard-coded to 0.0; now the original PA is propagated. Arguably more correct, but it changes fit results — worth mentioning in the PR description / changelog.
5. wimg.pixel_beam() still returns the unsmoothed beam (wavelet_atrous.py:179)
wimg.pixel_beam / pixel_beamarea stay bound to the original image's closures, so consumers using pixel_beam() — rmsimage.py:277 (min_size_allowed), gausfit.py:1149 (default ini guess for j ≤ 3), gaul2srl.py:337 — don't see the corrected beam. This is pre-existing (and partly intentional per the comment in gausfit.py:354), but it means the fix only partially takes effect.
Minor / cleanup
wavelet_atrous.py:75:filter_varis recomputed from the vector and normalised byN.sum(filter_vec), which is always 1. Storing'var': 0.5/'var': 1.0in thefilterdict next tosize/vecwould be simpler and self-documenting.wavelet_atrous.py:73/y1(~line 140):rms_boxsizing still uses the old filter-width heuristicl + (l−1)(2^(j−1)−1), now inconsistent with the variance-based beam. Also,float( N.sum(...has a stray space.
|
I think of these, the following are important, so applied them in 514b9e2. Also updated the references. 2 Second form "Minor / cleanup" |
Replace the previous filter-width approximation with a calculation based on the actual filter variance and cumulative smoothing across scales. The effective beam is calculated in pixel coordinates and converted back using
img.pix2beam(), preserving the original PA.Test:
python test_atrous_effective_beam.py --bmaj-pix 4 --bmin-pix 4 --pa-deg 0test_atrous_effective_beam.py
30 largest sources before and after. I think its graphically little different but not conclusive. But still - algorithmically better.
comapr_wavelets_newParams__PR550.pdf