Contains the GPSTime class that represents time as GPS

correct_week[source]

correct_week(week_num:int, tow:float, year:int)

Correct the week number for week rollovers.

Provide the mod 1024 week number and update to the actual GPS week based on the year

Parameters

week_num : int The mod 1024 week number tow : float The time of week year : int The year

Returns

int The full GPS week number

Raises

ValueError If the year is not an int ValueError If the week number and year are inconsistent

arange_datetime[source]

arange_datetime(start_datetime:datetime, duration_s:float, step_ms:float)

Create a list of datetimes in sequence.

The purpose of this function is to create a list that represents a sequence of datetimes of the specified duration with the specified step size.

This function is an analogue of the numpy.arange() function, but operates on datetimes.

Parameters

start_gpstime : datetime.datetime The datetime to start the sequence duration_s : float The duration of the sequence, in seconds step_ms : float The step size, in milliseconds

Returns

List[datetime.datetime] The sequence of datetime

Notes

Like numpy.arange, this does not include the final element. That is, if the start is at 0 with a duration of 5 and step of 1, the sequence would return [0, 1, 2, 3, 4]

See Also

numpy.arange() arange_gpstime()

Todo

.. todo:: Determine if this still works if a np.ndarray is returned instead of a list

tow2datetime[source]

tow2datetime(week_num:int, tow:float, year:Optional[int]=None)

Convert GPS Week and Time of Week to datetime.

The purpose of this function is to convert a GPS Week number and a time of week into a DateTime object. The week number represents the number of weeks since 6 January 1980 and the time of week is the number of seconds since midnight Sunday night. Note that the GPS week is sometimes expressed as a mod 1024 week. If this is the case, the Year argument can be used to correct for mod 1024 weeks. If the week number is not consistent with the Year, then an error is raised.

Parameters

week_num : int GPS Week Number (not limited to 1024) tow : float Time of Week (seconds since midnight Sunday Morning) year : Optional[int], optional If not None, used to correct the week_num from mod 1024 week to the actual week number (weeks since 6 Jan 1980), by default None

Returns

datetime.datetime object that represents the current time

datetime2tow[source]

datetime2tow(date_time:datetime)

Convert date time to GPS Week and Time of Week.

The purpose of this function is to convert a datetime object to the GPS week number and the time of week. This returns the full GPS week number. The user must separately compute the mod 1024 week if that is desired.

Parameters

date_time : datetime.datetime A datetime object representing the desired times

Returns

Tuple[int, float] Two elements: 1) The GPS Week Number and 2) the time of week

Raises

TypeError If the input is not a datetime

tow2zcount[source]

tow2zcount(week_num:int, tow:float, year:Optional[int]=None)

Convert a week number and time of week into week and zcount.

The Z-Count is the time of week in seconds divided by 1.5. This function is used to convert from a time of week and week number to z-count.

Parameters

week_num : int The week number tow : float The time of week (seconds) year : Optional[int], optional If not None, adjusts the week number to account for week roll overs. Otherwise, is passed through, by default None

Returns

Tuple[int, float] The week number and z-count

Notes

This function returns floating point z-count. Use another method to cast as int if required

zcount2tow[source]

zcount2tow(week_num:int, zcount:float, year:Optional[int]=None)

Convert a week number and time of week into week and zcount.

The Z-Count is the time of week divided by 1.5. This function is used to convert from a z-count and week number to time of week.

Parameters

week_num : int The week number zcount : float The z-count (1.5 sec epochs) year : Optional[int], optional If not None, adjusts the week number to account for week roll overs. Otherwise, is passed through, by default None

Returns

Tuple[int, float] The week number and time of week

datetime2zcount[source]

datetime2zcount(date_time:datetime)

Convert a datetime to z-count and week number.

This function takes a datetime and returns a week number and z-count. It accomplishes this by first calling datetime2tow() and then tow2zcount().

Parameters

date_time : datetime.datetime The datetime

Returns

Tuple[int, float] The week number and z-count

zcount2datetime[source]

zcount2datetime(week_num:int, zcount:float, year:Optional[int]=None)

Convert a week number and time of week into a datetime.

The Z-Count is the time of week divided by 1.5. This function is used to convert from a z-count and week number to the equivalent datetime. It accomplished this by calling zcount2tow() and then tow2datetime().

Parameters

week_num : int The week number zcount : float The z-count (1.5 sec epochs) year : Optional[int], optional If not None, adjusts the week number to account for week roll overs. Otherwise, is passed through, by default None

Returns

datetime.datetime The datetime representing the zcount