Skip to main content

This module is used to represent GPS time and provide tools for handling it. It is an alternative to the python built-in datetime module that is easier to use for scientific computing.

Project description

gps_time

CI PyPI PyPI - Python Version PyPI - License Code style: black Coverage

This file will become your README and also the index of your documentation.

Breaking Change

Prior to version 3.x, gps_time did not include any timezone information, i.e. all datetimes used by gps_time were “naive”. This could lead to errors for versions of python that default to “aware” datetime objects. In version 3, gps_time is updated to function using aware datetime objects. If you pass gps_time a naive datetime, it will assume that it is meant to represent UTC time. As this was the expected behavior, there should be minimal impact, but this may result in errors to existing code bases.

Install

Installation can be achieved using pip, specifically

pip install gps_time

How to use

This module is relatively straightfoward to use. The GPSTime objects are generated (using arbitrary numbers) by

gps_time1 = GPSTime(week_number=1872, time_of_week=3324.654324324234324)
gps_time2 = GPSTime(week_number=1875, time_of_week=9890874.32)
2

Notice that the time of week for gps_time2 is longer than a week. The GPSTime object will automatically adjust the week number and time of week to reasonable values.

print(gps_time2)

Conversion

The GPSTime objects can also created from datetime.datetime objects

gps_time3 = GPSTime.from_datetime(datetime.datetime(2017, 9, 2, 13, 23, 12, 211423)) print(gps_time3)

GPSTime can likewise be converted to datetime.datetime object. However, one must be careful because datetime.datetime objects only preserve microsecond resolution. Converting from GPSTime to datetime.datetime can lose information. The opposite conversion does not lose information.

print(f"GPS Time: {gps_time1}")
print(f"Datetime: {gps_time1.to_datetime()}")
print("")
print(f"Lost Precision: {gps_time1 - GPSTime.from_datetime(gps_time1.to_datetime())}")

Operators

GPSTime has comparison operators defined (equality, less than, etc.). It also has addition and subtraction defined. In general, one can add/subtract either floats or other GPSTimes.

For floats, it is interpreted as a time shift in seconds (forward for addition, backward for subtraction). This operation accounts for the time of week. In-place addition and subtraction, i.e. the += and -= operators are supported for floats.

time_shift_seconds = 23431123.3243

print(f"Addition (float):    {gps_time2 + time_shift_seconds}")
print(f"Subtraction (float): {gps_time2 - time_shift_seconds}")

Alternatively, addition and subtraction can be done using two GPSTime objects. Subtraction finds the time difference in seconds (as a float). Addition essentially sums the week numbers and times of week. Notice that in-place addition and subtraction are not supported for two GPSTime objects.

print(f"Addition (GPSTime):    {gps_time2 + gps_time1}")
print(f"Subtraction (GPSTime): {gps_time2 - gps_time1}")

License

Copyright (2020) The Aerospace Corporation. All Rights Reserved

The gps_time module releasded under the Apache2 license.

Open Source Licenses

This module is built on the nbdev template, which is used under the Apache2 license.

Formatting

As much as possible for jupyter notebooks, the black formatting standard will be used. To apply black to jupyter notebooks, the jupyter-black extension can be used.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gps_time-3.0.0.tar.gz (23.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gps_time-3.0.0-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

Details for the file gps_time-3.0.0.tar.gz.

File metadata

  • Download URL: gps_time-3.0.0.tar.gz
  • Upload date:
  • Size: 23.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for gps_time-3.0.0.tar.gz
Algorithm Hash digest
SHA256 f6b1fae52b177da97293e16488c3aaebe37df7e66814afbf3abaadc90af90e30
MD5 f422b4f58227c706725df262282a0dea
BLAKE2b-256 8a4e862eb591b89141f4bb930628da2f84d82b5e8d28984c6e46e0337c7ff750

See more details on using hashes here.

Provenance

The following attestation bundles were made for gps_time-3.0.0.tar.gz:

Publisher: publish.yaml on the-aerospace-corporation/gps_time

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gps_time-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: gps_time-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 24.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for gps_time-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 004a0870a8b5ea90c8da0b533d58d9cb49b2fc9ce903da55d41f2794e3fc4d67
MD5 a1f332543d307c8e9620e6720fffb200
BLAKE2b-256 d5c7edcdfad933791e4add24533a74f089945173111a1d88ec3e569605e0ef0c

See more details on using hashes here.

Provenance

The following attestation bundles were made for gps_time-3.0.0-py3-none-any.whl:

Publisher: publish.yaml on the-aerospace-corporation/gps_time

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page