Skip to content

Commit

Permalink
update test_psfgrid for most tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BradleySappington committed Dec 8, 2023
1 parent b3fdf34 commit 78f4573
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions webbpsf/tests/test_psfgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import numpy as np
import pytest

from .. import gridded_library
from .. import webbpsf_core
from .. import roman
from .. import utils
from .. import detectors
from webbpsf import gridded_library
from webbpsf import webbpsf_core
from webbpsf import roman
from webbpsf import utils
from webbpsf import detectors


def test_compare_to_calc_psf_oversampled():
Expand All @@ -33,7 +33,7 @@ def test_compare_to_calc_psf_oversampled():

# Pull one of the PSFs out of the grid
psfnum = 1
loc = grid.meta["grid_xypos"][psfnum]
loc = grid.grid_xypos[psfnum]
locy = int(float(loc[1]) - 0.5)
locx = int(float(loc[0]) - 0.5)
gridpsf = grid.data[psfnum, :, :]
Expand Down Expand Up @@ -68,7 +68,7 @@ def test_compare_to_calc_psf_detsampled():

# Pull one of the PSFs out of the grid
psfnum = 1
loc = grid.meta["grid_xypos"][psfnum]
loc = grid.grid_xypos[psfnum]
locy = int(float(loc[1]))
locx = int(float(loc[0]))
gridpsf = grid.data[psfnum, :, :]
Expand Down Expand Up @@ -142,8 +142,8 @@ def test_one_psf():
scalefactor = oversample**2 # normalization as used internally in GriddedPSFModel; see #302


assert grid1.meta["grid_xypos"] == [(1023, 1023)], "Center position not as expected" # the default is the center of the NIS aperture
assert grid2.meta["grid_xypos"] == [(10, 0)], "Corner position not as expected" # it's in (x,y)
assert np.all(grid1.grid_xypos == [[1023, 1023]]), "Center position not as expected" # the default is the center of the NIS aperture
assert np.all(grid2.grid_xypos == [(10, 0)]), "Corner position not as expected" # it's in (x,y)
# check for near-equality of the PSFs computed both ways,
# but ignore the outer few pixels rows and columns, for which boundary wrapping leads to imperfect equality
# depending on the order of the convolutions. Ignore 2 rows/cols on either side based on oversample value
Expand Down Expand Up @@ -209,7 +209,7 @@ def test_saving(tmpdir):
# Check meta data
model = utils.to_griddedpsfmodel(infile)
assert model.meta.keys() == grid.meta.keys()
assert model.meta["grid_xypos"] == grid.meta["grid_xypos"]
assert np.all(model.grid_xypos == grid.grid_xypos)
assert model.meta["oversampling"] == grid.meta["oversampling"]

# Remove temporary directory
Expand Down Expand Up @@ -249,7 +249,7 @@ def test_wfi():

# Pull one of the PSFs out of the grid
psfnum = 1
loc = grid.meta["grid_xypos"][psfnum]
loc = grid.grid_xypos[psfnum]
locy = int(float(loc[1])-0.5)
locx = int(float(loc[0])-0.5)
gridpsf = grid.data[psfnum, :, :]
Expand All @@ -266,3 +266,4 @@ def test_wfi():
assert np.allclose(gridpsf, convpsf*scalefactor), "Data values not as expected"


test_saving('/Users/bsappington/tmp/')

0 comments on commit 78f4573

Please sign in to comment.