Skip to content

Commit 76c5561

Browse files
authored
ENH add keyword for PSF noise (#22)
1 parent 743be9b commit 76c5561

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

montara/eastlake_step.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,17 @@ def update_stash(self, config, stash):
203203
_psf, safe = galsim.config.BuildGSObject({'blah': copy.deepcopy(config["psf"])}, 'blah')
204204
assert safe, "PSF model must be reusable (safe) to use as an InterpolatedImage"
205205
_psf = _psf.withFlux(1.0).drawImage(nx=25, ny=25, scale=0.263)
206+
207+
if config["output"].get("analyze_with_interpimage_psf_s2n", None) is not None:
208+
nse = (
209+
np.sum(_psf.array)
210+
/ config["output"]["analyze_with_interpimage_psf_s2n"]
211+
/ np.sqrt(np.prod(_psf.array.shape))
212+
)
213+
rng = np.random.RandomState(stash["step_primary_seed"])
214+
_psf_arr = _psf.array + rng.normal(scale=nse, size=_psf.array.shape)
215+
_psf = galsim.Image(_psf_arr, scale=_psf.scale)
216+
206217
_psf = galsim.InterpolatedImage(_psf, x_interpolant='lanczos15')
207218
with np.printoptions(threshold=np.inf, precision=32):
208219
_psf = repr(_psf)

0 commit comments

Comments
 (0)