diff --git a/ssapy/utils.py b/ssapy/utils.py index f7eaccd..35e8194 100644 --- a/ssapy/utils.py +++ b/ssapy/utils.py @@ -1978,27 +1978,26 @@ def dd_to_hms(degree_decimal): return f'{int(_h)}:{int(_m)}:{_s}' -def get_times(duration, freq, t): +def get_times(duration: Tuple[int, str], freq: Tuple[int, str], t0: Union[str, Time] = "2025-01-01") -> np.ndarray: """ Calculate a list of times spaced equally apart over a specified duration. Parameters ---------- - duration: int - The length of time to calculate times for. - freq: int, unit: str - frequency of time outputs in units provided - t: ssapy.utils.Time, optional + duration : tuple + A tuple containing the length of time and the unit (e.g., (30, 'day')). + freq : tuple + A tuple containing the frequency value and its unit (e.g., (1, 'hr')). + t0 : str or Time, optional The starting time. Default is "2025-01-01". - example input: - duration=(30, 'day'), freq=(1, 'hr'), t=Time("2025-01-01", scale='utc') + Returns ------- - times: array-like + np.ndarray A list of times spaced equally apart over the specified duration. """ - if isinstance(t, str): - t = Time(t, scale='utc') + if isinstance(t0, str): + t0 = Time(t0, scale='utc') unit_dict = {'second': 1, 'sec': 1, 's': 1, 'minute': 60, 'min': 60, 'hour': 3600, 'hr': 3600, 'h': 3600, 'day': 86400, 'd': 86400, 'week': 604800, 'month': 2630016, 'mo': 2630016, 'year': 31557600, 'yr': 31557600} dur_val, dur_unit = duration freq_val, freq_unit = freq @@ -2014,7 +2013,7 @@ def get_times(duration, freq, t): freq_seconds = freq_val * unit_dict[freq_unit.lower()] timesteps = int(dur_seconds / freq_seconds) + 1 - times = t + np.linspace(0, dur_seconds, timesteps) / unit_dict['day'] * u.day + times = t0 + np.linspace(0, dur_seconds, timesteps) / unit_dict['day'] * u.day return times @@ -2149,4 +2148,4 @@ def points_on_circle(r, v, rad, num_points=4): # Translate the rotated points to the center point r points_rotated = rotated_points + r.reshape(1, 3) - return points_rotated \ No newline at end of file + return points_rotated