Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions tests/test_draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,29 +527,21 @@ def test_drawKImage():
"""Test the various optional parameters to the drawKImage function.
In particular test the parameters image, and scale in various combinations.
"""
if is_jax_galsim():
maxk_threshold = 1.e-3
N = 880
Ns = 28
else:
maxk_threshold = 1.e-4
N = 1174
Ns = 37

# We use a Moffat profile with beta = 1.5, since its real-space profile is
# flux / (2 pi rD^2) * (1 + (r/rD)^2)^3/2
# and the 2-d Fourier transform of that is
# flux * exp(-rD k)
# So this should draw in Fourier space the same image as the Exponential drawn in
# test_drawImage().
obj = galsim.Moffat(flux=test_flux, beta=1.5, scale_radius=0.5)
obj = obj.withGSParams(maxk_threshold=maxk_threshold)
obj = obj.withGSParams(maxk_threshold=1.e-4)

# First test drawKImage() with no kwargs. It should:
# - create new images
# - return the new images
# - set the scale to 2pi/(N*obj.nyquist_scale)
im1 = obj.drawKImage()
N = 1174
np.testing.assert_equal(im1.bounds, galsim.BoundsI(-N/2,N/2,-N/2,N/2),
"obj.drawKImage() produced image with wrong bounds")
stepk = obj.stepk
Expand All @@ -571,7 +563,7 @@ def test_drawKImage():
# - also return that image
# - set the scale to obj.stepk
# - zero out any existing data
im3 = galsim.ImageCD(N-25,N-25)
im3 = galsim.ImageCD(1149,1149)
im4 = obj.drawKImage(im3)
np.testing.assert_almost_equal(im3.scale, stepk, 9,
"obj.drawKImage(im3) produced image with wrong scale")
Expand Down Expand Up @@ -619,7 +611,7 @@ def test_drawKImage():
np.testing.assert_almost_equal(CalculateScale(im7), 2, 1,
"Measured wrong scale after obj.drawKImage(dx)")
# This image is smaller because not using nyquist scale for stepk
np.testing.assert_equal(im7.bounds, galsim.BoundsI(-Ns,Ns,-Ns,Ns),
np.testing.assert_equal(im7.bounds, galsim.BoundsI(-37,37,-37,37),
"obj.drawKImage(dx) produced image with wrong bounds")

# Test if we provide an image with a defined scale. It should:
Expand Down
Loading