Switch Gregorian date to GNSS calendar (GPS & BDS).
Project description
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
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.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size gnsscal-1.1.1-py2.py3-none-any.whl (7.1 kB) | File type Wheel | Python version py2.py3 | Upload date | Hashes View |
Filename, size gnsscal-1.1.1.tar.gz (5.6 kB) | File type Source | Python version None | Upload date | Hashes View |
Hashes for gnsscal-1.1.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 548adecb9ddf4b5f0b986292c6aebb16d46284afc668696fd243b6e80989986d |
|
MD5 | d3f7407a97f49c47ab31685fa9a38cf5 |
|
BLAKE2-256 | 4b52cc4549dfedd7426bb5f3f520b1d3fcb7ef202809f1b0bb20d3bf3ee546d3 |