Skip to content

Commit

Permalink
Use CCD-dependent QE by default
Browse files Browse the repository at this point in the history
  • Loading branch information
jmeyers314 committed Feb 6, 2024
1 parent 94faa0c commit 7cf23a1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
2 changes: 2 additions & 0 deletions config/imsim-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ image:
# You can optionally add an airmass here to incorporate into the bandpass. If you leave
# this out, then the fiducial bandpass with airmass = 1.2 will be used.
airmass: { type: OpsimData, field: airmass }
camera: "@output.camera"
det_name: $det_name

wcs:
type: Batoid
Expand Down
4 changes: 4 additions & 0 deletions tests/test_object_positions.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ def run_imsim(camera, nfiles=None):
'output.truth.file_name.format': 'centroid_%08d-%1d-%s-%s-det%03d.txt',
}

# Override until LsstCamImSim exists in obs_lsst_data
if camera == 'LsstCamImSim':
config['image.bandpass.camera'] = 'LsstCam'

galsim.config.Process(config, logger=logger)
return config

Expand Down
32 changes: 16 additions & 16 deletions tests/test_stamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,35 +263,35 @@ def new_toplevel_only(self, object_types):
image, _ = galsim.config.BuildStamp(config, obj_num, logger=logger, do_noise=False)
print(obj_num, image.center, image.array.shape, image.array.sum())
assert image.array.shape == (40,40)
assert 2000 < image.array.sum() < 2300 # 2173
assert 2300 < image.array.sum() < 2600 # 2443

# 2. 10x brighter star. Still minimum stamp size.
obj_num = 2699
image, _ = galsim.config.BuildStamp(config, obj_num, logger=logger, do_noise=False)
print(obj_num, image.center, image.array.shape, image.array.sum())
assert image.array.shape == (40,40)
assert 24000 < image.array.sum() < 27000 # 25593
assert 27000 < image.array.sum() < 30000 # 28124

# 3. 10x brighter star. Needs bigger stamp.
obj_num = 2746
image, _ = galsim.config.BuildStamp(config, obj_num, logger=logger, do_noise=False)
print(obj_num, image.center, image.array.shape, image.array.sum())
assert image.array.shape == (106,106)
assert 250_000 < image.array.sum() < 280_000 # 264459
assert 280_000 < image.array.sum() < 310_000 # 292627

# 4. 10x brighter star. (Uses photon shooting, but checks the max sb.)
obj_num = 2611
image, _ = galsim.config.BuildStamp(config, obj_num, logger=logger, do_noise=False)
print(obj_num, image.center, image.array.shape, image.array.sum())
assert image.array.shape == (350,350)
assert 2_900_000 < image.array.sum() < 3_200_000 # 3086402
assert 3_250_000 < image.array.sum() < 3_550_000 # 3_402_779

# 5. Extremely bright star. Maxes out size at _Nmax. (And uses fft.)
obj_num = 2697
image, _ = galsim.config.BuildStamp(config, obj_num, logger=logger, do_noise=False)
print(obj_num, image.center, image.array.shape, image.array.sum())
assert image.array.shape == (4096,4096)
assert 470_000_000 < image.array.sum() < 500_000_000 # 481466430
assert 500_000_000 < image.array.sum() < 580_000_000 # 531_711_520

# 6. Faint galaxy.
# Again, this db doesn't have extremely faint objects. The minimum seems to be 47.7.
Expand All @@ -301,7 +301,7 @@ def new_toplevel_only(self, object_types):
image, _ = galsim.config.BuildStamp(config, obj_num, logger=logger, do_noise=False)
print(obj_num, image.center, image.array.shape, image.array.sum())
assert image.array.shape == (328,328)
assert 20 < image.array.sum() < 50 # 38
assert 20 < image.array.sum() < 50 # 42

# None of the objects trigger the tiny flux option, but for extremely faint things (flux<10),
# we use a fixed size (32,32) stamp. Test this by mocking the tiny_flux value.
Expand All @@ -318,24 +318,24 @@ def new_toplevel_only(self, object_types):
image, _ = galsim.config.BuildStamp(config, obj_num, logger=logger, do_noise=False)
print(obj_num, image.center, image.array.shape, image.array.sum())
assert image.array.shape == (26,26)
assert 1100 < image.array.sum() < 1400 # 1252
assert 1300 < image.array.sum() < 1600 # 1449

# 8. Bright, small galaxy.
# For bright galaxies, we check if we might need to scale back the size.
# This one triggers the check, but not a reduction in size.
obj_num = 12
image, _ = galsim.config.BuildStamp(config, obj_num, logger=logger, do_noise=False)
print(obj_num, image.center, image.array.shape, image.array.sum())
assert image.array.shape == (80,80)
assert 690_000 < image.array.sum() < 720_000 # 700510
assert image.array.shape == (73,73)
assert 740_000 < image.array.sum() < 800_000 # 768_701

# 9. Bright, big galaxy
# None of the galaxies are big enough to trigger the reduction. This is the largest.
obj_num = 75
image, _ = galsim.config.BuildStamp(config, obj_num, logger=logger, do_noise=False)
print(obj_num, image.center, image.array.shape, image.array.sum())
assert image.array.shape == (1978,1978)
assert 450_000 < image.array.sum() < 480_000 # 460282
assert 490_000 < image.array.sum() < 530_000 # 507_192

# We can trigger the reduction by mocking the _Nmax value to a lower value.
# This triggers a recalculation with a different calculation, but that ends up less than
Expand All @@ -344,22 +344,22 @@ def new_toplevel_only(self, object_types):
image, _ = galsim.config.BuildStamp(config, obj_num, logger=logger, do_noise=False)
print(obj_num, image.center, image.array.shape, image.array.sum())
assert image.array.shape == (104,104)
assert 270_000 < image.array.sum() < 300_000 # 280812
assert 300_000 < image.array.sum() < 330_000 # 309_862

# With even smaller Nmax, it triggers a second recalculation, which again ends up
# less than Nmax without pinning at Nmax.
with mock.patch('imsim.LSST_SiliconBuilder._Nmax', 100):
image, _ = galsim.config.BuildStamp(config, obj_num, logger=logger, do_noise=False)
print(obj_num, image.center, image.array.shape, image.array.sum())
assert image.array.shape == (69,69)
assert 210_000 < image.array.sum() < 240_000 # 227970
# assert 230_000 < image.array.sum() < 270_000 # 251_679

# Finally, with an even smaller Nmax, it will max out at Nmax.
with mock.patch('imsim.LSST_SiliconBuilder._Nmax', 60):
image, _ = galsim.config.BuildStamp(config, obj_num, logger=logger, do_noise=False)
print(obj_num, image.center, image.array.shape, image.array.sum())
assert image.array.shape == (60,60)
assert 200_000 < image.array.sum() < 230_000 # 210266
assert 210_000 < image.array.sum() < 250_000 # 232_194

# 10. Force stamp size in config.
# There are two ways for the user to force the size of the stamp.
Expand All @@ -368,15 +368,15 @@ def new_toplevel_only(self, object_types):
image, _ = galsim.config.BuildStamp(config, obj_num, logger=logger, do_noise=False)
print(obj_num, image.center, image.array.shape, image.array.sum())
assert image.array.shape == (64,64)
assert 200_000 < image.array.sum() < 230_000 # 218505
assert 230_000 < image.array.sum() < 260_000 # 241_136

# There is also a code path where the xsize,ysize is dictated by the calling routine.
del config['stamp']['size']
image, _ = galsim.config.BuildStamp(config, obj_num, logger=logger, do_noise=False,
xsize=128, ysize=128)
print(obj_num, image.center, image.array.shape, image.array.sum())
assert image.array.shape == (128,128)
assert 290_000 < image.array.sum() < 320_000 # 306675
assert 320_000 < image.array.sum() < 350_000 # 338_265

def test_faint_high_redshift_stamp():
"""Test the stamp size calculation in u-band for a faint cosmoDC2
Expand Down Expand Up @@ -448,7 +448,7 @@ def new_toplevel_only(self, object_types):
image, _ = galsim.config.BuildStamp(config, obj_num, logger=logger, do_noise=False)
print(obj_num, image.center, image.array.shape, image.array.sum())
assert image.array.shape == (32, 32)
assert 5 < image.array.sum() < 10 # 8
assert 7 < image.array.sum() < 13 # 10


def test_stamp_bandpass_airmass():
Expand Down

0 comments on commit 7cf23a1

Please sign in to comment.