Skip to content

Rubin deep coadd simulation code - #521

Merged
jchiang87 merged 30 commits into
mainfrom
u/jchiang/rubin_deep_coadd
Oct 17, 2026
Merged

jchiang87 merged 30 commits into
mainfrom
u/jchiang/rubin_deep_coadd

Conversation

@jchiang87

Copy link
Copy Markdown
Collaborator

No description provided.

jchiang87 and others added 23 commits September 8, 2026 14:29
…nsider band-dependence in the internal caches; fix pixel cell center calculation
@rmjarvis

Copy link
Copy Markdown
Contributor

Is this ready for review? You still have it marked as draft.

@jchiang87

Copy link
Copy Markdown
Collaborator Author

I was planning to remove the fft stuff before marking it ready, but everything else is ready to be looked at and I expect there will be some iteration anyway, so I'll mark it ready for you to have a look.

@jchiang87
jchiang87 marked this pull request as ready for review September 25, 2026 14:53
@jchiang87
jchiang87 requested a review from rmjarvis September 25, 2026 14:54

@rmjarvis rmjarvis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good Jim. Just a few comments and questions.

params, safe = galsim.config.GetAllParams(config, base, req=req)
deep_coadds = galsim.config.GetInputObj('deep_coadds', config, base,
'RubinDeepCoaddBandpass')
return deep_coadds.getBandpass(params['band']), safe

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a special deep_coadds version? This looks like it's just the normal LSST bandpass we normally use. Am I missing something here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This retrieves the "standard passband" from the butler, which is a calibration product. See the butler code here. This was mentioned in a slack thread. The one we've been using for the visit level sims can also have per-detector throughputs included, which we wouldn't use for the coadds.

Comment thread imsim/deep_coadd_image.py Outdated
"""
if 'noise' not in base['image']:
base['image']['noise'] = { "type": "Gaussian",
"sigma": self.noise_level }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this bit? I think it would be safer to just make the user include this in the config if they want gaussian noise.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The object rendering needed to have a noise level in order to have reasonable stamp sizes. I actually wasn't sure if this was the right thing to do, but it seemed to make sense to have a noise level that was informed by the original image. I'm open to alternative ways of handling this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be ok to raise an exception if the noise is missing. Could even have a custom noise type that is just CoaddGaussianNoise or something that would do this, which we could recommend in the error message.

But I think automatically adding this if it's missing is too much magic sauce. Better to be explicit IMO.

Comment thread imsim/deep_coadd_image.py Outdated
base['image']['noise'] = { "type": "Gaussian",
"sigma": self.noise_level }
if self.add_noise:
AddNoise(base, image, current_var, logger)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I think if we're doing this here, then we don't need the self.add_noise attribute. That is only used in the regular LSST_ImageBuilderBase class because FullFocalPlane doesn't add the noise for the second pass of a 2-pass image generation.

Comment thread imsim/deep_coadd_psf.py Outdated
image_pos = base['image_pos']
celestial_coord = base['wcs'].toWorld(image_pos)
ra = celestial_coord.ra / galsim.degrees
dec = celestial_coord.dec / galsim.degrees

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend leaving these as the celestial_coord and make that the argument to getPSF. The whole point is to avoid implicit definitions of angles being in degrees at various places in the code. Only when finally something requires degrees or radians, convert there.

Comment thread imsim/deep_coadd_stamp.py Outdated
xsize = ysize = 32
else:
# Determine the stamp size from the object flux.
noise_var = deep_coadds.getNoiseVar(ra, dec, band) / 3.0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This / 3.0 probably deserves an explanation.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is something else I was a bit unsure about. If I just use the noise from the image, some stamp boundaries are apparent in some galaxy renderings, especially ones that are long and thin. This factor mitigated the problem for the test image I've been using, but I don't know that it would work in general. I'm open to suggestions.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable itself (named noise_var) should probably not take the /3, since that feels like lying to ourselves. :) But we could document when we use it that we make stamps large enough that the profile at the edge drops to 1/3 the noise level to avoid apparent edges.

Comment thread imsim/deep_coadd_stamp.py Outdated
# Probably a little better to put them a bit later than the
# start in some cases (e.g. after TimeSampler,
# PupilAnnulusSampler), but leave that as a todo for now.
photon_ops = psfs + photon_ops

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe all this psf as photon_op handling is currently done correctly in GalSim itself. I think this goes back to when this was all new and we didn't have all that implemented correctly. It's probably ok, but I think it likely makes our code more fragile than it needs to be. If we can skip that and just let GalSim do it, that would be better. (Same with where we do this in the regular LSST_Image class.)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would the fix be just to omit this line?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also to draw the original profile, rather than split out the psfs. So skip the line where we make gal, *psfs from the original profile, and just use prof where we currently use gal. I think that should all just work, but definitely should test it to make sure I'm not missing something.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Mike, I think I've addressed all of your comments. Please have a look when you get a chance.

@jchiang87
jchiang87 requested a review from rmjarvis October 16, 2026 22:57

@rmjarvis rmjarvis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jchiang87
jchiang87 merged commit ab9ab14 into main Oct 17, 2026
2 of 4 checks passed
@jchiang87
jchiang87 deleted the u/jchiang/rubin_deep_coadd branch October 17, 2026 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants