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

DRAFT (do not merge): Field Varying PSF #208

Closed
wants to merge 9 commits into from

Conversation

hugobuddel
Copy link
Collaborator

This is a PR to make it easy to see and discuss the code from @joao-aveiro in #193

Preliminary implementation of GridFieldVaryingPSF for convolving FOVs with field-varying PSFs using interpolation. The implementation might look somewhat convoluted, and it does not rely on many existing Numpy and SciPy methods, but this is done purposely to enable Numba compilation and parallelization. Missing:
- Defining the structure of the input PSF grid;
- Reading PSF grid coordinates and perform correct positioning of the PSF;
- Kernel normalization;
- Expand for multiple wavelengths.
Release candidate of PSF effect using a grid of PSFs that are interpolated across the field. Working example, but further testing required. No multiple-wavelength compatibility yet.
- Compatibility with 3.5 lost (uses f-strings). Though these seem to be used in other places, so it probably was lost before.
- Some docstring incomplete, mostly due to obfuscated attributes or missing or not well-defined type hints.
Raising exceptions for pixels out of bounds during numba routines wasn't working, so it was removed and made it compulsory that the coordinates to be computed lie withing the PSF grid.
@hugobuddel hugobuddel marked this pull request as draft May 10, 2023 08:11
Copy link
Collaborator Author

@hugobuddel hugobuddel left a comment

Choose a reason for hiding this comment

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

Looking good! I'm mainly confused about the 1.5 (see inline comment). I'll comment more in #193

Comment on lines 975 to 976
dx=hdr["CDELT1"] * unit_factor_1*1.5,
dy=hdr["CDELT2"] * unit_factor_2*1.5,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why is there a 1.5 here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you for finding this. I had been doing some tests and this was left behind by mistake. That 1.5 factor should be removed.

return self.n,


class GridCoordinates:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is understandable why you added these classes, as I've found it quite annoying to do the calculations by hand.

However, I'm thinking that it might be better to directly use astropy wcs as that is what we will have to do at some point anyway once we start to model the projections better.

Nevertheless, I'm fine with using your implementation for now, as it is more than sufficient for our current goals.

Copy link
Collaborator

@joao-aveiro joao-aveiro May 13, 2023

Choose a reason for hiding this comment

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

I am not very familiar with WCS and more so with the astropy implementation, but I'll take a look when I have the chance. I also believe that my implementation works for now, but if WCS is well suited for this then it would be interesting to use it to avoid more custom code and increase the probability of errors.

def __init__(self, **kwargs):
super().__init__(**kwargs)

self.meta["z_order"] = [262, 662] # [JA] TODO: Is this ok?
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This z_order is probably fine. The hundreds-digit has some semantic meaning (which is not properly documented...) and the other are the order.

@hugobuddel
Copy link
Collaborator Author

FYI, yesterday we merged #276, which corrects the off-by-one error that caused some pain, perhaps especially for PSFs. Getting all the edge cases out was a huge task, hopefully we got them all.

I'm now writing some general PSF tests. E.g. creating a simulation of a single star with an analytical PSF, and then subsequently using that as a numerical PSF in a subsequent simulation. The results are now identical in shape, as expected. Then I'd like to take it from there and create more complex consistency tests, starting with a field varying PSF that does not vary, and see whether that gives an identical shape as well, etc. The idea is that this would provide a testing framework for the different implementations like this one.

@teutoburg teutoburg deleted the branch AstarVienna:dev_master April 18, 2024 09:55
@teutoburg teutoburg closed this Apr 18, 2024
@hugobuddel hugobuddel mentioned this pull request Apr 18, 2024
@hugobuddel
Copy link
Collaborator Author

Replaced with #403 because I still want to continue this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants