Skip to content

Commit

Permalink
fixed central points being floor instead of round
Browse files Browse the repository at this point in the history
  • Loading branch information
york-stsci committed Oct 4, 2021
1 parent 5251ca1 commit 3a0209e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions stips/astro_image/astro_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def initFromPoints(cls, xs, ys, rates, **kwargs):
if img.ysize < np.ceil(np.max(ys)) + 1:
img.ysize = np.ceil(np.max(ys)) + 1
ids = np.arange(len(xs))
img.addPoints(ids, xs, ys, rates)
img.addPoints(ids, xs, ys, xs, ys, rates)
return img

@classmethod
Expand Down Expand Up @@ -764,7 +764,7 @@ def galsimSersic(id, gal_params, psf_params, xsize, ysize, dir, overrides, logge
The flux at the central pixel of the model
"""
fname = 'sersic_{}.npy'.format(id)
ix, iy = int(np.floor(gal_params['x'])), int(np.floor(gal_params['y']))
ix, iy = int(round(gal_params['x'])), int(round(gal_params['y']))
if gal_params['flux'] == 0.:
result = np.zeros((ysize, xsize), dtype=np.float32)
with open(os.path.join(dir, fname), 'wb') as f:
Expand Down Expand Up @@ -874,7 +874,7 @@ def astropySersic(id, gal_params, psf_params, xsize, ysize, dir, overrides, logg
Parameters and return values are the same as galsimSersic
"""
fname = 'sersic_{}.npy'.format(id)
ix, iy = int(np.floor(gal_params['x'])), int(np.floor(gal_params['y']))
ix, iy = int(round(gal_params['x'])), int(round(gal_params['y']))
if gal_params['flux'] == 0.:
result = np.zeros((ysize, xsize), dtype=np.float32)
with open(os.path.join(dir, fname), 'wb') as f:
Expand Down Expand Up @@ -993,7 +993,7 @@ def pandeiaSersic(id, gal_params, psf_params, xsize, ysize, dir, overrides, logg
# print("Creating galaxy {} ({})".format(id, time.ctime()))

fname = 'sersic_{}.npy'.format(id)
ix, iy = int(np.floor(gal_params['x'])), int(np.floor(gal_params['y']))
ix, iy = int(round(gal_params['x'])), int(round(gal_params['y']))
if gal_params['flux'] == 0.:
result = np.zeros((ysize, xsize), dtype=np.float32)
with open(os.path.join(dir, fname), 'wb') as f:
Expand Down Expand Up @@ -1989,6 +1989,7 @@ def _remap(self, xs, ys):
"""
# Step 1 -- compensate for PSF adjustments
adj = ((self.shape - self.base_shape)/2).astype(np.int32)
self._log("debug", "Mapping offset is {}".format(adj))
out_y = (ys - adj[0])
out_x = (xs - adj[1])
return out_x, out_y
Expand Down
2 changes: 1 addition & 1 deletion stips/utilities/PSFGrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def get_reduced_psf(self, psf_ext, flux, cx, cy, id=0):
SaveArrayToFits(fname, psf_img, self.overrides)
self.logger.debug("PSF Image {} at ({},{})".format(psf_ext, cx, cy))
self.logger.debug("\tSize {}".format(psf_img.shape))
self.logger.debug("\tPSF Evaluated over [{}:{},{}:{}]".format(ly, hy, lx, hx))
self.logger.debug("\tPSF Evaluated over [{}:{},{}:{}] (PSF)".format(ly, hy, lx, hx))
max_flux = np.unravel_index(psf_img.argmax(), psf_img.shape)
self.logger.debug("\tMaximum flux is {} at {}".format(np.max(psf_img), max_flux))
self.logger.debug("\tTotal flux is {}".format(np.sum(psf_img)))
Expand Down

0 comments on commit 3a0209e

Please sign in to comment.