Commit 7d22f9ac authored by Fabian Kovac's avatar Fabian Kovac
Browse files

[f] added altitudes of links

parent a727cfd8
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
# Title: Data Preparation for LINK Configs and Transmissions # Title: Data Preparation for LINK Configs and Transmissions
# Author: Fabian Kovac <ds191008@fhstp.ac.at> # Author: Fabian Kovac <ds191008@fhstp.ac.at>
# Team: University of Applied Sciences St. Pölten # Team: University of Applied Sciences St. Pölten
# Version: 2.6 # Version: 2.8
# Last changed: 2021-09-22 # Last changed: 2021-09-29
# #
import sys 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 ...@@ -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) 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: 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 km using a WGS84 rotation-ellipsoid """Calculcates distance between two coordinates in m using a WGS84 rotation-ellipsoid
Parameters: Parameters:
lon_a (np.array): Longitudes of point A lon_a (np.array): Longitudes of point A
lat_a (np.array): Latitudes 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 lon_b (np.array): Longitudes of point B
lat_b (np.array): Latitudes of point B lat_b (np.array): Latitudes of point B
alt_b (np.array): Altitudes of point B
Returns: Returns:
length (np.array): Vector with distances in km length (np.array): Vector with distances in m
""" """
# constants (equator radius and pole radius in km) # 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 is the 'semi-major axis' and r_pole the 'semi-minor axis' on a WGS84 ellipsoid
r_equator = 6378.137 r_equator = 6378137
r_pole = 6356.7523142 r_pole = 6356752.3142
# calculate points on rotation-ellipsoid # calculate points on rotation-ellipsoid
# point A # 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 ...@@ -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 # 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)) 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 return distance
...@@ -349,6 +354,11 @@ def prep() -> None: ...@@ -349,6 +354,11 @@ def prep() -> None:
# drop links that are officially not in use ('na' in CAPACITYINTERFACE and/or FREQUENCY) # drop links that are officially not in use ('na' in CAPACITYINTERFACE and/or FREQUENCY)
# --> see Q&A Phillip Scheffknecht (05 Feb 2021) # --> see Q&A Phillip Scheffknecht (05 Feb 2021)
df_config = df_config.dropna(axis = 0, subset = ['CAPACITYINTERFACE', 'FREQUENCY']) 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)') _log('Dropped configs with NA in CAPACITYINTERFACE and/or FREQUENCY (links officially not in use)')
...@@ -409,15 +419,33 @@ def prep() -> None: ...@@ -409,15 +419,33 @@ def prep() -> None:
df_trans = df_trans.drop(['TEMP_LOC_TUPLE'], axis = 1) 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 # calculate midpoint of links
df_config['LONGITUDE_MID'], df_config['LATITUDE_MID'] = get_midpoint( df_config['LONGITUDE_MID'], df_config['LATITUDE_MID'] = get_midpoint(
df_config['LONGITUDE_A'], df_config['LATITUDE_A'], df_config['LONGITUDE_A'], df_config['LATITUDE_A'],
df_config['LONGITUDE_B'], df_config['LATITUDE_B'] 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') _log('Calculated midpoint of links')
# calculate LENGTH in km between 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') _log('Calculated distances between sites using a WGS84 ellipsoid')
...@@ -550,15 +578,18 @@ def prep() -> None: ...@@ -550,15 +578,18 @@ def prep() -> None:
'CURRTXBITRATE' : 'TxBitrate', 'CURRTXBITRATE' : 'TxBitrate',
'LONGITUDE_A' : 'XStart', 'LONGITUDE_A' : 'XStart',
'LATITUDE_A' : 'YStart', 'LATITUDE_A' : 'YStart',
'ANT_HEIGHT_ALTITUDE_A' : 'AltStart',
'LONGITUDE_MID' : 'XMid', 'LONGITUDE_MID' : 'XMid',
'LATITUDE_MID' : 'YMid', 'LATITUDE_MID' : 'YMid',
'ANT_HEIGHT_ALTITUDE_MID' : 'AltMid',
'LONGITUDE_B' : 'XEnd', 'LONGITUDE_B' : 'XEnd',
'LATITUDE_B' : 'YEnd', 'LATITUDE_B' : 'YEnd',
'ANT_HEIGHT_ALTITUDE_B' : 'AltEnd',
'LENGTH' : 'PathLength', 'LENGTH' : 'PathLength',
'FREQUENCY' : 'Frequency', '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: if 'TXFREQUENCY' in df_link.columns and 'RXFREQUENCY' in df_link.columns:
name_cols.update({ name_cols.update({
'RXFREQUENCY' : 'RxFrequency', 'RXFREQUENCY' : 'RxFrequency',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment