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

Unit test added for wcs_functions.py #1654

Closed
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
224b02d
Removed header expname/exver, drc implementation
s-goldman Aug 23, 2023
0f51c78
Merge branch 'master' into get_skycell_improvement
s-goldman Aug 23, 2023
5806e97
Merge branch 'spacetelescope:master' into get_skycell_improvement
s-goldman Aug 23, 2023
a7a1558
Added light sample header fits files
s-goldman Aug 23, 2023
05e8599
Update drizzlepac/wcs_functions.py
s-goldman Aug 23, 2023
684f947
Update drizzlepac/wcs_functions.py
s-goldman Aug 23, 2023
2101781
Update wcs_functions.py
s-goldman Aug 23, 2023
d8a6e8d
added back expname and extver
s-goldman Aug 30, 2023
bd0d4e8
Merge branch 'master' into get_skycell_improvement
s-goldman Sep 5, 2023
c4e0e57
Merge branch 'master' into get_skycell_improvement
s-goldman Sep 18, 2023
5c65968
Merge branch 'master' into get_skycell_improvement
s-goldman Sep 27, 2023
73580a0
Merge branch 'master' into get_skycell_improvement
s-goldman Sep 27, 2023
b685297
Merge branch 'master' into get_skycell_improvement
s-goldman Oct 2, 2023
8497fce
Merge branch 'master' into get_skycell_improvement
s-goldman Oct 3, 2023
a3989b6
Merge branch 'master' into get_skycell_improvement
s-goldman Oct 5, 2023
e53abe9
Merge branch 'master' into get_skycell_improvement
s-goldman Oct 10, 2023
740196c
Merge branch 'spacetelescope:master' into get_skycell_improvement
s-goldman Nov 15, 2023
6c372ba
Update test_wcs_functions.py
s-goldman Dec 11, 2023
c96f877
Update wcs_functions.py
s-goldman Dec 11, 2023
1fb858b
Merge branch 'master' into get_skycell_improvement
s-goldman Dec 11, 2023
dd20d3a
revert wcs_functions changes
s-goldman Dec 18, 2023
59ce6c5
Merge branch 'master' into get_skycell_improvement
s-goldman Jan 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions drizzlepac/tests/sample_drc_header.fits

Large diffs are not rendered by default.

4,296 changes: 4,296 additions & 0 deletions drizzlepac/tests/sample_flc_header.fits

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions drizzlepac/tests/test_wcs_functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import os
import pytest
import numpy as np
from astropy.wcs import WCS
from astropy.io import fits
from drizzlepac.wcs_functions import make_mosaic_wcs

abs_path = 'drizzlepac/tests/'

# checks if function works with single filenames and lists of filenames
# does not check if wcs is different, but this was confirmed independently.
@pytest.mark.parametrize(
"filename_array",
[
(abs_path+"sample_drc_header.fits"),
(abs_path+"sample_flc_header.fits"),
([abs_path+"sample_flc_header.fits", abs_path+"sample_flc_header.fits"]),
pytest.param([abs_path+"sample_flc_header.fits", abs_path+"sample_drc_header.fits"], marks=pytest.mark.xfail),
pytest.param(["bad_filename.fits"], marks=pytest.mark.xfail),
],
)
def test_make_mosaic_wcs(filename_array):
new_wcs = make_mosaic_wcs(filename_array)
19 changes: 11 additions & 8 deletions drizzlepac/wcs_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

"""
from astropy.io import fits as pyfits
from astropy.wcs.utils import is_proj_plane_distorted
import copy
import numpy as np
from numpy import linalg
Expand Down Expand Up @@ -129,8 +130,8 @@ def get_hstwcs(filename, extnum):
""" Return the HSTWCS object for a given chip. """
hdrwcs = wcsutil.HSTWCS(filename, ext=extnum)
hdrwcs.filename = filename
hdrwcs.expname = pyfits.getval(filename, 'expname', ext=extnum)
hdrwcs.extver = pyfits.getval(filename, 'extver', ext=extnum)
# hdrwcs.expname = pyfits.getval(filename, 'expname', ext=extnum)
# hdrwcs.extver = pyfits.getval(filename, 'extver', ext=extnum)

return hdrwcs

Expand Down Expand Up @@ -1069,15 +1070,17 @@ def make_mosaic_wcs(filenames, rot=None, scale=None):
mosaic_wcs : HSTWCS object
the merged composite WCS
"""

# makes str into list of str
if not isinstance(filenames, list):
filenames = [filenames]

# Compile list of WCSs for all chips from all input filenames
hstwcs_list = []
for f in filenames:
hstwcs_list.extend([get_hstwcs(f, extnum) for extnum in get_extns(f)])
# Combine them into a single mosaic WCS
output_wcs = utils.output_wcs(hstwcs_list, undistort=True)
hstwcs_list = [get_hstwcs(f, extnum) for f in filenames for extnum in get_extns(f)]

# Generate output WCS based on input WCSs, and undistorts depending on extension.
s-goldman marked this conversation as resolved.
Show resolved Hide resolved
output_wcs = utils.output_wcs(hstwcs_list, undistort=is_proj_plane_distorted(hstwcs_list[0]))
s-goldman marked this conversation as resolved.
Show resolved Hide resolved

# Combine them into a single mosaic WCS
output_wcs.wcs.cd = make_perfect_cd(output_wcs)

# Apply each parameter in order, as this is effectively what is
Expand Down