Skip to content

bug fix regarding subpixel localization. Added stacking and drizzle#21

Open
RainerHeintzmann wants to merge 10 commits intoJuliaAstro:mainfrom
RainerHeintzmann:main
Open

bug fix regarding subpixel localization. Added stacking and drizzle#21
RainerHeintzmann wants to merge 10 commits intoJuliaAstro:mainfrom
RainerHeintzmann:main

Conversation

@RainerHeintzmann
Copy link

I tried this package on some real data and found out that had serious problems regarding alignment precision. This could be traced back to not using the subpixel locations of the fitting results. This is now fixed.

Since I was looking for a stacking routine, I added code to allow stacking frames. This is either achieved via classical backward interpolation (warp) as before, or via a new forward (nearest-neighbor) interpolation scheme stack_many_drizzle(), which relies on slightly imprecise star tracking such that the field drifts over the pixels effectively supersampling your image. Drizzle does not interpolate. This also allows to remove hot pixel artefacts.

Copy link
Member

@cgarling cgarling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compat suggestions

@cgarling
Copy link
Member

cgarling commented Feb 24, 2026

Thanks for the nice looking PR! I haven't looked substantially at the algorithm code yet but generally I like the idea of this.

I think align_frame probably need to have its docstring changed to be more informative. Assuming the sources are stars, it looks like what happens is that each source essentially gets a unique PSF model fit to it (2D Gaussian by default) and I agree the positions used to compute the triangles should be updated to reflect these improved centroids. The docstring should be more explicit about the role the source model f has in the position calculation as in general there are many alternative ways you could measure source centroids. As an example, centroids via moments tend to be better for sources that are not well-fit by the assumed PSF model, but presumably the FWHM cut should trim out the extended sources that typically contaminate these sort of source lists.

Copy link
Member

@cgarling cgarling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some comments on align_frame

@RainerHeintzmann
Copy link
Author

RainerHeintzmann commented Feb 24, 2026 via email

@cgarling
Copy link
Member

Ah I see. Great to know. Are these the general rules for version larger than 1 or just special to the Language? They don't apply for versions below 1, I guess.

Yeah versions >1.0 have different rules than <1.0. Some guidelines are given here.

@RainerHeintzmann
Copy link
Author

Now there is an example with real measured data (500 Mb to download). Do you want to see, if the script runs fine for you? Under Linux you may be running into issues with View5D, but it should also run without it.

@RainerHeintzmann
Copy link
Author

Thanks for the nice looking PR! I haven't looked substantially at the algorithm code yet but generally I like the idea of this.

I think align_frame probably need to have its docstring changed to be more informative. Assuming the sources are stars, it looks like what happens is that each source essentially gets a unique PSF model fit to it (2D Gaussian by default) and I agree the positions used to compute the triangles should be updated to reflect these improved centroids. The docstring should be more explicit about the role the source model f has in the position calculation as in general there are many alternative ways you could measure source centroids. As an example, centroids via moments tend to be better for sources that are not well-fit by the assumed PSF model, but presumably the FWHM cut should trim out the extended sources that typically contaminate these sort of source lists.

I now added more documentation and examples and revised the parameters. As for the role of f, maybe you can add more detail? It would be nice, if also simple centroiding can be used rather than fitten. But be sure to subtract the local ROI minimum before centroiding!
Both for centroiding as well as fitting. Too sharp stars are probably not good, as this biases the result. But in practice one could also sigmoid-clip the input data to avoid this.

I did now many updates to the PR. Can you have another look at it? Thanks again for the super-quick replay. Do you think this could be something for the 2026 JuliaCon?

P.S.: Somehow your original tests are broken now, but it worked rather well on real stars. I think in the tests there was an abiguity and it aligned the wrong triangle. I started changing that now, but did not really finish it.

@cgarling
Copy link
Member

Thanks for the updates! Yes we can deal with the documentation more later.

Several of the test failures are cases where x==y fails because of small floating point differences but isapprox(x, y) would probably pass. I would like to check your examples / tests before merging. I also have not had a chance to review the stacking implementation, but we can probably can probably merge the PR and check it more closely later. We should review that code before registering a new version, though.

It looks like you allowed edits to this PR by maintainers so I may make a few small changes directly to expedite the review.

Finally, @icweaver should comment on this before merging as he is the primary author of this package. I'm generally in favor of this and we can clean things up further in future work.

@icweaver
Copy link
Member

Hi @RainerHeintzmann, thank you for this really nice PR, and thanks Chris for your in depth review! I'll try to do a pass as well by the end of today so that we can get things merged. I think this is going to be a really nice addition to this package

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants