Skip to content

Commit

Permalink
Re-add Shift operator manually and correct photon shooting decision.
Browse files Browse the repository at this point in the history
  • Loading branch information
welucas2 committed May 24, 2024
1 parent b1f191a commit bdaadae
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
4 changes: 2 additions & 2 deletions config/imsim-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ stamp:
HA:
type: Degrees
theta: { type: OpsimData, field: HA }
# -
# type: Shift
-
type: Shift
-
type: RubinDiffractionOptics
det_name: $det_name
Expand Down
16 changes: 8 additions & 8 deletions imsim/lsst_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,14 @@ def buildImage(self, config, base, image_num, obj_num, logger):

# Add the Shift photon operator if it isn't already being used.
# Place it before RubinDiffractionOptics if present, otherwise append.
photon_ops = base["stamp"]["photon_ops"]
shift_op = {'type': 'Shift'}
if shift_op not in photon_ops:
rubin_diffraction_optics_index = next((index for (index, d) in enumerate(photon_ops) if d["type"] == "RubinDiffractionOptics" or d["type"] == "RubinOptics"), None)
if rubin_diffraction_optics_index is not None:
photon_ops.insert(rubin_diffraction_optics_index, shift_op)
else:
photon_ops.append(shift_op)
# photon_ops = base["stamp"]["photon_ops"]
# shift_op = {'type': 'Shift'}
# if shift_op not in photon_ops:
# rubin_diffraction_optics_index = next((index for (index, d) in enumerate(photon_ops) if d["type"] == "RubinDiffractionOptics" or d["type"] == "RubinOptics"), None)
# if rubin_diffraction_optics_index is not None:
# photon_ops.insert(rubin_diffraction_optics_index, shift_op)
# else:
# photon_ops.append(shift_op)

if full_image is None:
full_image = create_full_image(config, base)
Expand Down
12 changes: 6 additions & 6 deletions imsim/stamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,12 +470,12 @@ def buildPSF(self, config, base, gsparams, logger):
else:
fft_sb_thresh = 0.

# if self.nominal_flux < 1.e6 or not fft_sb_thresh or self.nominal_flux < fft_sb_thresh:
# self.use_fft = False
# logger.info('Use photon shooting for object %d. '
# 'nominal flux = %.0f, FFT threshold %.0f',
# base.get('obj_num'), self.nominal_flux, fft_sb_thresh)
# return psf
if self.nominal_flux < 1.e6 or not fft_sb_thresh or self.nominal_flux < fft_sb_thresh:
self.use_fft = False
logger.info('Use photon shooting for object %d. '
'nominal flux = %.0f, FFT threshold %.0f',
base.get('obj_num'), self.nominal_flux, fft_sb_thresh)
return psf

dm_detector = None if not hasattr(self, 'det') else self.det
fft_psf, draw_method, self.fft_flux = get_fft_psf_maybe(
Expand Down
6 changes: 4 additions & 2 deletions tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def create_test_config(
"photon_ops": [
{"type": "TimeSampler", "t0": 0.0, "exptime": exptime},
{"type": "PupilAnnulusSampler", "R_outer": 4.18, "R_inner": 2.55},
{"type": "Shift"},
{
**optics_args,
"boresight": boresight,
Expand Down Expand Up @@ -256,5 +257,6 @@ def test_lsst_image_batches_photon_pooling():
testfns = [
v for k, v in vars().items() if k.startswith(args.test_prefix) and callable(v)
]
for testfn in testfns:
testfn()
# for testfn in testfns:
# testfn()
test_lsst_image_individual_objects()

0 comments on commit bdaadae

Please sign in to comment.