Skip to content

Commit f10ca72

Browse files
authored
Merge pull request #852 from bhilbert4/modernize-packaging
Modernize packaging
2 parents 840c149 + c7a26d0 commit f10ca72

30 files changed

Lines changed: 2496 additions & 2536 deletions

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Python Package CI
22

33
on:
44
push:
5-
branches: [ "master" ]
5+
branches: [ "main" ]
66
pull_request:
7-
branches: [ "master" ]
7+
branches: [ "main" ]
88

99
jobs:
1010
build:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
# Package Stuff #
99
#################
10+
build/
1011
build/*
1112
dist/*
1213
mirages.egg-info/*

MANIFEST.in

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
1-
include mirage/config/NIRCam_subarray_definitions.list
2-
include mirage/config/NIRCam_zeropoints.list
3-
include mirage/config/__init__.py
4-
include mirage/config/dq_init.cfg
5-
include mirage/config/linearity.cfg
6-
include mirage/config/nircam_filter_pupil_pairings.list
7-
include mirage/config/nircam_read_pattern_definitions.list
8-
include mirage/config/refpix.cfg
9-
include mirage/config/saturation.cfg
10-
include mirage/config/superbias.cfg
11-
include mirage/config/xtalk20150303g0.errorcut.txt
1+
recursive-include mirage/config *
122
include tests/test_data/NIRISS/niriss_soss_substrip256_clear.yaml
133
include mirage/reference_files/jband_transmission.dat
144
include mirage/reference_files/alpha_lyr_stis_009.fits
155
include examples/niriss_soss_example_data/*
16-
exclude mirage/reference_files/stellarmodels/atlas/*
17-
exclude mirage/reference_files/stellarmodels/phoenix/*
18-
exclude mirage/version.py

environment_python_3.11.yml

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,27 @@ dependencies:
88
- pip
99
- python==3.11.13
1010
- pip:
11-
- asdf==4.5.0
12-
- astropy==7.1.0
11+
- asdf==5.3.0
12+
- astropy==7.2.0
1313
- astroquery==0.4.11
1414
- batman-package>=2.5.2
15-
- bokeh==3.8.0
16-
- crds==13.0.6
17-
- grismconf==1.51
18-
- h5py==3.14.0
15+
- bokeh==3.9.0
16+
- crds==13.1.6
17+
- grismconf>=1.60
18+
- h5py==3.16.0
1919
- hotsoss==0.1.10
20-
- ipython==9.6.0
21-
- jupyter==1.1.1
22-
- jwst==1.19.2
20+
- jwst==2.0.0
2321
- jwst-backgrounds==1.3.0
2422
- jwst_gtvt==1.1.1
25-
- lxml==6.0.2
26-
- matplotlib==3.10.7
23+
- lxml==6.1.0
24+
- matplotlib==3.10.9
2725
- nircam_gsim>=1.71
28-
- numpy==2.2.6
26+
- numpy==2.3.5
2927
- photutils==2.3.0
30-
- pysiaf==0.24.1
31-
- pytest==8.4.2
28+
- pysiaf>=0.25.0
29+
- pytest==9.0.3
3230
- pyyaml==6.0.3
33-
- scipy==1.16.2
34-
- sphinx==8.2.3
35-
- synphot==1.6.0
36-
- webbpsf==2.0.0
31+
- scipy==1.17.1
32+
- setuptools==81.0.0
33+
- stpsf==2.2.0
34+
- synphot==1.7.0

environment_python_3.12.yml

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,27 @@ dependencies:
88
- pip
99
- python==3.12.11
1010
- pip:
11-
- asdf==4.5.0
12-
- astropy==7.1.0
11+
- asdf==5.3.0
12+
- astropy==7.2.0
1313
- astroquery==0.4.11
14-
- bokeh==3.8.0
15-
- crds==13.0.6
16-
- grismconf==1.51
17-
- h5py==3.14.0
14+
- batman-package>=2.5.2
15+
- bokeh==3.9.0
16+
- crds==13.1.6
17+
- grismconf>=1.60
18+
- h5py==3.16.0
1819
- hotsoss==0.1.10
19-
- ipython==9.6.0
20-
- jupyter==1.1.1
21-
- jwst==1.19.2
20+
- jwst==2.0.0
2221
- jwst-backgrounds==1.3.0
2322
- jwst_gtvt==1.1.1
24-
- lxml==6.0.2
25-
- matplotlib==3.10.7
23+
- lxml==6.1.0
24+
- matplotlib==3.10.9
2625
- nircam_gsim>=1.71
27-
- numpy==2.2.6
26+
- numpy==2.3.5
2827
- photutils==2.3.0
29-
- pysiaf==0.24.1
30-
- pytest==8.4.2
28+
- pysiaf>=0.25.0
29+
- pytest==9.0.3
3130
- pyyaml==6.0.3
32-
- scipy==1.16.2
33-
- sphinx==8.2.3
34-
- synphot==1.6.0
35-
- webbpsf==2.0.0
31+
- scipy==1.17.1
32+
- setuptools==81.0.0
33+
- stpsf==2.2.0
34+
- synphot==1.7.0

mirage/psf/deployments.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
from astropy.io import fits
2222
import numpy as np
23-
import webbpsf
23+
import stpsf as webbpsf
2424

2525
from mirage.logging import logging_functions
2626
from mirage.utils.constants import LOG_CONFIG_FILENAME, STANDARD_LOGFILE_NAME

mirage/psf/psf_selection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
from astropy.io import fits
3939
import numpy as np
40-
from webbpsf.utils import to_griddedpsfmodel
40+
from stpsf.utils import to_griddedpsfmodel
4141

4242
from mirage.logging import logging_functions
4343
from mirage.utils.constants import NIRISS_PUPIL_WHEEL_FILTERS, NIRCAM_PUPIL_WHEEL_FILTERS, \

mirage/psf/segment_psfs.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
from astropy.io import fits
2727
import numpy as np
2828
import pysiaf
29-
import webbpsf
30-
from webbpsf.gridded_library import CreatePSFLibrary
31-
from webbpsf.utils import to_griddedpsfmodel
29+
import stpsf
30+
from stpsf.gridded_library import CreatePSFLibrary
31+
from stpsf.utils import to_griddedpsfmodel
3232

3333
import multiprocessing
3434
import functools
@@ -56,7 +56,7 @@ def _generate_psfs_for_one_segment(inst, ote, segment_tilts, out_dir, boresight,
5656

5757
i_segment = i + 1
5858

59-
segname = webbpsf.webbpsf_core.segname(i_segment)
59+
segname = stpsf.stpsf_core.segname(i_segment)
6060
logger.info('GENERATING SEGMENT {} DATA'.format(segname))
6161

6262
det_filt_match = False
@@ -76,12 +76,12 @@ def _generate_psfs_for_one_segment(inst, ote, segment_tilts, out_dir, boresight,
7676
inst.detector = det
7777

7878
# Restrict the pupil to the current segment
79-
pupil = webbpsf.webbpsf_core.one_segment_pupil(i_segment)
79+
pupil = stpsf.stpsf_core.one_segment_pupil(i_segment)
8080
ote.amplitude = pupil[0].data
8181
inst.pupil = ote
8282

8383
# Determine normalization factor - what fraction of total pupil is in this one segment?
84-
full_pupil = fits.getdata(os.path.join(webbpsf.utils.get_webbpsf_data_path(), 'jwst_pupil_RevW_npix1024.fits.gz'))
84+
full_pupil = fits.getdata(os.path.join(stpsf.utils.get_stpsf_data_path(), 'jwst_pupil_RevW_npix1024.fits.gz'))
8585
pupil_fraction_for_this_segment = pupil[0].data.sum() / full_pupil.sum()
8686

8787
# Generate the PSF grid
@@ -191,7 +191,12 @@ def generate_segment_psfs(ote, segment_tilts, out_dir, filters=['F212N', 'F480M'
191191
logger = logging.getLogger('mirage.psf.segment_psfs.generate_segment_psfs')
192192

193193
# Create webbpsf NIRCam instance
194-
inst = webbpsf.Instrument(instrument)
194+
if instrument.lower() == 'nircam':
195+
inst = stpsf.NIRCam()
196+
elif instrument.lower() == 'fgs':
197+
inst = stpsf.FGS()
198+
else:
199+
raise ValueError(f'Unsupported instrument: {instrument}')
195200

196201
# Create dummy CreatePSFLibrary instance to get lists of filter and detectors
197202
lib = CreatePSFLibrary
@@ -415,14 +420,14 @@ def get_segment_offset(segment_number, detector, library_list):
415420
}
416421

417422
x_rot = control_xaxis_rotations[segment] # degrees
418-
x_rot_rad = x_rot * np.pi / 180 # radians
423+
x_rot_rad = np.float64(x_rot * np.pi / 180) # radians
419424

420425
# Note that y is defined as the x component and x is defined as the y component.
421426
# This is because "xtilt" moves the PSF in the y direction, and vice versa.
422-
tilt_onto_y = (xtilt * np.cos(x_rot_rad)) - (ytilt * np.sin(x_rot_rad))
423-
tilt_onto_x = (xtilt * np.sin(x_rot_rad)) + (ytilt * np.cos(x_rot_rad))
427+
tilt_onto_y = np.float64((xtilt * np.cos(x_rot_rad)) - (ytilt * np.sin(x_rot_rad)))
428+
tilt_onto_x = np.float64((xtilt * np.sin(x_rot_rad)) + (ytilt * np.cos(x_rot_rad)))
424429

425-
umrad_to_arcsec = 1e-6 * (180./np.pi) * 3600
430+
umrad_to_arcsec = np.float64(1e-6 * (180./np.pi) * 3600)
426431
x_arcsec = 2 * umrad_to_arcsec * tilt_onto_x
427432
y_arcsec = 2 * umrad_to_arcsec * tilt_onto_y
428433

@@ -450,11 +455,11 @@ def get_segment_offset(segment_number, detector, library_list):
450455
# between different OTE pose terms into optical tip and tilt. In particular, this is needed for
451456
# accurate modeling of radial translation corrections when using incoherent PSF calculations.
452457
if f'S{segment_number:02d}XTILT' in header:
453-
hexike_to_arcsec = 206265/webbpsf.constants.JWST_SEGMENT_RADIUS
458+
hexike_to_arcsec = 206265/stpsf.constants.JWST_SEGMENT_RADIUS
454459
# recall that Hexike tilt _around the X axis_ produces an offset _into Y_, and vice versa.
455-
x_arcsec = header[f'S{segment_number:02d}YTILT'] * hexike_to_arcsec
460+
x_arcsec = np.float64(header[f'S{segment_number:02d}YTILT'] * hexike_to_arcsec)
456461
# also recall coord flip of Y axis from OTE L.O.M in entrance pupil to exit pupil
457-
y_arcsec = -header[f'S{segment_number:02d}XTILT'] * hexike_to_arcsec
462+
y_arcsec = np.float64(-header[f'S{segment_number:02d}XTILT'] * hexike_to_arcsec)
458463

459464
# Optionally, arbitrary boresight offset may also be present in the FITS header metadata.
460465
# If so, include that in the PSF too. Be careful about coordinate sign for the V2 axis!

mirage/psf/soss_trace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def generate_SOSS_psfs(filt):
194194
The filter to use, ['CLEAR', 'F277W']
195195
"""
196196
try:
197-
import webbpsf
197+
import stpsf as webbpsf
198198

199199
except ImportError:
200200
raise ("Could not import `webbpsf` package. Functionality limited. Generating dummy file.")

mirage/psf/tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from astropy.modeling.models import Gaussian2D
1111
import numpy as np
1212
from photutils.datasets import load_irac_psf
13-
import webbpsf
13+
import stpsf as webbpsf
1414

1515
from mirage.psf.psf_selection import get_psf_wings
1616
from mirage.utils.siaf_interface import get_instance

0 commit comments

Comments
 (0)