Open ptbrown1729 opened 1 year ago
hey @ptbrown1729, I'm so sorry this one slipped through the cracks.
I suspect you've long moved on to something that works for you. You're absolutely correct that using even sized arrays wouldn't be a difficult change. that "warning" was largely inherited from some legacy code and I hadn't looked into recently.
was this issue essentially just a suggestion for modification? If so, thanks very much, I appreciate you looking into it and I can incorporate these changes
@tlambert03 - no worries, and yes just a suggestion for modification/improvement. This is an issue that took me a long time to track down, and still seems like unexpected behavior.
Where I use these functions, I wrap them with code to throw an error if oversampling is requested with an even sized grid.
I guess there is a bigger issue with supporting even-sized PSF's at all, which is there is not a natural choice of center location. So the PSF starts to depend on what routine you use for convolving an image with it.
Description
I have a use case where it is helpful to work with even-sized PSF arrays. The documentation in PSFmodels says not to do this, but I thought it might be useful to look into what the problem is. I am expecting the output PSF's to always be symmetric about the center, which is at pixel
(nxy-1)//2
. I find that this is the case except whennxy
is an even number.It looks like part of the issue is in this code
where
xymax_ = ((nx_)*p.sf - 1) / 2;
If, for example
nx_ = 4
andp.sf = 3
then the coordinates would get grouped(-5, -4, -3); (-2, -1, 0); (1, 2, 3); (4, 5, ?)
, and the asymmetry between the 0th and 2nd grouping is clearIt seems like this should work for the even case also if the loop went from
for the even case there should be
p.sf
more coordinate points which are greater than zero versus less than zero.nx_=4
andp.sf = 3
would then get grouped(-4, -3, -2); (-1, 0, 1); (2, 3, 4); (5, 6, 7)
What I Did