so6-file-converter 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- so6_file_converter-0.1.0/.gitattributes +2 -0
- so6_file_converter-0.1.0/.github/workflows/publish.yml +31 -0
- so6_file_converter-0.1.0/.gitignore +7 -0
- so6_file_converter-0.1.0/LICENSE +21 -0
- so6_file_converter-0.1.0/PKG-INFO +95 -0
- so6_file_converter-0.1.0/README.md +75 -0
- so6_file_converter-0.1.0/pyproject.toml +34 -0
- so6_file_converter-0.1.0/src/so6_converter/__init__.py +7 -0
- so6_file_converter-0.1.0/src/so6_converter/reader.py +124 -0
- so6_file_converter-0.1.0/tests/data/sample.so6 +3 -0
- so6_file_converter-0.1.0/tests/test_reader.py +32 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
test:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v4
|
|
12
|
+
- uses: actions/setup-python@v5
|
|
13
|
+
with:
|
|
14
|
+
python-version: "3.12"
|
|
15
|
+
- run: pip install -e ".[test]"
|
|
16
|
+
- run: pytest
|
|
17
|
+
|
|
18
|
+
publish:
|
|
19
|
+
needs: test
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
environment: pypi
|
|
22
|
+
permissions:
|
|
23
|
+
id-token: write # trusted publishing, no API token needed
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v4
|
|
26
|
+
- uses: actions/setup-python@v5
|
|
27
|
+
with:
|
|
28
|
+
python-version: "3.12"
|
|
29
|
+
- run: pip install build
|
|
30
|
+
- run: python -m build
|
|
31
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 O
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: so6-file-converter
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Convert .SO6 flight traffic files into pandas DataFrames
|
|
5
|
+
Project-URL: Homepage, https://github.com/uriibra/so6-file-converter
|
|
6
|
+
Project-URL: Issues, https://github.com/uriibra/so6-file-converter/issues
|
|
7
|
+
Author: O
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: air traffic,flight,pandas,so6,trajectory
|
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering
|
|
15
|
+
Requires-Python: >=3.8
|
|
16
|
+
Requires-Dist: pandas
|
|
17
|
+
Provides-Extra: test
|
|
18
|
+
Requires-Dist: pytest; extra == 'test'
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# so6-file-converter
|
|
22
|
+
|
|
23
|
+
Convert **SO6** flight traffic files into [pandas](https://pandas.pydata.org/) DataFrames for data analysis.
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install so6-file-converter
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Requires Python 3.8+ and pandas (installed automatically).
|
|
32
|
+
|
|
33
|
+
## Quick start
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from so6_converter import so6_to_df, so6_to_df_simple, so6_to_df_waypoints
|
|
37
|
+
|
|
38
|
+
# Raw SO6 file, one row per segment
|
|
39
|
+
df_raw = so6_to_df("example.so6")
|
|
40
|
+
|
|
41
|
+
# One row per flight, variables stored as lists
|
|
42
|
+
df_simple = so6_to_df_simple("./route1/example.so6")
|
|
43
|
+
|
|
44
|
+
# One row per waypoint, duplicates removed
|
|
45
|
+
df_waypoints = so6_to_df_waypoints(r"C:\Users\folder1\folder2\example.so6")
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Paths can be strings or `pathlib.Path` objects.
|
|
49
|
+
|
|
50
|
+
All three functions convert coordinates from minutes to decimal degrees and add a
|
|
51
|
+
`country_flow` column built from the ICAO prefixes of origin and destination (e.g. `EG_LE`).
|
|
52
|
+
|
|
53
|
+
## Functions
|
|
54
|
+
|
|
55
|
+
### `so6_to_df`
|
|
56
|
+
|
|
57
|
+
Reads a **raw SO6 file** without altering its structure: one row per segment, so each
|
|
58
|
+
row contains two waypoints (start and end of the segment).
|
|
59
|
+
|
|
60
|
+
Columns: `segment_id`, `origin`, `destination`, `ac_type`, `time_ini_seg`, `time_end_seg`,
|
|
61
|
+
`fl_ini`, `fl_end`, `status`, `callsign`, `date_ini`, `date_end`, `lat_ini`, `lon_ini`,
|
|
62
|
+
`lat_end`, `lon_end`, `flightid`, `sequence`, `segment_length`, `segment_color`,
|
|
63
|
+
`flown_distance` (total distance of the flight), `country_flow`.
|
|
64
|
+
|
|
65
|
+
Typical uses: initial inspection of SO6 data, custom pipelines built on raw inputs.
|
|
66
|
+
|
|
67
|
+
### `so6_to_df_simple`
|
|
68
|
+
|
|
69
|
+
Groups records **by flight**. Each row is a flight, and `lat`, `long`, `alt`, `time` and
|
|
70
|
+
`date` are lists with the evolution of each variable along the route.
|
|
71
|
+
|
|
72
|
+
Columns: `callsign`, `flightid`, `origin`, `destination`, `lat`, `long`, `alt`, `time`,
|
|
73
|
+
`date`, `total_distance`, `ac_type`, `country_flow`.
|
|
74
|
+
|
|
75
|
+
Typical uses: flight-level trajectory analysis.
|
|
76
|
+
|
|
77
|
+
### `so6_to_df_waypoints`
|
|
78
|
+
|
|
79
|
+
Splits each segment into its two **waypoints**, one per row, and removes duplicates.
|
|
80
|
+
|
|
81
|
+
Columns: `waypoint`, `callsign`, `flightid`, `origin`, `destination`, `lat`, `lon`, `alt`,
|
|
82
|
+
`time`, `date`, `country_flow`.
|
|
83
|
+
|
|
84
|
+
Typical uses: route reconstruction, airspace and network analysis, flight path visualization.
|
|
85
|
+
|
|
86
|
+
## Development
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
pip install -e ".[test]"
|
|
90
|
+
pytest
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## License
|
|
94
|
+
|
|
95
|
+
MIT
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# so6-file-converter
|
|
2
|
+
|
|
3
|
+
Convert **SO6** flight traffic files into [pandas](https://pandas.pydata.org/) DataFrames for data analysis.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install so6-file-converter
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Requires Python 3.8+ and pandas (installed automatically).
|
|
12
|
+
|
|
13
|
+
## Quick start
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from so6_converter import so6_to_df, so6_to_df_simple, so6_to_df_waypoints
|
|
17
|
+
|
|
18
|
+
# Raw SO6 file, one row per segment
|
|
19
|
+
df_raw = so6_to_df("example.so6")
|
|
20
|
+
|
|
21
|
+
# One row per flight, variables stored as lists
|
|
22
|
+
df_simple = so6_to_df_simple("./route1/example.so6")
|
|
23
|
+
|
|
24
|
+
# One row per waypoint, duplicates removed
|
|
25
|
+
df_waypoints = so6_to_df_waypoints(r"C:\Users\folder1\folder2\example.so6")
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Paths can be strings or `pathlib.Path` objects.
|
|
29
|
+
|
|
30
|
+
All three functions convert coordinates from minutes to decimal degrees and add a
|
|
31
|
+
`country_flow` column built from the ICAO prefixes of origin and destination (e.g. `EG_LE`).
|
|
32
|
+
|
|
33
|
+
## Functions
|
|
34
|
+
|
|
35
|
+
### `so6_to_df`
|
|
36
|
+
|
|
37
|
+
Reads a **raw SO6 file** without altering its structure: one row per segment, so each
|
|
38
|
+
row contains two waypoints (start and end of the segment).
|
|
39
|
+
|
|
40
|
+
Columns: `segment_id`, `origin`, `destination`, `ac_type`, `time_ini_seg`, `time_end_seg`,
|
|
41
|
+
`fl_ini`, `fl_end`, `status`, `callsign`, `date_ini`, `date_end`, `lat_ini`, `lon_ini`,
|
|
42
|
+
`lat_end`, `lon_end`, `flightid`, `sequence`, `segment_length`, `segment_color`,
|
|
43
|
+
`flown_distance` (total distance of the flight), `country_flow`.
|
|
44
|
+
|
|
45
|
+
Typical uses: initial inspection of SO6 data, custom pipelines built on raw inputs.
|
|
46
|
+
|
|
47
|
+
### `so6_to_df_simple`
|
|
48
|
+
|
|
49
|
+
Groups records **by flight**. Each row is a flight, and `lat`, `long`, `alt`, `time` and
|
|
50
|
+
`date` are lists with the evolution of each variable along the route.
|
|
51
|
+
|
|
52
|
+
Columns: `callsign`, `flightid`, `origin`, `destination`, `lat`, `long`, `alt`, `time`,
|
|
53
|
+
`date`, `total_distance`, `ac_type`, `country_flow`.
|
|
54
|
+
|
|
55
|
+
Typical uses: flight-level trajectory analysis.
|
|
56
|
+
|
|
57
|
+
### `so6_to_df_waypoints`
|
|
58
|
+
|
|
59
|
+
Splits each segment into its two **waypoints**, one per row, and removes duplicates.
|
|
60
|
+
|
|
61
|
+
Columns: `waypoint`, `callsign`, `flightid`, `origin`, `destination`, `lat`, `lon`, `alt`,
|
|
62
|
+
`time`, `date`, `country_flow`.
|
|
63
|
+
|
|
64
|
+
Typical uses: route reconstruction, airspace and network analysis, flight path visualization.
|
|
65
|
+
|
|
66
|
+
## Development
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
pip install -e ".[test]"
|
|
70
|
+
pytest
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## License
|
|
74
|
+
|
|
75
|
+
MIT
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "so6-file-converter"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Convert .SO6 flight traffic files into pandas DataFrames"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [{ name = "O" }]
|
|
14
|
+
keywords = ["so6", "air traffic", "flight", "trajectory", "pandas"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
"Intended Audience :: Science/Research",
|
|
19
|
+
"Topic :: Scientific/Engineering",
|
|
20
|
+
]
|
|
21
|
+
dependencies = ["pandas"]
|
|
22
|
+
|
|
23
|
+
[project.optional-dependencies]
|
|
24
|
+
test = ["pytest"]
|
|
25
|
+
|
|
26
|
+
[project.urls]
|
|
27
|
+
Homepage = "https://github.com/uriibra/so6-file-converter"
|
|
28
|
+
Issues = "https://github.com/uriibra/so6-file-converter/issues"
|
|
29
|
+
|
|
30
|
+
[tool.hatch.version]
|
|
31
|
+
path = "src/so6_converter/__init__.py"
|
|
32
|
+
|
|
33
|
+
[tool.hatch.build.targets.wheel]
|
|
34
|
+
packages = ["src/so6_converter"]
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"""Convert SO6 flight traffic files into pandas DataFrames."""
|
|
2
|
+
|
|
3
|
+
from .reader import add_country_flow, so6_to_df, so6_to_df_simple, so6_to_df_waypoints
|
|
4
|
+
|
|
5
|
+
__version__ = "0.1.0"
|
|
6
|
+
|
|
7
|
+
__all__ = ["add_country_flow", "so6_to_df", "so6_to_df_simple", "so6_to_df_waypoints", "__version__"]
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"""Readers that convert SO6 flight files into pandas DataFrames."""
|
|
2
|
+
|
|
3
|
+
import pandas as pd
|
|
4
|
+
|
|
5
|
+
__all__ = ["add_country_flow", "so6_to_df", "so6_to_df_simple", "so6_to_df_waypoints"]
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def add_country_flow(i):
|
|
9
|
+
"""Add a ``country_flow`` column (e.g. ``EG_LE``) built from the ICAO prefixes of origin and destination."""
|
|
10
|
+
i['country_flow'] = i.apply(lambda row: sorted([row['origin'][0:2], row['destination'][0:2]]) , axis=1)
|
|
11
|
+
i['country_flow'] = i['country_flow'].str[0] + '_' + i['country_flow'].str[-1]
|
|
12
|
+
i['country_flow'] = i['country_flow'].replace('EI_GC', 'EG_GC') #add ireland to eg flow
|
|
13
|
+
return i
|
|
14
|
+
|
|
15
|
+
def so6_to_df(route): #line x line as so6
|
|
16
|
+
"""Read a raw SO6 file into a DataFrame with one row per segment, as in the original file."""
|
|
17
|
+
columns = ['segment_id', 'origin', 'destination', 'ac_type', 'time_ini_seg', 'time_end_seg', 'fl_ini', 'fl_end', 'status', 'callsign',\
|
|
18
|
+
'date_ini', 'date_end', 'lat_ini', 'lon_ini', 'lat_end', 'lon_end', 'flightid', 'sequence', 'segment_length', 'segment_color']
|
|
19
|
+
data = []
|
|
20
|
+
|
|
21
|
+
with open(route) as doc:
|
|
22
|
+
for line in doc:
|
|
23
|
+
line = line.split()
|
|
24
|
+
data.append(line)
|
|
25
|
+
|
|
26
|
+
df = pd.DataFrame(data, columns=columns)
|
|
27
|
+
|
|
28
|
+
#transform coordinates into decimal
|
|
29
|
+
df['lat_ini'] = df['lat_ini'].astype(float)/60
|
|
30
|
+
df['lat_end'] = df['lat_end'].astype(float)/60
|
|
31
|
+
df['lon_ini'] = df['lon_ini'].astype(float)/60
|
|
32
|
+
df['lon_end'] = df['lon_end'].astype(float)/60
|
|
33
|
+
|
|
34
|
+
#transform numeric values into numeric
|
|
35
|
+
df['segment_length'] = df['segment_length'].astype(float)
|
|
36
|
+
df['fl_ini'] = df['fl_ini'].astype(int)
|
|
37
|
+
df['fl_end'] = df['fl_end'].astype(int)
|
|
38
|
+
df['status'] = df['status'].astype(int)
|
|
39
|
+
df['sequence'] = df['sequence'].astype(int)
|
|
40
|
+
df['segment_color'] = df['segment_color'].astype(int)
|
|
41
|
+
|
|
42
|
+
#create new column total_distance
|
|
43
|
+
dist_sum = df.groupby('flightid')['segment_length'].sum().reset_index()
|
|
44
|
+
df = df.merge(dist_sum, on='flightid', suffixes=('', '_sum'))
|
|
45
|
+
df = df.rename(columns={'segment_length_sum': 'flown_distance'})
|
|
46
|
+
df1 = add_country_flow(df)
|
|
47
|
+
return df1
|
|
48
|
+
|
|
49
|
+
def so6_to_df_simple(route): #one line x flight list with lat, lon, alt, no segments, simplifyed
|
|
50
|
+
"""Read an SO6 file into a DataFrame with one row per flight; lat/long/alt/time/date are lists."""
|
|
51
|
+
columns = ['callsign', 'flightid', 'origin', 'destination', 'lat', 'long', 'alt', 'time', 'date', 'total_distance', 'ac_type']
|
|
52
|
+
data = []
|
|
53
|
+
last = ''
|
|
54
|
+
with open(route) as doc:
|
|
55
|
+
tmp = []
|
|
56
|
+
for line in doc:
|
|
57
|
+
line = line.split()
|
|
58
|
+
if line[16] != last:
|
|
59
|
+
if len(tmp)>0: data.append(tmp)
|
|
60
|
+
tmp = []
|
|
61
|
+
tmp.append(line[9])
|
|
62
|
+
tmp.append(line[16])
|
|
63
|
+
tmp.append(line[1])
|
|
64
|
+
tmp.append(line[2])
|
|
65
|
+
tmp.append([float(line[12])/60])
|
|
66
|
+
tmp.append([float(line[13])/60])
|
|
67
|
+
tmp.append([int(line[6])])
|
|
68
|
+
tmp.append([line[4]])
|
|
69
|
+
tmp.append([line[10]])
|
|
70
|
+
tmp.append(float(line[18]))
|
|
71
|
+
tmp.append(line[3])
|
|
72
|
+
last = line[16]
|
|
73
|
+
|
|
74
|
+
else:
|
|
75
|
+
tmp[4].append(float(line[12])/60)
|
|
76
|
+
tmp[5].append(float(line[13])/60)
|
|
77
|
+
tmp[6].append(int(line[6]))
|
|
78
|
+
tmp[7].append(line[4])
|
|
79
|
+
tmp[8].append(line[10])
|
|
80
|
+
tmp[9]+= float(line[18])
|
|
81
|
+
if len(tmp)>0: data.append(tmp) #last flight
|
|
82
|
+
|
|
83
|
+
df = pd.DataFrame(data, columns=columns)
|
|
84
|
+
df1 = add_country_flow(df)
|
|
85
|
+
return df1
|
|
86
|
+
|
|
87
|
+
def so6_to_df_waypoints(route): #structured x waypints, one line x wpt
|
|
88
|
+
"""Read an SO6 file into a DataFrame with one row per waypoint, removing duplicates."""
|
|
89
|
+
columns = ['waypoint', 'callsign', 'flightid', 'origin', 'destination', 'lat', 'lon', 'alt', 'time', 'date']
|
|
90
|
+
data = []
|
|
91
|
+
with open(route) as doc:
|
|
92
|
+
for line in doc:
|
|
93
|
+
tmp = [] #first wpt
|
|
94
|
+
line = line.split()
|
|
95
|
+
wpt1, wpt2 = line[0].split("_")
|
|
96
|
+
tmp.append(wpt1)
|
|
97
|
+
tmp.append(line[9]) #callsign
|
|
98
|
+
tmp.append(line[16]) #flightid
|
|
99
|
+
tmp.append(line[1]) #ori
|
|
100
|
+
tmp.append(line[2]) #dest
|
|
101
|
+
tmp.append(float(line[12])/60) #lat
|
|
102
|
+
tmp.append(float(line[13])/60) #lon
|
|
103
|
+
tmp.append(int(line[6])) #alt
|
|
104
|
+
tmp.append(line[4]) #time
|
|
105
|
+
tmp.append(line[10]) #date
|
|
106
|
+
data.append(tmp)
|
|
107
|
+
|
|
108
|
+
tmp = [] #secondwpt
|
|
109
|
+
tmp.append(wpt2)
|
|
110
|
+
tmp.append(line[9]) #callsign
|
|
111
|
+
tmp.append(line[16]) #flightid
|
|
112
|
+
tmp.append(line[1]) #ori
|
|
113
|
+
tmp.append(line[2]) #dest
|
|
114
|
+
tmp.append(float(line[14])/60) #lat
|
|
115
|
+
tmp.append(float(line[15])/60) #lon
|
|
116
|
+
tmp.append(int(line[7])) #alt
|
|
117
|
+
tmp.append(line[5]) #time
|
|
118
|
+
tmp.append(line[11]) #date
|
|
119
|
+
data.append(tmp)
|
|
120
|
+
|
|
121
|
+
df = pd.DataFrame(data, columns=columns)
|
|
122
|
+
df1 = add_country_flow(df)
|
|
123
|
+
|
|
124
|
+
return df1.drop_duplicates()
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
LEMD_BAN LEMD EGLL A320 080000 080500 0 100 0 IBE3166 261102 261102 2424.600000 -213.600000 2430.000000 -210.000000 1001 1 25.500000 0
|
|
2
|
+
BAN_SIE LEMD EGLL A320 080500 081500 100 350 0 IBE3166 261102 261102 2430.000000 -210.000000 2500.000000 -200.000000 1001 2 75.000000 0
|
|
3
|
+
EIDW_ABC EIDW GCLP B738 120000 121000 0 200 0 RYR100 261102 261102 3205.800000 -376.200000 3150.000000 -380.000000 2002 1 60.000000 0
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from so6_converter import so6_to_df, so6_to_df_simple, so6_to_df_waypoints
|
|
6
|
+
|
|
7
|
+
SAMPLE = Path(__file__).parent / "data" / "sample.so6"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def test_so6_to_df():
|
|
11
|
+
df = so6_to_df(SAMPLE)
|
|
12
|
+
assert len(df) == 3
|
|
13
|
+
assert df.loc[0, 'segment_id'] == 'LEMD_BAN'
|
|
14
|
+
assert df.loc[0, 'lat_ini'] == pytest.approx(40.41)
|
|
15
|
+
assert df.loc[0, 'fl_end'] == 100
|
|
16
|
+
assert list(df['flown_distance']) == [100.5, 100.5, 60.0]
|
|
17
|
+
assert list(df['country_flow']) == ['EG_LE', 'EG_LE', 'EG_GC']
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_so6_to_df_simple():
|
|
21
|
+
df = so6_to_df_simple(SAMPLE)
|
|
22
|
+
assert list(df['flightid']) == ['1001', '2002']
|
|
23
|
+
assert df.loc[0, 'alt'] == [0, 100]
|
|
24
|
+
assert df.loc[0, 'total_distance'] == 100.5
|
|
25
|
+
assert df.loc[1, 'callsign'] == 'RYR100'
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def test_so6_to_df_waypoints():
|
|
29
|
+
df = so6_to_df_waypoints(SAMPLE)
|
|
30
|
+
# BAN ends segment 1 and starts segment 2 with the same data, so it is kept only once
|
|
31
|
+
assert list(df['waypoint']) == ['LEMD', 'BAN', 'SIE', 'EIDW', 'ABC']
|
|
32
|
+
assert df.iloc[-1]['lat'] == pytest.approx(52.5)
|