GalSim-developers / GalSim

The modular galaxy image simulation toolkit. Documentation:
http://galsim-developers.github.io/GalSim/
Other
223 stars 105 forks source link

Additional functionality for interpolated chromatic images #1294

Closed FedericoBerlfein closed 2 months ago

FedericoBerlfein commented 3 months ago

Currently Galsim is not able to produce chromatic images directly from images, which could be a useful added feature. Specifically, the motivation behind this added implementation is for work on Euclid-like image simulations, where we will have the PSF information given as oversampled PSF images at specific wavelengths. Therefore the current Galsim methods for generating a chromatic PSF do not support this as an input, which is why we seek ideas/feedback on the best way to implement this.

To be more clear, currently chromatic objects in Galsim are generated from instantiating a ChromaticObject and then optionally using the interpolate method to draw images at set wavelengths to produce an InterpolatedChromaticObject that linearly interpolates those stored images for later calculations. However, there is no way to directly instantiate a InterpolatedChromaticObject from a list of images at specific wavelengths. This seems to be a straightforward extension, however, there are multiple ways to implement such a functionality if this is a desired addition to Galsim.

  1. The first one would be to modify the already created InterpolatedChromaticObject class to allow instantiation directly from a list of images, rather than instantiate it exclusively from a ChromaticObject.
  2. Another avenue could be to create a different object class that does this exclusively, and does not touch the existing InterpolatedChromaticObject class. The actual class would be very similar to InterpolatedChromaticObject, but would skip some of the steps the class currently takes before creating images to interpolate, as these would be given as input.
  3. A third option could be to mimic what the InterpolatedImage class, which currently spatially interpolates a single image, and create an InterpolatedChromaticImage class that can take also interpolate in wavelength.

Our timeline is to implement something for this problem this week, and with the main goal of making simulations in the coming months, so the timeline of the project is relatively short.

rmjarvis commented 3 months ago

I would suggest using the existing InterpolatedChromaticObject class, and make a classmethod factory function to construct it. Something like gasim.InterpolatedChromaticObject.from_images(images, wavelengths).

aguinot commented 3 months ago

Thank you for the suggestion! Given that InterpolatedChromaticObject is a subclass of ChromaticObject isn't it going to be a problem to make a classmethod that do not provide the expected input, meaning a ChromaticObject ?

rmjarvis commented 3 months ago

Nope. No problem with that. ChromaticRealGalaxy has a similar functionality. cf. http://galsim-developers.github.io/GalSim/_build/html/chromaticobject.html#galsim.ChromaticRealGalaxy.makeFromImages

That's doing a slightly different thing, but it's pretty similar, so worth taking a look.

FedericoBerlfein commented 3 months ago

Got it, thanks for the help Mike!

rmjarvis commented 2 months ago

Implemented on #1296