nmea
¶
nmea - Imports GPS NMEA-formatted data files.
-
class
upoints.nmea.
Fix
(time, latitude, longitude, quality, satellites, dilution, altitude, geoid_delta, dgps_delta=None, dgps_station=None, mode=None)[source]¶ Bases:
upoints.point.Point
Class for representing a GPS NMEA-formatted system fix.
New in version 0.8.0.
Initialise a new
Fix
object.Parameters: - time (datetime.time) – Time the fix was taken
- latitude (float) – Fix’s latitude
- longitude (float) – Fix’s longitude
- quality (int) – Mode under which the fix was taken
- satellites (int) – Number of tracked satellites
- dilution (float) – Horizontal dilution at reported position
- altitude (float) – Altitude above MSL
- geoid_delta (float) – Height of geoid’s MSL above WGS84 ellipsoid
- dgps_delta (float) – Number of seconds since last DGPS sync
- dgps_station (int) – Identifier of the last synced DGPS station
- mode (str) – Type of reading
-
class
upoints.nmea.
Locations
(gpsdata_file=None)[source]¶ Bases:
upoints.point.Points
Class for representing a group of GPS location objects.
New in version 0.8.0.
Initialise a new
Locations
object.-
import_locations
(gpsdata_file, checksum=True)[source]¶ Import GPS NMEA-formatted data files.
import_locations()
returns a list of Fix objects representing the fix sentences found in the GPS data.It expects data files in NMEA 0183 format, as specified in the official documentation, which is ASCII text such as:
$GPGSV,6,6,21,32,65,170,35*48 $GPGGA,142058,5308.6414,N,00300.9257,W,1,04,5.6,1374.6,M,34.5,M,,*6B $GPRMC,142058,A,5308.6414,N,00300.9257,W,109394.7,202.9,191107,5,E,A*2C $GPGSV,6,1,21,02,76,044,43,03,84,156,49,06,89,116,51,08,60,184,30*7C $GPGSV,6,2,21,09,87,321,50,10,77,243,44,11,85,016,49,12,89,100,52*7A $GPGSV,6,3,21,13,70,319,39,14,90,094,52,16,85,130,49,17,88,136,51*7E $GPGSV,6,4,21,18,57,052,27,24,65,007,34,25,62,142,32,26,88,031,51*73 $GPGSV,6,5,21,27,64,343,33,28,45,231,16,30,84,198,49,31,90,015,52*7C $GPGSV,6,6,21,32,65,170,34*49 $GPWPL,5200.9000,N,00013.2600,W,HOME*5E $GPGGA,142100,5200.9000,N,00316.6600,W,1,04,5.6,1000.0,M,34.5,M,,*68 $GPRMC,142100,A,5200.9000,N,00316.6600,W,123142.7,188.1,191107,5,E,A*21
The reader only imports the GGA, or GPS fix, sentences currently but future versions will probably support tracks and waypoints. Other than that the data is out of scope for
upoints
.The above file when processed by
import_locations()
will return the followinglist
object:[Fix(datetime.time(14, 20, 58), 53.1440233333, -3.01542833333, 1, 4, 5.6, 1374.6, 34.5, None, None), Position(datetime.time(14, 20, 58), True, 53.1440233333, -3.01542833333, 109394.7, 202.9, datetime.date(2007, 11, 19), 5.0, 'A'), Waypoint(52.015, -0.221, 'Home'), Fix(datetime.time(14, 21), 52.015, -3.27766666667, 1, 4, 5.6, 1000.0, 34.5, None, None), Position(datetime.time(14, 21), True, 52.015, -3.27766666667, 123142.7, 188.1, datetime.date(2007, 11, 19), 5.0, 'A')]
Note
The standard is quite specific in that sentences must be less than 82 bytes, while it would be nice to add yet another validity check it isn’t all that uncommon for devices to break this requirement in their “extensions” to the standard.
Todo
Add optional check for message length, on by default
Parameters: - gpsdata_file (iter) – NMEA data to read
- checksum (bool) – Whether checksums should be tested
Returns: Series of locations taken from the data
Return type:
-
-
class
upoints.nmea.
LoranPosition
(latitude, longitude, time, status, mode=None)[source]¶ Bases:
upoints.point.Point
Class for representing a GPS NMEA-formatted Loran-C position.
Initialise a new
LoranPosition
object.Parameters: - latitude (float) – Fix’s latitude
- longitude (float) – Fix’s longitude
- time (datetime.time) – Time the fix was taken
- status (bool) – Whether the data is active
- mode (str) – Type of reading
-
upoints.nmea.
MODE_INDICATOR
= {'A': 'Autonomous', 'D': 'Differential', 'E': 'Estimated', 'M': 'Manual', 'N': 'Invalid', 'S': 'Simulated'}¶ NMEA’s mapping of code to reading type
-
class
upoints.nmea.
Position
(time, status, latitude, longitude, speed, track, date, variation, mode=None)[source]¶ Bases:
upoints.point.Point
Class for representing a GPS NMEA-formatted position.
New in version 0.8.0.
Initialise a new
Position
object.Parameters: - time (datetime.time) – Time the fix was taken
- status (bool) – Whether the data is active
- latitude (float) – Fix’s latitude
- longitude (float) – Fix’s longitude
- speed (float) – Ground speed
- track (float) – Track angle
- date (datetime.date) – Date when position was taken
- variation (float) – Magnetic variation
- mode (str) – Type of reading
-
class
upoints.nmea.
Waypoint
(latitude, longitude, name)[source]¶ Bases:
upoints.point.Point
Class for representing a NMEA-formatted waypoint.
New in version 0.8.0.
Initialise a new
Waypoint
object.Parameters: -
static
parse_elements
(elements)[source]¶ Parse waypoint data elements.
Parameters: elements (list) – Data values for fix Returns: Object representing data Return type: nmea.Waypoint
-
static
-
upoints.nmea.
calc_checksum
(sentence)[source]¶ Calculate a NMEA 0183 checksum for the given sentence.
NMEA checksums are a simple XOR of all the characters in the sentence between the leading “$” symbol, and the “*” checksum separator.
Parameters: sentence (str) – NMEA 0183 formatted sentence
-
upoints.nmea.
nmea_latitude
(latitude)[source]¶ Generate a NMEA-formatted latitude pair.
Parameters: latitude (float) – Latitude to convert Returns: NMEA-formatted latitude values Return type: tuple
-
upoints.nmea.
nmea_longitude
(longitude)[source]¶ Generate a NMEA-formatted longitude pair.
Parameters: longitude (float) – Longitude to convert Returns: NMEA-formatted longitude values Return type: tuple