Skip to content

Commit 94cb3ed

Browse files
committed
Edited docstrings as per convention
1 parent 1770e19 commit 94cb3ed

File tree

2 files changed

+34
-18
lines changed

2 files changed

+34
-18
lines changed

gs/backend/positioning/sgp4_handler.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@
2121

2222
@dataclass
2323
class SGP4Data:
24-
"""Data structure representing the satellite's position and velocity."""
24+
"""
25+
Data structure representing the satellite's position and velocity.
26+
:param position_km: tuple representing the position of the satellite in km
27+
:param velocity_km_sec: tuple representing velocity of the satellite in km/second
28+
29+
30+
"""
2531

2632
position_km: tuple[float, float, float]
2733
velocity_km_sec: tuple[float, float, float]
@@ -31,6 +37,10 @@ def setup_sgp4(tle: TLEData) -> Satrec:
3137
"""
3238
Initialize the SGP4 satellite model using TLE data. Formatting and SGP4 initialization pulled from link below
3339
https://pypi.org/project/sgp4/
40+
41+
:warning: currently broken for TLEs where eccentricity is low relative to drag term
42+
:param tle(TLEData): The TLE string used to initialize Satrec
43+
:return: Returns initialized Satrec
3444
"""
3545

3646

@@ -94,18 +104,17 @@ def get_sat_position(tle: TLEData, dt: datetime) -> SGP4Data:
94104
"""
95105
Compute the satellite's position and velocity at a given time.
96106
97-
Arguments are
98-
tle(TLEData): Two-line element set representing the satellite.
99-
dt(datetime): The timestamp for which to calculate the position.
100-
107+
:warning: currently broken for TLEs where eccentricity is low relative to drag term
108+
109+
:param tle(TLEData): Two-line element set representing the satellite.
110+
:param dt(datetime): The timestamp for which to calculate the position.
111+
:return: Returns location data with custom SGP4Data object
101112
"""
113+
102114
sat = setup_sgp4(tle)
103115
jd, fr = jday(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second)
104116
error_code, position, velocity = sat.sgp4(jd, fr)
105117

106-
#print("eccentricity (parsed):", tle.eccentricity)
107-
108-
109118
if 0.0 <= tle.eccentricity and tle.eccentricity <= 1.0:
110119
print("tle.eccentricity within expected bounds")
111120

gs/backend/positioning/tle.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,16 @@ def to_tle(self) -> str:
6363
)
6464
first_line += str(calculate_checksum(first_line))
6565
second_line += str(calculate_checksum(second_line))
66-
#print("hi!")
67-
#print(f"{first_line}\n{second_line}")
6866
return f"{first_line}\n{second_line}"
6967

7068
def format_epoch_to_date(self, epoch_year: int, epoch_day: float) -> str:
7169
"""
72-
Convert epoch year and day-of-year to a calendar date (YYYY-MM-DD).
70+
Convert epoch year and day-of-year to a calendar date (YYYY-MM-DD).
7371
74-
Arguments:
75-
epoch_year (int): Last two digits of the epoch year.
76-
epoch_day (float): Day of the year, including fraction.
72+
:param epoch_year (int): Last two digits of the epoch year.
73+
:param epoch_day (float): Day of the year, including fraction.
7774
78-
Returns:
79-
str: Formatted date string in YYYY-MM-DD format.
75+
:return: Returns formatted date string in YYYY-MM-DD format as a string.
8076
"""
8177
full_year = 2000 + epoch_year if epoch_year < 57 else 1900 + epoch_year
8278
base_date = datetime(full_year, 1, 1) + timedelta(days=epoch_day - 1)
@@ -90,7 +86,13 @@ def convert_epoch_values_to_jd(self) -> float:
9086

9187

9288
def calculate_checksum(line: str) -> int:
93-
"""Calculate the checksum for a line of TLE data."""
89+
"""
90+
Calculate the checksum for a line of TLE data.
91+
92+
:param line(str): The single line of TLE data to calculate the checksum for
93+
:return: Returns the checksum integer
94+
95+
"""
9496
output = 0
9597
for i in line[:68]:
9698
if i.isdigit():
@@ -101,7 +103,12 @@ def calculate_checksum(line: str) -> int:
101103

102104

103105
def convert_decimal_point_assumed(value: str) -> float:
104-
"""Convert a string to a float, assuming a decimal point before the last digit."""
106+
"""
107+
Convert a string to a float, assuming a decimal point before the last digit.
108+
109+
:param value(str): the string to convert
110+
:returns: data from string converted into float
111+
"""
105112
return float(f"{value[0]}.{value[1:6]}e{value[6:]}")
106113

107114

0 commit comments

Comments
 (0)