Skip to main content

This module contains functions for converting between Gregorian date, day of year and GNSS calendar, now support GNSS calendar for GPS and BDS.

There are 3 functions for converting between Gregorian date and day of year (doy):

date2doy(date)
date2yrdoy(date)
yrdoy2date(year, doy)

Using them like:

>>> from datetime import date

>>> date2doy(date(2017, 5, 17))
137

>>> date2yrdoy(date(2017, 5, 17))
(2017, 137)

>>> yrdoy2date(2017, 137)
datetime.date(2017, 5, 17)

There are 4 functions for converting between Gregorian date and GNSS calendars (GPS or BDS):

date2gpswd(date)
date2bdswd(date)
gpswd2date(gpsweek, dayofweek)
bdswd2date(bdsweek, dayofweek)

Using them like:

>>> from datetime import date

>>> date2gpswd(date(2017, 5, 17))
(1949, 3)

>>> date2bdswd(date(2017, 5, 17))
(593, 3)

>>> gpswd2date(1949, 3)
datetime.date(2017, 5, 17)

>>> bdswd2date(593, 3)
datetime.date(2017, 5, 17)

There are 4 functions for converting between year, day of year (doy) and GNSS calendars (GPS or BDS):

yrdoy2gpswd(year, doy)
yrdoy2bdswd(year, doy)
gpswd2yrdoy(gpsweek, dayofweek)
bdswd2yrdoy(bdsweek, dayofweek)

Using them like:

>>> yrdoy2gpswd(2017, 137)
(1949, 3)

>>> yrdoy2bdswd(2017, 137)
(593, 3)

>>> gpswd2yrdoy(1949, 3)
(2017, 137)

>>> bdswd2yrdoy(593, 3)
(2017, 137)

There are also 2 functions for converting between GPS calendar and BDS calendar:

gpsw2bdsw(gpsweek)
bdsw2gpsw(bdsweek)

Using them like:

>>> gpsw2bdsw(1949)
593

>>> bdsw2gpsw(593)
1949

Where the type of date is datetime.date and others are int or tuple of int.

Zero point of GPS and BDS are also given as module level constains in Gregorian date.

Examples

import gnsscal
from datetime import date

# Convert Gregorian date to GPS calendar
today = date.today()
gpsweek, days = gnsscal.date2gpswd(today)

# Convert GPS week to BDS week
gpsweek = 1812
bdsweek = gnsscal.gpsw2bdsw(gpsweek)

# Get zero point of GPS and BDS calendar
gps_zero = gnsscal.GPS_START_DATE
bds_zero = gnsscal.BDS_START_DATE

CLI mode

You can also using gnsscal in CLI mode:

$ python -m gnsscal [options]

Set input date using the optional arguments:

-h, --help                          show this help message and exit
-v, --version                       show program's version number and exit
-date <year> <month> <day>          year, month, day
-ydoy <year> <doy>                  year, day of year
-gpswd <GPS week> <day of week>     GPS week, day of week
-bdswd <BDS week> <day of week>     BDS week, day of week

Example, typing this command in terminal:

$ python -m gnsscal -date 2017 5 17

Then it will print:

Gregorian date: 2017-05-17
year, doy: 2017, 137
GPS week: 1949, 3
BDS week: 0593, 3

Installation

The module can be installed using pip:

$ pip install gnsscal

Test

Test gnsscal.py using command:

$ python test_gnsscal.py

License

Released under BSD, see LICENSE for more details.

For comments and suggestions, please send email to: jiangyingming(at)live.com

Release files for gnsscal 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gnsscal 1.1.2
File Size Uploaded
gnsscal-1.1.2.tar.gz 6.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gnsscal 1.1.2
File Interpreter ABI Platform
gnsscal-1.1.2-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size:11.3 kB

Release files / gnsscal-1.1.2.tar.gz

Download URL gnsscal-1.1.2.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0ab49d9c33f3aab96b3957cdf10a8f2ea599bebb432999ab92364f975c8a9269
BLAKE2b-256 checksum
How to use checksums
b19117d5bda72351749ad1e17fa63fce213f15ebd925c30b388377d1f8db6398
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.4

Release files / gnsscal-1.1.2-py2.py3-none-any.whl

Download URL gnsscal-1.1.2-py2.py3-none-any.whl
Size 5.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
cead16c57576eab35e97f4d5a40eb9fe7feacaddaa68f744455e81ffc0a2ac2a
BLAKE2b-256 checksum
How to use checksums
6d32322b3e895d0022120a9bdc9505d1c906ac1671d3687b408bf248b2e5973f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.4

Release history Release notifications | RSS feed

This release

1.1.2 This release

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page