Skip to content

Commit

Permalink
Use np.sqrt to preserve numpy type in config SNR calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
rmjarvis committed Jun 6, 2024
1 parent 750af6d commit 733d808
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion galsim/config/extra_psf.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def DrawPSFStamp(psf, config, base, bounds, offset, method, logger):

sn_target = ParseValue(config, 'signal_to_noise', base, float)[0]

sn_meas = math.sqrt( np.sum(im.array**2, dtype=float) / noise_var )
sn_meas = np.sqrt( np.sum(im.array**2, dtype=float) / noise_var )
flux = sn_target / sn_meas
im *= flux

Expand Down
2 changes: 1 addition & 1 deletion galsim/config/stamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ def getSNRScale(self, image, config, base, logger):
# Then a few things cancel and we find that
# S/N = sqrt( sum I(x,y)^2 / var )

sn_meas = math.sqrt( np.sum(image.array**2, dtype=float) / noise_var )
sn_meas = np.sqrt( np.sum(image.array**2, dtype=float) / noise_var )
# Now we rescale the flux to get our desired S/N
scale_factor = sn_target / sn_meas
return scale_factor
Expand Down

0 comments on commit 733d808

Please sign in to comment.