Search code examples
galsim

Piecewise function parameters for SED or Bandpass in GalSim


Is there a way to pass a piecewise (discontinuous) function for the "spec" parameter of SED or the "throughput" parameter of Bandpass? I tried passing a delta function and a triangular function using numpy, but galsim would not accept either as a valid python function.

I want to try drawing an object at a single wavelength, and thought I should modify the SED or the bandpass to have a value only at a single wavelength. If there are better ways to do this, please let me know!


Solution

  • There's a better way to do this.

    If you already have a ChromaticObject with some SED, you can get a GSObject corresponding to that ChromaticObject at a single wavelength using the ChromaticObject.evaluateAtWavelength() method. Once you have that GSObject, you can draw it into an image. For example:

    sed = galsim.SED('wave**0.2')
    sed2 = galsim.SED('wave**1.0')
    obj = galsim.Gaussian(sigma=0.1)*sed + galsim.Gaussian(sigma=0.5)*sed2
    foo = obj.evaluateAtWavelength(800.0) # argument is wavelength in nm
    

    You can do this and find that obj is chromatic, while foo is not. And you can do this easily for any number of wavelengths without having to redefine SEDs.