Skip to content

Commit

Permalink
Changes from code review.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanRyanIrish committed Dec 3, 2024
1 parent 8a654db commit f7ee6cc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions xrayvision/coordinates/frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,13 @@ def projective_frame_to_wcs(frame, projection="TAN"):
-------
`astropy.wcs.WCS`
"""
# Bail out early if not STIXImaging frame
# Bail out early if not Projective frame
if not isinstance(frame, Projective):
return None
else:
conjunction = "-"
ctype = [conjunction.join([X_CTYPE, projection]), conjunction.join([Y_CTYPE, projection])]
cunit = ["arcsec"] * 2

wcs = WCS(naxis=2)
wcs.wcs.aux.rsun_ref = frame.rsun.to_value(u.m)
Expand All @@ -102,8 +106,8 @@ def projective_frame_to_wcs(frame, projection="TAN"):
wcs.wcs.aux.dsun_obs = obs_frame.radius.to_value(u.m)

wcs.wcs.dateobs = frame.obstime.utc.iso
wcs.wcs.cunit = ["arcsec", "arcsec"]
wcs.wcs.ctype = [X_CTYPE, Y_CTYPE]
wcs.wcs.cunit = cunit
wcs.wcs.ctype = ctype

return wcs

Expand Down
4 changes: 2 additions & 2 deletions xrayvision/coordinates/tests/test_frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def projective_wcs():
w.wcs.crpix = [10, 20]
w.wcs.cdelt = np.array([2, 2])
w.wcs.crval = [0, 0]
w.wcs.ctype = ["PJLN", "PJLT"]
w.wcs.ctype = ["PJLN-TAN", "PJLT-TAN"]

w.wcs.aux.hgln_obs = 10
w.wcs.aux.hglt_obs = 20
Expand Down Expand Up @@ -58,7 +58,7 @@ def test_projective_frame_to_wcs(projective_frame):
wcs = projective_frame_to_wcs(projective_frame)

assert isinstance(wcs, WCS)
assert wcs.wcs.ctype[0] == "PJLN"
assert wcs.wcs.ctype[0] == "PJLN-TAN"
assert wcs.wcs.cunit[0] == "arcsec"
assert wcs.wcs.dateobs == "2024-01-01 00:00:00.000"

Expand Down

0 comments on commit f7ee6cc

Please sign in to comment.