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
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6b1fae52b177da97293e16488c3aaebe37df7e66814afbf3abaadc90af90e30
|
|
| MD5 |
f422b4f58227c706725df262282a0dea
|
|
| BLAKE2b-256 |
8a4e862eb591b89141f4bb930628da2f84d82b5e8d28984c6e46e0337c7ff750
|
Provenance
The following attestation bundles were made for gps_time-3.0.0.tar.gz:
Publisher:
publish.yaml on the-aerospace-corporation/gps_time
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gps_time-3.0.0.tar.gz -
Subject digest:
f6b1fae52b177da97293e16488c3aaebe37df7e66814afbf3abaadc90af90e30 - Sigstore transparency entry: 768269787
- Sigstore integration time:
-
Permalink:
the-aerospace-corporation/gps_time@5225e1c5441c909396d70afef46a1ac02af41048 -
Branch / Tag:
refs/tags/3.0.0 - Owner: https://github.com/the-aerospace-corporation
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@5225e1c5441c909396d70afef46a1ac02af41048 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
004a0870a8b5ea90c8da0b533d58d9cb49b2fc9ce903da55d41f2794e3fc4d67
|
|
| MD5 |
a1f332543d307c8e9620e6720fffb200
|
|
| BLAKE2b-256 |
d5c7edcdfad933791e4add24533a74f089945173111a1d88ec3e569605e0ef0c
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gps_time-3.0.0-py3-none-any.whl -
Subject digest:
004a0870a8b5ea90c8da0b533d58d9cb49b2fc9ce903da55d41f2794e3fc4d67 - Sigstore transparency entry: 768269799
- Sigstore integration time:
-
Permalink:
the-aerospace-corporation/gps_time@5225e1c5441c909396d70afef46a1ac02af41048 -
Branch / Tag:
refs/tags/3.0.0 - Owner: https://github.com/the-aerospace-corporation
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@5225e1c5441c909396d70afef46a1ac02af41048 -
Trigger Event:
release
-
Statement type: