Skip to content

Fixes off-by-a-half in FOVs#880

Open
oczoske wants to merge 5 commits intomainfrom
oc/psf_convolution
Open

Fixes off-by-a-half in FOVs#880
oczoske wants to merge 5 commits intomainfrom
oc/psf_convolution

Conversation

@oczoske
Copy link
Copy Markdown
Collaborator

@oczoske oczoske commented Feb 19, 2026

This PR

  • replaces scipy.signal.zoom with interpolation using RegularGridInterpolator and WCS in PSF rescaling
  • makes sure that the rescaled PSF kernel has odd pixel numbers on either side. This is necessary for scipy.signal.convolve with mode='same' to keep the (convolved) source centred in the output.

(The "full" convolution of an array of size nimg with a kernel of size nkern has size nimg+nkern-1. This has the same parity as nimg if nkern is odd.)

Closes #879

@oczoske oczoske self-assigned this Feb 19, 2026
@oczoske oczoske added the bugfix PR resolving one or more bugs (use "Bug" type for issues, not this label) label Feb 19, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 19, 2026

Codecov Report

❌ Patch coverage is 97.05882% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 74.76%. Comparing base (67be391) to head (37a07e2).
⚠️ Report is 38 commits behind head on main.

Files with missing lines Patch % Lines
scopesim/effects/psfs/discrete.py 97.05% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #880      +/-   ##
==========================================
- Coverage   74.83%   74.76%   -0.07%     
==========================================
  Files          69       69              
  Lines        8868     8936      +68     
==========================================
+ Hits         6636     6681      +45     
- Misses       2232     2255      +23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@teutoburg teutoburg moved this to 🏗 In progress in ScopeSim-development Feb 19, 2026
@oczoske oczoske requested a review from teutoburg April 1, 2026 14:12
@oczoske oczoske marked this pull request as ready for review April 1, 2026 14:12
@oczoske oczoske changed the title Fixes off-by-a-half in FOVs; needs cleaning Fixes off-by-a-half in FOVs Apr 1, 2026
@teutoburg teutoburg moved this from 🏗 In progress to 👀 Awaiting Review in ScopeSim-development Apr 1, 2026
Copy link
Copy Markdown
Contributor

@teutoburg teutoburg left a comment

Choose a reason for hiding this comment

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

Two minor comments, otherwise go ahead 👍

Comment on lines +104 to +107
#from astropy.io import fits
#fits.writeto(f"image_{obj.meta['wave_min'].value}.fits", data=image.value, overwrite=True)
#fits.writeto(f"kernel_{obj.meta['wave_min'].value}.fits", kernel, overwrite=True)
#fits.writeto(f"newimage_{obj.meta['wave_min'].value}.fits", new_image, overwrite=True)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this a leftover from debugging? If so, maybe remove before merging.

Suggested change
#from astropy.io import fits
#fits.writeto(f"image_{obj.meta['wave_min'].value}.fits", data=image.value, overwrite=True)
#fits.writeto(f"kernel_{obj.meta['wave_min'].value}.fits", kernel, overwrite=True)
#fits.writeto(f"newimage_{obj.meta['wave_min'].value}.fits", new_image, overwrite=True)



def _cutout_kernel(image, fov_header, kernel_header=None):
logger.info("Going into _cutout_kernel")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
logger.info("Going into _cutout_kernel")
logger.debug("Going into _cutout_kernel")

I don't think this needs to be at info level.

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

Labels

bugfix PR resolving one or more bugs (use "Bug" type for issues, not this label)

Projects

Status: 👀 Awaiting Review

Development

Successfully merging this pull request may close these issues.

Point source convolution with symmetric PSF yields asymmetric image

2 participants