Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 26 additions & 13 deletions wizard/parsers/gps/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
from .gpx import GPXParser
from .igotu import PARSERS as IGOUT
from .catlog import PARSERS as CATLOG
from .axytrek import PARSERS as AXYTREK
from .base import PARSERS as BASE
from .jm import PARSERS as JM
from .unknown import PARSERS as UNKNOWN
from .pathtrack import PARSERS as PATHTRACK
from .catlog import PARSERS as CATLOG
from .ecotone import PARSERS as ECOTONE
from .gpx import GPXParser
from .ho11 import PARSERS as HO11
from .axytrek import PARSERS as AXYTREK
from .igotu import PARSERS as IGOUT
from .interrex import PARSERS as INTERREX
from .ornitela import PARSERS as ORNITELA
from .jm import PARSERS as JM
from .mataki import PARSERS as MATAKI
from .ecotone import PARSERS as ECOTONE
from .ornitela import PARSERS as ORNITELA
from .pathtrack import PARSERS as PATHTRACK
from .unknown import PARSERS as UNKNOWN

PARSERS = [
GPXParser,
] + IGOUT + CATLOG + BASE + JM + UNKNOWN + PATHTRACK + \
HO11 + AXYTREK + INTERREX + ORNITELA + MATAKI + ECOTONE
PARSERS = (
[
GPXParser,
]
+ IGOUT
+ CATLOG
+ BASE
+ JM
+ UNKNOWN
+ PATHTRACK
+ HO11
+ AXYTREK
+ INTERREX
+ ORNITELA
+ MATAKI
+ ECOTONE
)
52 changes: 37 additions & 15 deletions wizard/parsers/gps/jm.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
from parsers.helpers import stream_chunk_contains


def signed(val, direction):
val = float(val)
if direction in ("S", "W"):
return -val
return val



# Earth&Ocean mGPS-2

class GPS2JMParser7_5(Parser):
Expand Down Expand Up @@ -142,31 +150,37 @@ class GPS2JMParser8Alternative(Parser):
DATATYPE = "gps_2jm"
# TODO: define fields
FIELDS = [
"date", "time",
"latitude", "latitude_decimal", 'n',
"longitude", "longitude_decimal", 'e',
"satellite",
"voltage", "speed", "altitude", "distance"
"UTC_date",
"UTC_time",
"Latitude",
"Latitude_dir",
"Longitude",
"Longitude_dir",
"satcount",
"hdop",
"speed_km_h",
"altitude_m",
"direction_deg",
]
VERSION = "v8"
SEPARATOR = " "

# TODO: understand the fields first
MAPPINGS = {
"id": "",
"date": "date",
"time": "time",
"latitude": None,
"longitude": None,
"altitude": "altitude",
"speed_km_h": "speed",
"date": "UTC_date",
"time": "UTC_time",
"latitude": "Latitude",
"longitude": "Longitude",
"altitude": "altitude_m",
"speed_km_h": "speed_km_h",
"type": None,
"distance": "distance",
"distance": None,
"course": None,
"hdop": None,
"pdop": None,
"satellites_count": "satellite",
"direction_deg": None,
"satellites_count": "satcount",
"direction_deg": "direction_deg",
"temperature": None,
"solar_I_mA": None,
"bat_soc_pct": None,
Expand Down Expand Up @@ -207,7 +221,15 @@ def __init__(self, parsable: Parsable):
if len(header) != len(self.FIELDS):
self._raise_not_supported(f"Stream have fields different than expected, {len(header)} != {len(self.FIELDS)}")

self.data = pd.read_csv(content, header=0, names=self.FIELDS, sep=self.SEPARATOR, index_col=False)
df = pd.read_csv(content, header=0, names=self.FIELDS, sep=self.SEPARATOR, index_col=False)

df["Latitude"] = [
signed(v, d) for v, d in zip(df["Latitude"], df["Latitude_dir"])
]
df["Longitude"] = [
signed(v, d) for v, d in zip(df["Longitude"], df["Longitude_dir"])
]
self.data = df


PARSERS = [
Expand Down
51 changes: 51 additions & 0 deletions wizard/parsers/gps/ornitela.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,57 @@ class OrnitelaParser(CSVParser):
}



class OrnitelaAlternativeParser(OrnitelaParser):
FIELDS = [
"device_id",
"UTC_datetime",
"UTC_date",
"UTC_time",
"datatype",
"satcount",
"U_bat_mV",
"bat_soc_pct",
"solar_I_mA",
"hdop",
"Latitude",
"Longitude",
"Altitude_m",
"speed_km_h",
"direction_deg",
"temperature_C",
"mag_x",
"mag_y",
"mag_z",
"acc_x",
"acc_y",
"acc_z",
""
]

MAPPINGS = {
"id": "device_id",
"date": "UTC_date",
"time": "UTC_time",
"latitude": "Latitude",
"longitude": "Longitude",
"altitude": "Altitude_m",
"speed_km_h": "speed_km_h",
"type": "datatype",
"distance": None,
"course": "direction_deg",
"hdop": "hdop",
"pdop": None,
"satellites_count": "satcount",
"temperature": "temperature_C",
"solar_I_mA": "solar_I_mA",
"bat_soc_pct": "bat_soc_pct",
"ring_nr": None,
"trip_nr": None,
}


PARSERS = [
OrnitelaParser,
OrnitelaAlternativeParser,
]
1 change: 1 addition & 0 deletions wizard/parsers/parser_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def as_table(self) -> pa.Table:
table = pa.Table.from_pandas(self.data, preserve_index=False)
table = table.append_column('_datatype', pa.array([self.DATATYPE] * len(table), pa.string()))
table = table.append_column('_parser', pa.array([self.__class__.__name__] * len(table), pa.string()))
table = table.append_column('_logger_file', pa.array([self.file._file_path.name] * len(table), pa.string()))
return table

def write_parquet(self, path: pathlib.Path, filename: str = None):
Expand Down
Loading
Loading