Skip to content

Commit

Permalink
fix issue with subgrid Gaussian kernel pixel size
Browse files Browse the repository at this point in the history
  • Loading branch information
sibirrer committed Jun 11, 2024
1 parent a401fa9 commit 78cda97
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions lenstronomy/Data/psf.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def kernel_point_source(self):
if not hasattr(self, "_kernel_point_source"):
if self.psf_type == "GAUSSIAN":
kernel_num_pix = min(
round(self._truncation * self._fwhm / self._pixel_size), 201
round(self._truncation * self._fwhm / self._pixel_size), 221
)
if kernel_num_pix % 2 == 0:
kernel_num_pix += 1
Expand Down Expand Up @@ -147,20 +147,19 @@ def kernel_point_source_supersampled(self, supersampling_factor, updata_cache=Tr
kernel_point_source_supersampled = self._kernel_point_source_supersampled
else:
if self.psf_type == "GAUSSIAN":
kernel_numPix = (
self._truncation / self._pixel_size * supersampling_factor
kernel_num_pix = int(
round(self._truncation * self._fwhm / self._pixel_size * supersampling_factor)
)
kernel_numPix = int(round(kernel_numPix))
if kernel_numPix > 10000:
if kernel_num_pix > 10000:
raise ValueError(
"The pixelized Gaussian kernel has a grid of %s pixels with a truncation at "
"%s times the sigma of the Gaussian, exceeding the limit allowed."
% (kernel_numPix, self._truncation)
% (kernel_num_pix, self._truncation)
)
if kernel_numPix % 2 == 0:
kernel_numPix += 1
if kernel_num_pix % 2 == 0:
kernel_num_pix += 1
kernel_point_source_supersampled = kernel_util.kernel_gaussian(
kernel_numPix, self._pixel_size / supersampling_factor, self._fwhm
kernel_num_pix, self._pixel_size / supersampling_factor, self._fwhm
)

elif self.psf_type == "PIXEL":
Expand Down

0 comments on commit 78cda97

Please sign in to comment.