spacetelescope / webbpsf

James Webb Space Telescope PSF simulation tool
https://webbpsf.readthedocs.io
BSD 3-Clause "New" or "Revised" License
119 stars 63 forks source link

Roll-your-own source spectra don't work as described #28

Closed mperrin closed 6 years ago

mperrin commented 6 years ago

Issue by josePhoenix Tuesday Nov 25, 2014 at 22:16 GMT Originally opened as https://github.com/mperrin/webbpsf/issues/28


The docs say source spectra can be provided a variety of ways, but it looks like options 2 and 3 are not currently functional. We should update the docs and/or POPPY.

The following are valid sources:

  1. A pysynphot.Spectrum object. This is the best option, providing maximum ease and accuracy, but requires the user to have pysynphot installed. In this case, the Spectrum object is combined with a pysynphot.ObsBandpass for the selected instrument and filter to derive the effective stimulus in detected photoelectrons versus wavelength. This is binned to the number of wavelengths set by the nlambda parameter.
  2. A dictionary with elements source["wavelengths"] and source["weights"] giving the wavelengths in meters and the relative weights for each. These should be numpy arrays or lists. In this case, the wavelengths and weights are used exactly as provided, without applying the instrumental filter profile.

    src = {'wavelengths': [2.0e-6, 2.1e-6, 2.2e-6], 'weights': [0.3, 0.5, 0.2]} nc.calcPSF(source=src, outfile='psf_for_src.fits')

  3. A tuple or list containing the numpy arrays (wavelength, weights) instead.

Reported by @kvangorkom.

To reproduce:

Run this code and note the output. Specifically, the part that says Pysynphot unavailable (or invalid source supplied)! Assuming flat # of counts versus wavelength.

It looks like poppy/instrument.py line 611 (_getWeights) is the section of interest in poppy.

import webbpsf
miri = webbpsf.MIRI()
test_src = {'wavelengths':[2.0e-6, 2.1e-6, 2.2e-6], 'weights': [0.3, 0.5, 0.2]}
miri.calcPSF(source=test_src)

Output:

webbpsf : INFO Setting up PSF calculation for MIRI
webbpsf : INFO PSF calc using fov_arcsec = 12.000000, oversample = 4, nlambda = 9
poppy : WARNING Pysynphot unavailable (or invalid source supplied)! Assuming flat # of counts versus wavelength.
poppy : WARNING CAUTION: no WAVEUNIT keyword found in filter file /Users/kgorkom/webbpsf-data//MIRI//filters/F560W_throughput.fits. Assuming = Angstroms by default
poppy : WARNING CAUTION: Just interpolating rather than integrating filter profile, over 9 steps
webbpsf : INFO Creating optical system model:
poppy : INFO Initialized OpticalSystem: JWST+MIRI
poppy : INFO JWST Pupil: Loaded amplitude transmission from /Users/kgorkom/webbpsf-data/pupil_RevV.fits
poppy : INFO JWST Pupil: Loaded OPD from /Users/kgorkom/webbpsf-data//MIRI/OPD/OPD_RevV_miri_421.fits
poppy : INFO The supplied pupil OPD is a datacube but no slice was specified. Defaulting to use slice 0.
poppy : INFO Rotated optic by 4.561000 degrees counter clockwise.
poppy : INFO Added pupil plane: JWST Pupil
poppy : INFO Added detector: MIRI detector, with pixelscale=0.110000 arcsec/pixel and oversampling=4
poppy : INFO Calculating PSF with 9 wavelengths
poppy : INFO Propagating wavelength = 5.04e-06 meters with weight=0.06
poppy : INFO Propagating wavelength = 5.1825e-06 meters with weight=0.11
poppy : INFO Propagating wavelength = 5.325e-06 meters with weight=0.10
poppy : INFO Propagating wavelength = 5.4675e-06 meters with weight=0.12
poppy : INFO Propagating wavelength = 5.61e-06 meters with weight=0.13
poppy : INFO Propagating wavelength = 5.7525e-06 meters with weight=0.13
poppy : INFO Propagating wavelength = 5.895e-06 meters with weight=0.14
poppy : INFO Propagating wavelength = 6.0375e-06 meters with weight=0.14
poppy : INFO Propagating wavelength = 6.18e-06 meters with weight=0.06
poppy : INFO Calculation completed in 5.627 s
poppy : INFO PSF Calculation completed.
poppy : INFO Downsampling to detector pixel scale. 
mperrin commented 6 years ago

Comment by josePhoenix Tuesday Dec 16, 2014 at 15:48 GMT


OpticalSystem has this functionality; just need to pass source through as a (wavelengths, weights) tuple

mperrin commented 6 years ago

Comment by mperrin Tuesday Dec 16, 2014 at 15:56 GMT


Addressed in commit b28162c but needs testing.

mperrin commented 6 years ago

Comment by josePhoenix Tuesday Dec 16, 2014 at 22:38 GMT


Did you push after committing? I'm not seeing it

mperrin commented 6 years ago

Comment by mperrin Tuesday Dec 16, 2014 at 23:02 GMT


This was a commit to poppy/instrument.py not anything in webbpsf.

https://github.com/mperrin/poppy/commit/b28162c00ebafbb8739ae66bd0b5ded3a8d1ef4b

mperrin commented 6 years ago

Comment by josePhoenix Tuesday Dec 16, 2014 at 23:43 GMT


ahh right :+1:

mperrin commented 6 years ago

Comment by josePhoenix Thursday Dec 18, 2014 at 16:38 GMT


Seems to be working for Kyle; will open issue on POPPY to add test for this.