From 7fd3c6de991680e8335ab18350b0ef18a6bc677f Mon Sep 17 00:00:00 2001 From: DanRyanIrish Date: Fri, 15 Nov 2024 13:45:22 +0000 Subject: [PATCH 1/7] Add generic projective frame. Good for representing images from unknown instruments. --- changelog/76.feature.rst | 1 + xrayvision/coordinates/.frames.py.swp | Bin 0 -> 16384 bytes xrayvision/coordinates/__init__.py | 0 xrayvision/coordinates/frames.py | 120 ++++++++++++++++++ .../coordinates/tests/.test_frames.py.swp | Bin 0 -> 12288 bytes xrayvision/coordinates/tests/__init__.py | 0 xrayvision/coordinates/tests/test_frames.py | 73 +++++++++++ 7 files changed, 194 insertions(+) create mode 100644 changelog/76.feature.rst create mode 100644 xrayvision/coordinates/.frames.py.swp create mode 100644 xrayvision/coordinates/__init__.py create mode 100644 xrayvision/coordinates/frames.py create mode 100644 xrayvision/coordinates/tests/.test_frames.py.swp create mode 100644 xrayvision/coordinates/tests/__init__.py create mode 100644 xrayvision/coordinates/tests/test_frames.py diff --git a/changelog/76.feature.rst b/changelog/76.feature.rst new file mode 100644 index 0000000..6f1c88d --- /dev/null +++ b/changelog/76.feature.rst @@ -0,0 +1 @@ +Add `~xrayvision.coordinates.frames.Projective` coordinate frame. This is intended to represent the projective coordinate system of images with unknown pointing. diff --git a/xrayvision/coordinates/.frames.py.swp b/xrayvision/coordinates/.frames.py.swp new file mode 100644 index 0000000000000000000000000000000000000000..2f0fcb3b793d68dd383b671c9fb3481d449c95e6 GIT binary patch literal 16384 zcmeHO&5s;M6|XpaB@i5$NC>2e%B(=M)@*Oqn_zpT0oKbpSu0*IJ7dSOW%btd)XX&Q z>1uUXZ+1WiAxm(9Gan}|fCQ3r20;`li8ur#5Fj}4p+x$_m-#vG48!p-W8dqZ?Y36$-FJ73v9^dq8KnaeQ|0_) zB)4>Zr?IrMx^#YZ-8iwUcuUI0hU8jseGjW56-s7;p?Y2L2Bi z(8&q*RrqnD@Fgg|?>qE;fARZ~;=6OGzWC|B90QI4$ADwNG2j?*3^)cH1C9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5Io)75TDk+cu`n@1=pCY}wml zZo}nX%)IG#$uMHM-TLKc*BYBou2n4Yd}RqA$V{IV^k3y_z)Jld0f|#o}0Q89jGk)T!b17>k*)t!&VP#hHP- z@5igH>G75aAIm#66UEiE=^{<7HtW`rZpHhiOc!}Ss8eif;t$wrXnr1f`yOcbJER^HNPSnLG zqM@jtR>$9mMl7q7nP7V=UUfo5u`CK4RS7F~D*B6Jn%B}wUsfD(2+9K&M{iVQpdsFG z%7T-fKy^wvY9f}lW!I@)>1eY)Qj-Re<#IgwZEm%2zP2kToJan?@NL4mRq-BG(z0e_ zg;cE+{u6beBrCFXx~Lr<4ruXAx>b4*-I95SuLy%E#J7baCF>KP4B6*zrK5ach@1w= y7Y)lZzSHs$2T2@m0h;c{~0u{})y literal 0 HcmV?d00001 diff --git a/xrayvision/coordinates/tests/__init__.py b/xrayvision/coordinates/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/xrayvision/coordinates/tests/test_frames.py b/xrayvision/coordinates/tests/test_frames.py new file mode 100644 index 0000000..81c89d1 --- /dev/null +++ b/xrayvision/coordinates/tests/test_frames.py @@ -0,0 +1,73 @@ +import astropy.units as u +import numpy as np +import pytest +from astropy.wcs import WCS +from sunpy.coordinates import HeliographicStonyhurst + +from xrayvision.coordinates.frames import Projective, projective_frame_to_wcs, projective_wcs_to_frame + + +@pytest.fixture +def projective_wcs(): + w = WCS(naxis=2) + + w.wcs.dateobs = "2024-01-01 00:00:00.000" + w.wcs.crpix = [10, 20] + w.wcs.cdelt = np.array([2, 2]) + w.wcs.crval = [0, 0] + w.wcs.ctype = ["PJLN-TAN", "PJLT-TAN"] + + w.wcs.aux.hgln_obs = 10 + w.wcs.aux.hglt_obs = 20 + w.wcs.aux.dsun_obs = 1.5e11 + + return w + + +@pytest.fixture +def projective_frame(): + obstime = "2024-01-01" + observer = HeliographicStonyhurst(10 * u.deg, 20 * u.deg, 1.5e11 * u.m, obstime=obstime) + + frame_args = {"obstime": obstime, "observer": observer, "rsun": 695_700_000 * u.m} + + frame = Projective(**frame_args) + return frame + + +def test_projective_wcs_to_frame(projective_wcs): + frame = projective_wcs_to_frame(projective_wcs) + assert isinstance(frame, Projective) + + assert frame.obstime.isot == "2024-01-01T00:00:00.000" + assert frame.rsun == 695700 * u.km + assert frame.observer == HeliographicStonyhurst( + 10 * u.deg, 20 * u.deg, 1.5e11 * u.m, obstime="2024-01-01T00:00:00.000" + ) + + +def test_projective_wcs_to_frame_none(): + w = WCS(naxis=2) + w.wcs.ctype = ["ham", "cheese"] + frame = projective_wcs_to_frame(w) + + assert frame is None + + +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-TAN" + assert wcs.wcs.cunit[0] == "arcsec" + assert wcs.wcs.dateobs == "2024-01-01 00:00:00.000" + + assert wcs.wcs.aux.rsun_ref == projective_frame.rsun.to_value(u.m) + assert wcs.wcs.aux.dsun_obs == 1.5e11 + assert wcs.wcs.aux.hgln_obs == 10 + assert wcs.wcs.aux.hglt_obs == 20 + + +def test_projective_frame_to_wcs_none(): + wcs = projective_frame_to_wcs(HeliographicStonyhurst()) + assert wcs is None From 2586df50a7f926b763ac5faebd7c0d1f6192e4fd Mon Sep 17 00:00:00 2001 From: DanRyanIrish Date: Fri, 15 Nov 2024 15:36:25 +0000 Subject: [PATCH 2/7] Delete xrayvision/coordinates/.frames.py.swp --- xrayvision/coordinates/.frames.py.swp | Bin 16384 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 xrayvision/coordinates/.frames.py.swp diff --git a/xrayvision/coordinates/.frames.py.swp b/xrayvision/coordinates/.frames.py.swp deleted file mode 100644 index 2f0fcb3b793d68dd383b671c9fb3481d449c95e6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16384 zcmeHO&5s;M6|XpaB@i5$NC>2e%B(=M)@*Oqn_zpT0oKbpSu0*IJ7dSOW%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<)_y#`|Sm)3IvNpjgXN;<%0JP?EMU zCp;-fvaD8dz0zFYrWtH)Ddxh6$?ECThF@Q#-K>~2qXNvSFIO<{X;xR(cpDyy{Vo

311^A%mH8SgMS{WsI304UE2t00WH_J&uY>^Fjzw z!cC~niX}a%$3_)&K#}B7a5)@RnupdrMVvCgjNG*m0T+1r1Pa=;~jJ54U0P!EpFoq+!}D) zl8Lkx>Qtn-r9mxj1u3uu5w7E7cR|%g9`6h;h)j+wyh!&LW?dDr5gb)^E+V5 z*R1h(*l0F+H9pUuBel{^u^HH*`Xk28YAWXmMc%>>L@-vImbGK{AFiS~labRoqy7JD z*pHvZ9-a38<@5btV!!__;G4i6a29wNpgaHr-ohULO@Q|QZQ$d;$AEu9&+mXA19t(+ z0g&$dfj^?39|7)g3^)cH1C9a5fMdWh;23ZWI0hU8M=(%sYOv*@ytha~uY)}d{WQ5W zzj?*Ky7BoHFHa~jSA9qFWBK%B=@vNNVVj-ZE0;Dmnp@X4ZOX5-cahoLQKfNx_Xcvi zl_1Zw>aXF?(O#Kl-k08&DmD`Yv1hjDiy><`CfGbeka8z%o>3+*!Ny&*iMWfq>z6lu zY&HGM>pMGJ+fOw-JmbKFmg-84-yE4cku$%wI71WZu-e{66UKvbe`fy;O$&Ti_SL@R zic-~mJO;pX9{T$@R~>G)`ShHL_q0y3wdG~xyL)*HyZ-*NsVqK|Jc^djK6(BLOgJRz ziU$Og*|ooERuN3fmXZpG6SlWZv!NJmr%mp`X6-1yRh&%<7Aa$h8h Date: Fri, 15 Nov 2024 15:38:04 +0000 Subject: [PATCH 3/7] Delete xrayvision/coordinates/tests/.test_frames.py.swp --- .../coordinates/tests/.test_frames.py.swp | Bin 12288 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 xrayvision/coordinates/tests/.test_frames.py.swp diff --git a/xrayvision/coordinates/tests/.test_frames.py.swp b/xrayvision/coordinates/tests/.test_frames.py.swp deleted file mode 100644 index 0485ec7ac978c1481c3c8bdf85e50ef70be8a051..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2O=u)V6vr!j$gb{Yl@&d@WqaufGo7A^>+S{uiXiLahCt#6gxGX?YGztzx|{0m zB!jM=jJH+r;&nv?5AJalL2oPG6a*2`qkHnYq6p%@s=BAU=OY`zgGx2?OQx&dt9tdX zS8pbyckJh%xk4{kErRQQLVoF<@4Cx3=03heNZSp3*5^Yv5S_EH!mjb+`bML<+_<>h zv?uLfFASGBi^6zmpS#0dKla0*{MHLY-u44GVet}3)K90w-2scOXgE2tZqW*81rAjp zO*)MW3uL*aPUfS=BlLkY&mHQbJGBB@0j+>mKr5gX&mKr5gX&fgyqNkiT?+$7gn_tUr4bKbW?tg&GNMkLPtb@)LH%^Kl2jn`(c;6QP1}_k}w$dQXVH}tw!3cL&bx9PD##k zs7?UY&DsjmrW&<{by#k?Z}qzU#0ht>C9AY$A7T~cR(Q;5##rq*Ev&3_tl6Ap$%Q3H z@R)TxbW3zvkb2kcr_4;PL2YXEZ9K-91#YzL)?*F3i5Io)75TDk+cu`n@1=pCY}wml zZo}nX%)IG#$uMHM-TLKc*BYBou2n4Yd}RqA$V{IV^k3y_z)Jld0f|#o}0Q89jGk)T!b17>k*)t!&VP#hHP- z@5igH>G75aAIm#66UEiE=^{<7HtW`rZpHhiOc!}Ss8eif;t$wrXnr1f`yOcbJER^HNPSnLG zqM@jtR>$9mMl7q7nP7V=UUfo5u`CK4RS7F~D*B6Jn%B}wUsfD(2+9K&M{iVQpdsFG z%7T-fKy^wvY9f}lW!I@)>1eY)Qj-Re<#IgwZEm%2zP2kToJan?@NL4mRq-BG(z0e_ zg;cE+{u6beBrCFXx~Lr<4ruXAx>b4*-I95SuLy%E#J7baCF>KP4B6*zrK5ach@1w= y7Y)lZzSHs$2T2@m0h;c{~0u{})y From 8a654dbbcc9d6505d781f0b55acfd5a0b16bd65d Mon Sep 17 00:00:00 2001 From: DanRyanIrish Date: Fri, 29 Nov 2024 10:36:01 +0000 Subject: [PATCH 4/7] Apply some bugs found in code review. --- xrayvision/coordinates/frames.py | 20 ++++++++++---------- xrayvision/coordinates/tests/test_frames.py | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/xrayvision/coordinates/frames.py b/xrayvision/coordinates/frames.py index bc10b66..af9add4 100644 --- a/xrayvision/coordinates/frames.py +++ b/xrayvision/coordinates/frames.py @@ -8,24 +8,24 @@ __all__ = ["Projective"] -X_CTYPE = "PJLN-TAN" -Y_CTYPE = "PJLT-TAN" +X_CTYPE = "PJLN" +Y_CTYPE = "PJLT" class Projective(SunPyBaseCoordinateFrame): - """A generic projective coordinate frame for a imaging taken by an arbitrary imager.""" + """A generic projective coordinate frame for an image taken by an arbitrary imager.""" observer = ObserverCoordinateAttribute(HeliographicStonyhurst) rsun = astropy.coordinates.QuantityAttribute(default=_RSUN, unit=u.km) frame_specific_representation_info = { astropy.coordinates.SphericalRepresentation: [ - astropy.coordinates.RepresentationMapping("lon", "Tx", u.arcsec), - astropy.coordinates.RepresentationMapping("lat", "Ty", u.arcsec), + astropy.coordinates.RepresentationMapping("lon", u.arcsec), + astropy.coordinates.RepresentationMapping("lat", u.arcsec), astropy.coordinates.RepresentationMapping("distance", "distance"), ], astropy.coordinates.UnitSphericalRepresentation: [ - astropy.coordinates.RepresentationMapping("lon", "Tx", u.arcsec), - astropy.coordinates.RepresentationMapping("lat", "Ty", u.arcsec), + astropy.coordinates.RepresentationMapping("lon", u.arcsec), + astropy.coordinates.RepresentationMapping("lat", u.arcsec), ], } @@ -113,8 +113,8 @@ def projective_frame_to_wcs(frame, projection="TAN"): astropy.wcs.utils.FRAME_WCS_MAPPINGS.insert(1, [projective_frame_to_wcs]) PROJECTIVE_CTYPE_TO_UCD1 = { - "SXLT": "custom:pos.projective.lat", - "SXLN": "custom:pos.projective.lon", - "SXRZ": "custom:pos.projective.z", + "PJLT": "custom:pos.projective.lat", + "PJLN": "custom:pos.projective.lon", + "PJRZ": "custom:pos.projective.z", } astropy.wcs.wcsapi.fitswcs.CTYPE_TO_UCD1.update(PROJECTIVE_CTYPE_TO_UCD1) diff --git a/xrayvision/coordinates/tests/test_frames.py b/xrayvision/coordinates/tests/test_frames.py index 81c89d1..38dbebd 100644 --- a/xrayvision/coordinates/tests/test_frames.py +++ b/xrayvision/coordinates/tests/test_frames.py @@ -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-TAN", "PJLT-TAN"] + w.wcs.ctype = ["PJLN", "PJLT"] w.wcs.aux.hgln_obs = 10 w.wcs.aux.hglt_obs = 20 @@ -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-TAN" + assert wcs.wcs.ctype[0] == "PJLN" assert wcs.wcs.cunit[0] == "arcsec" assert wcs.wcs.dateobs == "2024-01-01 00:00:00.000" From f7ee6ccdd82d05c42586a4c80d0f2f759a73e4c7 Mon Sep 17 00:00:00 2001 From: DanRyanIrish Date: Tue, 3 Dec 2024 15:44:29 +0000 Subject: [PATCH 5/7] Changes from code review. --- xrayvision/coordinates/frames.py | 10 +++++++--- xrayvision/coordinates/tests/test_frames.py | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/xrayvision/coordinates/frames.py b/xrayvision/coordinates/frames.py index af9add4..3dc1393 100644 --- a/xrayvision/coordinates/frames.py +++ b/xrayvision/coordinates/frames.py @@ -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) @@ -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 diff --git a/xrayvision/coordinates/tests/test_frames.py b/xrayvision/coordinates/tests/test_frames.py index 38dbebd..81c89d1 100644 --- a/xrayvision/coordinates/tests/test_frames.py +++ b/xrayvision/coordinates/tests/test_frames.py @@ -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 @@ -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" From 36bb8473b94cfd2c95b1c6db0cb2762e9f54c742 Mon Sep 17 00:00:00 2001 From: DanRyanIrish Date: Tue, 3 Dec 2024 16:59:53 +0000 Subject: [PATCH 6/7] Fix minor bug in last commit. --- xrayvision/coordinates/frames.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xrayvision/coordinates/frames.py b/xrayvision/coordinates/frames.py index 3dc1393..bc3e860 100644 --- a/xrayvision/coordinates/frames.py +++ b/xrayvision/coordinates/frames.py @@ -47,7 +47,7 @@ def projective_wcs_to_frame(wcs): return wcs.coordinate_frame # Not a lat,lon coordinate system bail out early - if set(wcs.wcs.ctype) != {X_CTYPE, Y_CTYPE}: + if X_CTYPE not in wcs.wcs.ctype[0] or Y_CTYPE not in wcs.wcs.ctype[1]: return None dateavg = wcs.wcs.dateobs From 95bdde779ab2ec10918a40c76595202520144865 Mon Sep 17 00:00:00 2001 From: DanRyanIrish Date: Tue, 3 Dec 2024 17:28:38 +0000 Subject: [PATCH 7/7] Change lat/lon names in Projective back to Ty/Tx. Without Ty/Tx, it causes conflicts when using STIXImaging. THerefore getting changing from Ty/Tx to lat/lon is a bigger change then shiould be done here. --- xrayvision/coordinates/frames.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xrayvision/coordinates/frames.py b/xrayvision/coordinates/frames.py index bc3e860..2db23d5 100644 --- a/xrayvision/coordinates/frames.py +++ b/xrayvision/coordinates/frames.py @@ -19,13 +19,13 @@ class Projective(SunPyBaseCoordinateFrame): rsun = astropy.coordinates.QuantityAttribute(default=_RSUN, unit=u.km) frame_specific_representation_info = { astropy.coordinates.SphericalRepresentation: [ - astropy.coordinates.RepresentationMapping("lon", u.arcsec), - astropy.coordinates.RepresentationMapping("lat", u.arcsec), + astropy.coordinates.RepresentationMapping("lon", "Tx", u.arcsec), + astropy.coordinates.RepresentationMapping("lat", "Ty", u.arcsec), astropy.coordinates.RepresentationMapping("distance", "distance"), ], astropy.coordinates.UnitSphericalRepresentation: [ - astropy.coordinates.RepresentationMapping("lon", u.arcsec), - astropy.coordinates.RepresentationMapping("lat", u.arcsec), + astropy.coordinates.RepresentationMapping("lon", "Tx", u.arcsec), + astropy.coordinates.RepresentationMapping("lat", "Ty", u.arcsec), ], }