Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
josePhoenix opened this issue Nov 25, 2014 · 6 comments
Closed

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

josePhoenix opened this issue Nov 25, 2014 · 6 comments
Milestone

Comments

@josePhoenix
Copy link
Collaborator

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. 
@josePhoenix
Copy link
Collaborator Author

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

@mperrin
Copy link
Owner

mperrin commented Dec 16, 2014

Addressed in commit b28162c but needs testing.

@josePhoenix
Copy link
Collaborator Author

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

@mperrin
Copy link
Owner

mperrin commented Dec 16, 2014

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

mperrin/poppy@b28162c

@josePhoenix
Copy link
Collaborator Author

ahh right 👍

@josePhoenix
Copy link
Collaborator Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants