Skip to content

Commit 700e51c

Browse files
committed
💥 boom(astro): move space frames to coordinax_astro
Signed-off-by: Nathaniel Starkman <[email protected]>
1 parent c448fff commit 700e51c

File tree

27 files changed

+259
-222
lines changed

27 files changed

+259
-222
lines changed

‎docs/guides/coordinates_and_frames.md‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,29 @@ frame metadata to your data.
77

88
## Built-in Frames
99

10-
{mod}`coordinax.frames` includes several standard astronomical frames:
10+
`coordinax.frames` includes several standard frames:
1111

1212
```{code-block} python
1313
>>> import coordinax.frames as cxf
14-
>>> icrs = cxf.ICRS()
14+
15+
>>> alice = cxf.Alice()
16+
>>> alice
17+
Alice()
18+
19+
>>> bob = cxf.Bob()
20+
>>> bob
21+
Bob()
22+
```
23+
24+
`coordinax_astro` includes several standard astronomical frames:
25+
26+
```{code-block} python
27+
>>> from coordinax_astro import ICRS, Galactocentric
28+
>>> icrs = ICRS()
1529
>>> icrs
1630
ICRS()
1731
18-
>>> gc = cxf.Galactocentric()
32+
>>> gc = Galactocentric()
1933
>>> gc
2034
Galactocentric(
2135
galcen=LonLatSphericalPos(...),
Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,30 @@
1-
"""Coordinax for Astronomy."""
1+
"""Coordinax for Astronomy.
22
3-
__all__ = [
4-
"FourVector",
5-
]
3+
>>> import unxt as u
4+
>>> import coordinax as cx
5+
>>> import coordinax_astro as cxa
66
7-
from ._src import FourVector
7+
>>> icrs = cxa.ICRS()
8+
>>> gcf = cxa.Galactocentric()
9+
10+
>>> op = cx.frames.frame_transform_op(icrs, gcf)
11+
>>> op
12+
Pipe(( ... ))
13+
14+
>>> q = cx.vecs.CartesianPos3D.from_([1, 2, 3], "kpc")
15+
>>> print(op(q))
16+
<CartesianPos3D: (x, y, z) [kpc]
17+
[-11.375 1.845 0.133]>
18+
19+
"""
20+
21+
__all__ = ["FourVector", "AbstractSpaceFrame", "ICRS", "Galactocentric"]
22+
23+
from ._src import ICRS, AbstractSpaceFrame, FourVector, Galactocentric
24+
25+
# Interoperability. Importing this module will register interop frameworks.
26+
# isort: split
27+
from . import _interop
28+
29+
# clean up namespace
30+
del _interop
File renamed without changes.

src/coordinax/_coordinax_space_frames/_interop/interop_astropy/frames.py renamed to packages/coordinax-astro/src/coordinax_astro/_interop/interop_astropy.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
import astropy.coordinates as apyc
66
import equinox as eqx
77

8-
from coordinax._coordinax_space_frames import ICRS, Galactocentric
8+
from coordinax_astro._src.frames import ICRS, Galactocentric
9+
910
from coordinax._src.frames.base import AbstractReferenceFrame
1011
from coordinax._src.vectors.d3 import LonLatSphericalPos
1112

@@ -17,10 +18,10 @@ def from_(cls: type[ICRS], obj: apyc.ICRS, /) -> ICRS:
1718
Examples
1819
--------
1920
>>> import astropy.coordinates as apyc
20-
>>> import coordinax.frames as cxf
21+
>>> from coordinax_astro import ICRS
2122
2223
>>> apy_icrs = apyc.ICRS()
23-
>>> cxf.ICRS.from_(apy_icrs)
24+
>>> ICRS.from_(apy_icrs)
2425
ICRS()
2526
2627
"""
@@ -35,14 +36,14 @@ def from_(cls: type[Galactocentric], obj: apyc.Galactocentric, /) -> Galactocent
3536
Examples
3637
--------
3738
>>> import astropy.coordinates as apyc
38-
>>> import coordinax.frames as cxf
39+
>>> from coordinax_astro import Galactocentric
3940
4041
>>> apy_gcf = apyc.Galactocentric()
4142
>>> apy_gcf
4243
<Galactocentric Frame (galcen_coord=<ICRS Coordinate: (ra, dec) in deg
4344
(266.4051, -28.936175)>, galcen_distance=8.122 kpc, galcen_v_sun=(12.9, 245.6, 7.78) km / s, z_sun=20.8 pc, roll=0.0 deg)>
4445
45-
>>> gcf = cxf.Galactocentric.from_(apy_gcf)
46+
>>> gcf = Galactocentric.from_(apy_gcf)
4647
>>> gcf
4748
Galactocentric(
4849
galcen=LonLatSphericalPos( ... ),
@@ -58,7 +59,6 @@ def from_(cls: type[Galactocentric], obj: apyc.Galactocentric, /) -> Galactocent
5859
... and gcf.galcen.distance.ustrip("kpc") == apy_gcf.galcen_distance.to_value("kpc") )
5960
Array(True, dtype=bool)
6061
61-
6262
""" # noqa: E501
6363
obj = eqx.error_if(obj, obj.has_data, "Astropy frame must not have data.")
6464
galcen = LonLatSphericalPos(
File renamed without changes.
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
"""Frames for Astronomy."""
1+
"""Coordinax for Astronomy."""
22

3-
__all__ = [
4-
"FourVector",
5-
]
3+
__all__ = ["FourVector", "AbstractSpaceFrame", "ICRS", "Galactocentric"]
64

5+
from .frames import ICRS, AbstractSpaceFrame, Galactocentric
76
from .vecs import FourVector

src/coordinax/_coordinax_space_frames/__init__.py renamed to packages/coordinax-astro/src/coordinax_astro/_src/frames/__init__.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,3 @@
66
from .frame_transforms import *
77
from .galactocentric import Galactocentric
88
from .icrs import ICRS
9-
10-
# Interoperability. Importing this module will register interop frameworks.
11-
# isort: split
12-
from . import _interop
13-
14-
# clean up namespace
15-
del _interop
File renamed without changes.

src/coordinax/_coordinax_space_frames/frame_transforms.py renamed to packages/coordinax-astro/src/coordinax_astro/_src/frames/frame_transforms.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ def frame_transform_op(
4949
>>> from plum import dispatch
5050
>>> import unxt as u
5151
>>> import coordinax as cx
52+
>>> from coordinax_astro import AbstractSpaceFrame, ICRS, Galactocentric
5253
53-
>>> class MySpaceFrame(cx.frames.AbstractSpaceFrame):
54+
>>> class MySpaceFrame(AbstractSpaceFrame):
5455
... pass
5556
5657
>>> @dispatch
@@ -61,7 +62,7 @@ def frame_transform_op(
6162
we don't have a direct transformation defined:
6263
6364
>>> my_frame = MySpaceFrame()
64-
>>> gcf_frame = cx.frames.Galactocentric()
65+
>>> gcf_frame = Galactocentric()
6566
6667
>>> op = cx.frames.frame_transform_op(my_frame, gcf_frame)
6768
>>> op
@@ -87,8 +88,8 @@ def frame_transform_op(from_frame: ICRS, to_frame: ICRS, /) -> Identity:
8788
Examples
8889
--------
8990
>>> import coordinax.frames as cxf
90-
>>> icrs_frame = cxf.ICRS()
91-
>>> frame_op = cxf.frame_transform_op(icrs_frame, icrs_frame)
91+
>>> alice = cxf.Alice()
92+
>>> frame_op = cxf.frame_transform_op(alice, alice)
9293
>>> frame_op
9394
Identity()
9495
@@ -107,13 +108,14 @@ def frame_transform_op(from_frame: Galactocentric, to_frame: Galactocentric, /)
107108
--------
108109
>>> import unxt as u
109110
>>> import coordinax.frames as cxf
111+
>>> from coordinax_astro import Galactocentric
110112
111-
>>> gcf_frame = cxf.Galactocentric()
113+
>>> gcf_frame = Galactocentric()
112114
>>> frame_op = cxf.frame_transform_op(gcf_frame, gcf_frame)
113115
>>> frame_op
114116
Pipe(Identity())
115117
116-
>>> gcf_frame2 = cxf.Galactocentric(roll=u.Quantity(10, "deg"))
118+
>>> gcf_frame2 = Galactocentric(roll=u.Quantity(10, "deg"))
117119
>>> frame_op2 = cxf.frame_transform_op(gcf_frame, gcf_frame2)
118120
>>> frame_op2
119121
Pipe((
@@ -151,6 +153,7 @@ def frame_transform_op(from_frame: ICRS, to_frame: Galactocentric, /) -> Pipe:
151153
152154
>>> import unxt as u
153155
>>> import coordinax as cx
156+
>>> from coordinax_astro import Galactocentric, ICRS
154157
>>> import astropy.coordinates as apyc
155158
156159
The location of Vega in ICRS coordinates:
@@ -186,8 +189,8 @@ def frame_transform_op(from_frame: ICRS, to_frame: Galactocentric, /) -> Pipe:
186189
>>> vega_q = cx.vecs.LonLatSphericalPos.from_(vega.icrs.data)
187190
>>> vega_p = cx.vecs.LonCosLatSphericalVel.from_(vega.icrs.data.differentials["s"])
188191
189-
>>> icrs_frame = cx.frames.ICRS()
190-
>>> gcf_frame = cx.frames.Galactocentric.from_(apy_gcf)
192+
>>> icrs_frame = ICRS()
193+
>>> gcf_frame = Galactocentric.from_(apy_gcf)
191194
192195
Define the transformation operator:
193196
@@ -277,6 +280,7 @@ def frame_transform_op(from_frame: Galactocentric, to_frame: ICRS, /) -> Pipe:
277280
278281
>>> import unxt as u
279282
>>> import coordinax as cx
283+
>>> from coordinax_astro import Galactocentric, ICRS
280284
>>> import astropy.coordinates as apyc
281285
282286
The location of Vega in Galactocentric coordinates:
@@ -313,8 +317,8 @@ def frame_transform_op(from_frame: Galactocentric, to_frame: ICRS, /) -> Pipe:
313317
>>> vega_q = cx.CartesianPos3D.from_(vega.galactocentric.data)
314318
>>> vega_p = cx.CartesianVel3D.from_(vega.galactocentric.data.differentials["s"])
315319
316-
>>> icrs_frame = cx.frames.ICRS()
317-
>>> gcf_frame = cx.frames.Galactocentric.from_(apy_gcf)
320+
>>> icrs_frame = ICRS()
321+
>>> gcf_frame = Galactocentric.from_(apy_gcf)
318322
319323
Define the transformation operator:
320324

src/coordinax/_coordinax_space_frames/galactocentric.py renamed to packages/coordinax-astro/src/coordinax_astro/_src/frames/galactocentric.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ class Galactocentric(AbstractSpaceFrame):
3030
3131
Examples
3232
--------
33-
>>> import coordinax as cx
34-
>>> frame = cx.frames.Galactocentric()
35-
>>> frame
33+
>>> from coordinax_astro import Galactocentric
34+
>>> Galactocentric()
3635
Galactocentric(
3736
galcen=LonLatSphericalPos( ... ),
3837
roll=Quantity(weak_i32[], unit='deg'),

0 commit comments

Comments
 (0)