Skip to content

Commit 422bb51

Browse files
MNT: add tolerance as an attribute of get_solution
1 parent f4025ec commit 422bb51

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

rocketpy/simulation/flight.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,7 +1934,7 @@ def time(self):
19341934
"""Returns time array from solution."""
19351935
return self.solution_array[:, 0]
19361936

1937-
def get_solution_at_time(self, t):
1937+
def get_solution_at_time(self, t, atol=1e-3):
19381938
"""Returns the solution state vector at a given time. If the time is
19391939
not found in the solution, the closest time is used and a warning is
19401940
raised.
@@ -1943,6 +1943,10 @@ def get_solution_at_time(self, t):
19431943
----------
19441944
t : float
19451945
Time in seconds.
1946+
atol : float, optional
1947+
Absolute tolerance for time comparison. Default is 1e-3. If the
1948+
difference between the time and the closest time in the solution
1949+
is greater than this value, a warning is raised.
19461950
19471951
Returns
19481952
-------
@@ -1953,7 +1957,7 @@ def get_solution_at_time(self, t):
19531957
19541958
"""
19551959
time_index = find_closest(self.time, t)
1956-
if abs(self.time[time_index] - t) > 1e-5:
1960+
if abs(self.time[time_index] - t) > atol:
19571961
warnings.warn(
19581962
f"Time {t} not found in solution. Closest time is "
19591963
f"{self.time[time_index]}. Using closest time.",

0 commit comments

Comments
 (0)