2121
2222
2323def random_orbit (
24- i : Optional [float ] = 45.0 ,
25- alt : float = 500 ,
26- r_body : float = 6371 ,
24+ i : Optional [float ] = None ,
25+ a : Optional [float ] = 6371 + 500 ,
2726 e : float = 0 ,
2827 Omega : Optional [float ] = None ,
29- omega : Optional [float ] = 0 ,
28+ omega : Optional [float ] = None ,
3029 f : Optional [float ] = None ,
30+ alt : float = None ,
31+ r_body : float = 6371 ,
3132) -> ClassicElements :
3233 """Create a set of orbit elements.
3334
3435 Parameters are fixed if specified and randomized if ``None``. Defaults to a random
35- circular orbit at 500 km altitude and 45 deg inclination .
36+ circular orbit at 500 km altitude.
3637
3738 Args:
3839 i: [deg] Inclination, randomized in ``[-pi, pi]``.
39- alt: [km] Altitude above r_body.
40- r_body: [km] Body radius.
40+ a: [km] Semi-major axis.
4141 e: Eccentricity.
4242 Omega: [deg] LAN, randomized in ``[0, 2pi]``.
4343 omega: [deg] Argument of periapsis, randomized in ``[0, 2pi]``.
4444 f: [deg] True anomaly, randomized in ``[0, 2pi]``.
45+ alt: [km] (deprecated) Altitude above r_body.
46+ r_body: [km] (deprecated) Body radius.
4547
4648 Returns:
4749 ClassicElements: orbital elements
4850 """
51+ if alt is not None :
52+ logger .warning (
53+ "Ignoring a, e, and omega and using alt and r_body to generate a circular orbit."
54+ "random_circular_orbit is preferred for this use case."
55+ )
56+ return random_circular_orbit (
57+ i = i ,
58+ alt = alt ,
59+ r_body = r_body ,
60+ Omega = Omega ,
61+ f = f ,
62+ )
63+
4964 oe = ClassicElements ()
50- oe .a = ( r_body + alt ) * 1e3
65+ oe .a = a * 1e3
5166 oe .e = e
5267 oe .i = np .radians (i ) if i is not None else np .random .uniform (- np .pi , np .pi )
5368 oe .Omega = (
@@ -60,6 +75,32 @@ def random_orbit(
6075 return oe
6176
6277
78+ def random_circular_orbit (
79+ i : Optional [float ] = None ,
80+ alt : float = 500 ,
81+ r_body : float = 6371 ,
82+ Omega : Optional [float ] = None ,
83+ f : Optional [float ] = None ,
84+ ):
85+ """Create a set of orbit elements for a circular orbit.
86+
87+ Parameters are fixed if specified and randomized if ``None``.
88+
89+ Args:
90+ i: [deg] Inclination, randomized in ``[-pi, pi]``.
91+ alt: [km] Altitude above r_body.
92+ r_body: [km] Body radius, defaults to Earth's radius.
93+ Omega: [deg] LAN, randomized in ``[0, 2pi]``.
94+ f: [deg] True anomaly, randomized in ``[0, 2pi]``.
95+
96+ """
97+ omega = 0
98+ e = 0
99+ a = r_body + alt
100+
101+ return random_orbit (i = i , a = a , e = e , Omega = Omega , omega = omega , f = f )
102+
103+
63104def random_epoch (start : int = 2000 , end : int = 2022 ):
64105 """Generate a random epoch in a year range.
65106
@@ -616,6 +657,7 @@ def hill2cd(
616657__doc_title__ = "Orbital"
617658__all__ = [
618659 "random_orbit" ,
660+ "random_circular_orbit" ,
619661 "random_epoch" ,
620662 "lla2ecef" ,
621663 "elevation" ,
0 commit comments