Skip to content

Commit

Permalink
Merge branch 'ifu_mode_improvements_part2' of github.com:mperrin/webb…
Browse files Browse the repository at this point in the history
…psf-st into ifu_mode_improvements_part2
  • Loading branch information
mperrin committed Sep 12, 2024
2 parents e686a22 + e67280f commit d99fa5e
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 23 deletions.
12 changes: 0 additions & 12 deletions CITATION

This file was deleted.

59 changes: 59 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: WebbPSF
message: >-
If you use this software, please cite it using the
metadata from this file.
type: software
authors:
- given-names: Marshall
family-names: Perrin
affiliation: Space Telescope Science Institute
orcid: 'https://orcid.org/0000-0002-3191-8151'
- given-names: Marcio
family-names: Melendez
email: [email protected]
affiliation: Space Telescope Science Institute
orcid: 'https://orcid.org/0000-0001-8485-0325'
- given-names: Shannon
family-names: Osborne
affiliation: Fred Hutchinson Cancer Center
orcid: https://orcid.org/0009-0001-8609-1518'
- given-names: Robel
family-names: Geda
affiliation: Princeton University
orcid: 'https://orcid.org/0000-0003-1509-9966'
- given-names: Bradley
family-names: Sappington
email: [email protected]
affiliation: Space Telescope Science Institute
orcid: 'https://orcid.org/0009-0008-2911-2555'
- given-names: Charles-Philippe
family-names: Lajoie
affiliation: Space Telescope Science Institute
orcid: 'https://orcid.org/0009-0003-3993-8338'
- given-names: Joseph
family-names: Long
affiliation: Flatiron Institute
orcid: 'https://orcid.org/0000-0003-1905-9443'
- given-names: "O. Justin"
family-names: "Otor"
affiliation: "Otor"
orcid: 'https://orcid.org/0000-0002-4679-5692'
repository-code: 'https://github.com/spacetelescope/webbpsf'
abstract: >-
WebbPSF produces simulated PSFs for the James Webb Space
Telescope, NASA's flagship infrared space telescope.
WebbPSF can simulate images for any of the four science
instruments plus the fine guidance sensor, including both
direct imaging, coronagraphic, and spectroscopic modes.
WebbPSF also supports simulating PSFs for the upcoming
Nancy Grace Roman Space Telescope (formerly WFIRST),
including its Wide Field Instrument and a preliminary
version of the Coronagraph Instrument.
license: BSD-3-Clause
version: 1.3.1
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2010-2018, Space Telescope Science Institute, AURA
Copyright (c) 2010-2024, Space Telescope Science Institute, AURA
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
18 changes: 9 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
astropy==6.0.1
ipython==8.24.0
matplotlib==3.9.0
numpy==1.26.4
photutils==1.13.0
astropy>=6.1.2,<6.2.0
ipython>=8.27.0,<8.28.0
matplotlib>=3.9.1,<3.10.0
numpy>=2.1.0,<2.2.0
photutils>=1.13.0,<1.14.0
poppy>=1.0.0
pysiaf==0.22.0
scipy==1.13.0
synphot==1.4.0
astroquery==0.4.7
pysiaf>=0.22.0,<0.23.0
scipy>=1.14.0,<1.15.0
synphot>=1.4.0,<1.5.0
astroquery>=0.4.7,<0.5.0
24 changes: 23 additions & 1 deletion webbpsf/tests/test_nirspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ def test_calc_datacube_fast():
def test_mode_switch():
"""Test switch between IFU and imaging modes"""
nrs = webbpsf_core.NIRSpec()
nrs_default_v3pa = nrs._rotation
# check mode swith to IFU
nrs.mode = 'IFU'
assert 'IFU' in nrs.aperturename
assert nrs.band == 'PRISM/CLEAR'
assert nrs.image_mask is None
assert nrs._rotation != nrs_default_v3pa

# check switch of which IFU band
nrs.disperser = 'G395H'
Expand All @@ -76,6 +78,7 @@ def test_mode_switch():
# check mode switch back to imaging
nrs.mode = 'imaging'
assert 'IFU' not in nrs.aperturename
assert nrs._rotation == nrs_default_v3pa


def test_IFU_wavelengths():
Expand All @@ -94,6 +97,26 @@ def test_IFU_wavelengths():
assert len(nrs.get_IFU_wavelengths(n)) == n



def test_aperture_rotation_updates():
""" Test that switching detector or aperture updates the aperture PA
(this is a tiny detail)"""
nrs = webbpsf_core.NIRSpec()
pa_nrs1_full = nrs._rotation

# changing aperture updates PA
nrs.set_position_from_aperture_name('NRS_S200A1_SLIT')
assert nrs._rotation != pa_nrs1_full

# change back to original aperture
nrs.set_position_from_aperture_name('NRS1_FULL')
assert nrs._rotation == pa_nrs1_full

# changing detector should update aperturename and also update PA
nrs.detector = 'NRS2'
assert nrs.aperturename == 'NRS2_FULL'
assert nrs._rotation != pa_nrs1_full

def test_nrs_ifu_broadening():
""" Basic functional test for the code that adjusts PSF outputs to better match empirical IFU PSFs
"""
Expand All @@ -116,4 +139,3 @@ def test_nrs_ifu_broadening():
fwhm_oversamp = webbpsf.measure_fwhm(psf_nb, ext='OVERSAMP')
fwhm_overdist = webbpsf.measure_fwhm(psf_nb, ext='OVERDIST')
assert fwhm_overdist == fwhm_oversamp, "IFU broadening model should be disabled for this test case"

16 changes: 16 additions & 0 deletions webbpsf/webbpsf_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3330,6 +3330,9 @@ def aperturename(self, value):
self.image_mask = None
else:
self._mode = 'imaging' # More to implement here later!
# Update the rotation angle
# This works the same for both regular and IFU modes
self._rotation = self._get_aperture_rotation(self.aperturename)

def _tel_coords(self):
"""Convert from science frame coordinates to telescope frame coordinates using
Expand Down Expand Up @@ -3359,6 +3362,19 @@ def _get_pixelscale_from_apername(self, apername):
else:
return super()._get_pixelscale_from_apername(apername)

def _get_aperture_rotation(self, apername):
"""Get the rotation angle of a given aperture, using values from SIAF.
Returns ~ position angle counterclockwise from the V3 axis, in degrees
(i.e. SIAF V3IdlYangle)
For NIRSpec this is simple, since even the SLIT type apertures have
V3IdlYAngle values defined. And we don't have the complexity of
COMPOUND type apertures that MIRI has to deal with.
"""
return self.siaf[apername].V3IdlYAngle

@property
def disperser(self):
"""NIRSpec spectral dispersing element (grating or prism).
Expand Down

0 comments on commit d99fa5e

Please sign in to comment.