Skip to content

replay

calculate_offset

calculate_offset(start, end, t_reference)

Calculate the replay offset based off of a reference time.

Parameters:

Name Type Description Default
start int

Start time (GPS nanoseconds) of the replay window.

required
end int

End time (GPS nanoseconds) of the replay window.

required
t_reference float

Reference time to calculate the offset for.

required

Returns:

Type Description
float

The replay offset.

Source code in arrakis/replay.py
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
def calculate_offset(start: int, end: int, t_reference: float) -> float:
    """Calculate the replay offset based off of a reference time.

    Parameters
    ----------
    start : int
        Start time (GPS nanoseconds) of the replay window.
    end : int
        End time (GPS nanoseconds) of the replay window.
    t_reference : float
        Reference time to calculate the offset for.

    Returns
    -------
    float
        The replay offset.

    """
    duration = end - start
    num_replays = math.floor((t_reference - start) / duration)
    return num_replays * duration

translate_time

translate_time(t, start, end)

Map a reference time into a replay window.

Parameters:

Name Type Description Default
t int or None

GPS time in nanoseconds. If None, uses the current time.

required
start int

Start time (GPS nanoseconds) of the replay window.

required
end int

End time (GPS nanoseconds) of the replay window.

required

Returns:

Type Description
int

The corresponding archival GPS time within the replay window.

Source code in arrakis/replay.py
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
def translate_time(t: int | None, start: int, end: int) -> int:
    """Map a reference time into a replay window.

    Parameters
    ----------
    t : int or None
        GPS time in nanoseconds. If None, uses the current time.
    start : int
        Start time (GPS nanoseconds) of the replay window.
    end : int
        End time (GPS nanoseconds) of the replay window.

    Returns
    -------
    int
        The corresponding archival GPS time within the replay window.

    """
    if t is None:
        t = int(gpstime.gpsnow()) * Time.SECONDS
    offset = calculate_offset(start, end, t)
    return int(t - offset)