LIGOTimeGPS
raw JSON → 2.1.0 verified Fri May 01 auth: no python
A pure Python implementation of LIGOTimeGPS, used for converting between LIGO time (GPS seconds) and standard time formats. Current version is 2.1.0, requiring Python >=3.11. Released irregularly with minor version bumps.
pip install ligotimegps Common errors
error AttributeError: module 'ligotimegps' has no attribute 'LIGOTimeGPS' ↓
cause Multiple installs or importing from wrong path after an incomplete import.
fix
Run 'pip show ligotimegps' to verify installation. Import using 'from ligotimegps import LIGOTimeGPS'.
error TypeError: 'LIGOTimeGPS' object cannot be interpreted as an integer ↓
cause Trying to use LIGOTimeGPS directly in functions expecting an integer, like range() or indexing.
fix
Convert to int or float: int(t.gpsSeconds) or float(t).
error ValueError: invalid format for LIGOTimeGPS: '1234567890.0' ↓
cause Passing a float string to LIGOTimeGPS. The constructor does not parse strings.
fix
Use LIGOTimeGPS.from_float(1234567890.0) or parse the string yourself.
Warnings
gotcha The constructor accepts two integers (seconds, nanoseconds), but nanoseconds can be negative. This can cause confusion when converting from other time representations. ↓
fix Ensure nanoseconds are normalized (0 <= ns < 1e9) before passing to the constructor, or use the from_float method.
deprecated Arithmetic operations like +, -, <, > are supported, but there is no official documentation for edge cases (e.g., overflow). Relying on undocumented behavior may break in future versions. ↓
fix Use explicit conversion to float for comparisons and arithmetic.
breaking The ability to compare LIGOTimeGPS with integers/floats directly may be removed. In version 2.x, this works implicitly, but future versions might require explicit conversion. ↓
fix Always convert to float for comparisons: float(t) > 1e9.
Imports
- LIGOTimeGPS wrong
from ligotimegps.ligotimegps import LIGOTimeGPScorrectfrom ligotimegps import LIGOTimeGPS
Quickstart
from ligotimegps import LIGOTimeGPS
t = LIGOTimeGPS(1234567890, 0)
print(t)
print(float(t))
print(t.gpsSeconds, t.gpsNanoSeconds)