Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
oeigner
LINK - Forschungsprojekt Repo
Commits
7d22f9ac
Commit
7d22f9ac
authored
Sep 29, 2021
by
Fabian Kovac
Browse files
[f] added altitudes of links
parent
a727cfd8
Changes
1
Hide whitespace changes
Inline
Side-by-side
FHSTP/01_data_preparation/prep.py
View file @
7d22f9ac
...
...
@@ -2,8 +2,8 @@
# Title: Data Preparation for LINK Configs and Transmissions
# Author: Fabian Kovac <ds191008@fhstp.ac.at>
# Team: University of Applied Sciences St. Pölten
# Version: 2.
6
# Last changed: 2021-09-2
2
# Version: 2.
8
# Last changed: 2021-09-2
9
#
import
sys
...
...
@@ -141,23 +141,25 @@ def get_midpoint(lon_a: np.array, lat_a: np.array, lon_b: np.array, lat_b: np.ar
return
np
.
degrees
(
lon_mid
),
np
.
degrees
(
lat_mid
)
def
get_distance
(
lon_a
:
np
.
array
,
lat_a
:
np
.
array
,
lon_b
:
np
.
array
,
lat_b
:
np
.
array
)
->
np
.
array
:
"""Calculcates distance between two coordinates in
k
m using a WGS84 rotation-ellipsoid
def
get_distance
(
lon_a
:
np
.
array
,
lat_a
:
np
.
array
,
alt_a
:
np
.
array
,
lon_b
:
np
.
array
,
lat_b
:
np
.
array
,
alt_b
:
np
.
array
)
->
np
.
array
:
"""Calculcates distance between two coordinates in m using a WGS84 rotation-ellipsoid
Parameters:
lon_a (np.array): Longitudes of point A
lat_a (np.array): Latitudes of point A
alt_a (np.array): Altitudes of point A
lon_b (np.array): Longitudes of point B
lat_b (np.array): Latitudes of point B
alt_b (np.array): Altitudes of point B
Returns:
length (np.array): Vector with distances in
k
m
length (np.array): Vector with distances in m
"""
# constants (equator radius and pole radius in
k
m)
# constants (equator radius and pole radius in m)
# r_equator is the 'semi-major axis' and r_pole the 'semi-minor axis' on a WGS84 ellipsoid
r_equator
=
6378
.
137
r_pole
=
6356
.
7523142
r_equator
=
6378137
r_pole
=
6356752
.
3142
# calculate points on rotation-ellipsoid
# point A
...
...
@@ -179,6 +181,9 @@ def get_distance(lon_a: np.array, lat_a: np.array, lon_b: np.array, lat_b: np.ar
# calculate distances between points using the square root of the sum of squares
distance
=
np
.
sqrt
(
np
.
square
(
dx
)
+
np
.
square
(
dy
)
+
np
.
square
(
dz
))
# incorporate altitudes into the distance
distance
=
np
.
sqrt
(
np
.
square
(
distance
)
+
np
.
square
(
alt_a
-
alt_b
))
return
distance
...
...
@@ -349,6 +354,11 @@ def prep() -> None:
# drop links that are officially not in use ('na' in CAPACITYINTERFACE and/or FREQUENCY)
# --> see Q&A Phillip Scheffknecht (05 Feb 2021)
df_config
=
df_config
.
dropna
(
axis
=
0
,
subset
=
[
'CAPACITYINTERFACE'
,
'FREQUENCY'
])
# check if RXFREQUENCY and TXFREQUENCY exists (only present after 2021-05)
if
'TXFREQUENCY'
in
df_config
.
columns
and
'RXFREQUENCY'
in
df_config
.
columns
:
df_config
=
df_config
.
dropna
(
axis
=
0
,
subset
=
[
'RXFREQUENCY'
,
'TXFREQUENCY'
])
_log
(
'Dropped configs with NA in CAPACITYINTERFACE and/or FREQUENCY (links officially not in use)'
)
...
...
@@ -409,15 +419,33 @@ def prep() -> None:
df_trans
=
df_trans
.
drop
([
'TEMP_LOC_TUPLE'
],
axis
=
1
)
# check if ANT_HEIGHT_ALTITUDE_A and ANT_HEIGHT_ALTITUDE_B exists (only present after 2021-09)
# otherwise get altitudes of config file from "VIW_ZAMG_MW_CONFIG_DY_20210928_SH.csv"
# --> see mail Jürgen Köhler (juergen.koehler@drei.com) at 2021-09-27 16:15
if
'ANT_HEIGHT_ALTITUDE_A'
not
in
df_config
.
columns
and
'ANT_HEIGHT_ALTITUDE_B'
not
in
df_config
.
columns
:
df_altitudes
=
pd
.
read_csv
(
'files_from_H3A/CONFIG_ALTITUDES.csv'
,
sep
=
';'
)
df_altitudes
=
df_altitudes
[[
'LINKID'
,
'ANT_HEIGHT_ALTITUDE_A'
,
'ANT_HEIGHT_ALTITUDE_B'
]]
df_config
=
pd
.
merge
(
df_config
,
df_altitudes
,
how
=
'inner'
,
left_on
=
'LINKID'
,
right_on
=
'LINKID'
)
# calculate midpoint of links
df_config
[
'LONGITUDE_MID'
],
df_config
[
'LATITUDE_MID'
]
=
get_midpoint
(
df_config
[
'LONGITUDE_A'
],
df_config
[
'LATITUDE_A'
],
df_config
[
'LONGITUDE_B'
],
df_config
[
'LATITUDE_B'
]
)
df_config
[
'ANT_HEIGHT_ALTITUDE_MID'
]
=
(
df_config
[
'ANT_HEIGHT_ALTITUDE_A'
]
+
df_config
[
'ANT_HEIGHT_ALTITUDE_B'
])
//
2
df_config
[
'ANT_HEIGHT_ALTITUDE_MID'
]
=
df_config
[
'ANT_HEIGHT_ALTITUDE_MID'
].
astype
(
'int'
)
_log
(
'Calculated midpoint of links'
)
# calculate LENGTH in km between links
df_config
[
'LENGTH'
]
=
get_distance
(
df_config
[
'LONGITUDE_A'
],
df_config
[
'LATITUDE_A'
],
df_config
[
'LONGITUDE_B'
],
df_config
[
'LATITUDE_B'
])
df_config
[
'LENGTH'
]
=
get_distance
(
df_config
[
'LONGITUDE_A'
],
df_config
[
'LATITUDE_A'
],
df_config
[
'ANT_HEIGHT_ALTITUDE_A'
],
df_config
[
'LONGITUDE_B'
],
df_config
[
'LATITUDE_B'
],
df_config
[
'ANT_HEIGHT_ALTITUDE_B'
]
)
_log
(
'Calculated distances between sites using a WGS84 ellipsoid'
)
...
...
@@ -550,15 +578,18 @@ def prep() -> None:
'CURRTXBITRATE'
:
'TxBitrate'
,
'LONGITUDE_A'
:
'XStart'
,
'LATITUDE_A'
:
'YStart'
,
'ANT_HEIGHT_ALTITUDE_A'
:
'AltStart'
,
'LONGITUDE_MID'
:
'XMid'
,
'LATITUDE_MID'
:
'YMid'
,
'ANT_HEIGHT_ALTITUDE_MID'
:
'AltMid'
,
'LONGITUDE_B'
:
'XEnd'
,
'LATITUDE_B'
:
'YEnd'
,
'ANT_HEIGHT_ALTITUDE_B'
:
'AltEnd'
,
'LENGTH'
:
'PathLength'
,
'FREQUENCY'
:
'Frequency'
,
}
# check if RXFREQUENCY and TXFREQUENCY exists (only present
with
2021-05)
# check if RXFREQUENCY and TXFREQUENCY exists (only present
after
2021-05)
if
'TXFREQUENCY'
in
df_link
.
columns
and
'RXFREQUENCY'
in
df_link
.
columns
:
name_cols
.
update
({
'RXFREQUENCY'
:
'RxFrequency'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment