Commit 92a3d7eb authored by Fabian Kovac's avatar Fabian Kovac
Browse files

[i] reverted PinstMean for dry periods (research purposes) back to mean per link

parent ba700154
...@@ -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.4 # Version: 2.5
# Last changed: 2021-09-08 # Last changed: 2021-09-27
# #
import sys import sys
...@@ -495,44 +495,21 @@ def prep() -> None: ...@@ -495,44 +495,21 @@ def prep() -> None:
_log('Merged config data to link dataframe') _log('Merged config data to link dataframe')
_log('\n******************************** MERGE INCA ********************************')
# set INCA RR data for each km of link path
df_link['RRpath'] = get_inca_data(
df_link['BEGINTIME'],
df_link['LONGITUDE_A'],
df_link['LATITUDE_A'],
df_link['LONGITUDE_B'],
df_link['LATITUDE_B'],
df_link['LENGTH']
)
_log('Merged INCA RR data to transmissions')
_log('\n******************************** CALC POWER LEVELS *************************') _log('\n******************************** CALC POWER LEVELS *************************')
# build df with differences of sending and receiving levels # build df with differences of sending and receiving levels
df_diff = df_link[['LINKID', 'TXLEVEL', 'REMOTERXLEVEL', 'RRpath']].copy() df_diff = df_link[['LINKID', 'TXLEVEL', 'REMOTERXLEVEL']].copy()
df_diff['PINSTMEAN'] = df_diff['TXLEVEL'] - df_diff['REMOTERXLEVEL'] df_diff['PINSTMEAN'] = df_diff['TXLEVEL'] - df_diff['REMOTERXLEVEL']
_log('Built dataframe with mean link difference levels of TXLEVEL and REMOTERXLEVEL') _log('Built dataframe with mean link difference levels of TXLEVEL and REMOTERXLEVEL')
# get min rainrate of LINK path # get mean of differences per link
df_diff['RRmin'] = np.array([np.array(x).min() for x in df_diff['RRpath'].values]) df_diff = df_diff.groupby(['LINKID']).agg({'PINSTMEAN' : 'mean'}).reset_index()
_log('Calculate min rainrates for LINK path')
# get mean of differences per link of dry periods
df_diff = df_diff[df_diff['RRmin'] == 0.0].groupby(['LINKID']).agg({'PINSTMEAN' : 'mean'}).reset_index()
_log('Calculate mean difference levels of dry periods')
# merge differences to transmission dataframe # merge differences to transmission dataframe
df_link = pd.merge(df_link, df_diff, how = 'left', left_on = 'LINKID', right_on = 'LINKID') df_link = pd.merge(df_link, df_diff, how = 'left', left_on = 'LINKID', right_on = 'LINKID')
_log('Merged mean link difference levels back to link dataframe') _log('Merged mean link difference levels back to link dataframe')
# if PINSTMEAN is NA, LINK only saw wet periods
# --> set to mean of all LINKS
df_link['PINSTMEAN'] = df_link['PINSTMEAN'].fillna(df_link['PINSTMEAN'].mean())
_log('Filled NAs of PINSTMEAN (exclusively wet periods) with daily mean of all LINKS')
# calculate instantaneous values from transmitted and received signal strength # calculate instantaneous values from transmitted and received signal strength
df_link['PINST'] = df_link['TXLEVEL'] - df_link['REMOTERXLEVEL'] df_link['PINST'] = df_link['TXLEVEL'] - df_link['REMOTERXLEVEL']
...@@ -588,13 +565,24 @@ def prep() -> None: ...@@ -588,13 +565,24 @@ def prep() -> None:
'TXFREQUENCY' : 'TxFrequency' 'TXFREQUENCY' : 'TxFrequency'
}) })
# set RRpath as last column
name_cols.update({'RRpath' : 'RRpath'})
df_link = df_link.rename(columns = name_cols).reindex(columns = list(name_cols.values())) df_link = df_link.rename(columns = name_cols).reindex(columns = list(name_cols.values()))
_log('Converted link dataframe to RAINLINK format') _log('Converted link dataframe to RAINLINK format')
_log('\n******************************** MERGE INCA ********************************')
# set INCA RR data for each km of link path
df_link['RRpath'] = get_inca_data(
df_link['DateTime'],
df_link['XStart'],
df_link['YStart'],
df_link['XEnd'],
df_link['YEnd'],
df_link['PathLength']
)
_log('Merged INCA RR data to transmissions')
_log('\n******************************** SAVE FILES ********************************') _log('\n******************************** SAVE FILES ********************************')
# build path for clean config and transmissions destination files # build path for clean config and transmissions destination files
......
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