Commit e9accd30 authored by Fabian Kovac's avatar Fabian Kovac
Browse files

[i] PinstMean of LINKS only for dry periods

parent 1a404442
......@@ -487,19 +487,51 @@ def prep() -> None:
# convert BEGINTIME to RAINLINK format
df_link['BEGINTIME'] = df_link['BEGINTIME'].dt.strftime('%Y%m%d%H%M')
_log('Converted BEGINTIME to RAINLINK format "%Y%m%d%H%M"')
# merge config and link dataframe
drop_cols = ['RADIOLINKID', 'LINKTYPE', 'SITEID_A', 'SITEID_B', 'CAPACITYINTERFACE']
df_link = pd.merge(df_link, df_config, how = 'inner', left_on = 'RADIOLINKID', right_on = 'LINKID').drop(drop_cols, axis = 1)
_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 *************************')
# build df with differences of sending and receiving levels
df_diff = df_link[['RADIOLINKID', 'TXLEVEL', 'REMOTERXLEVEL']].copy()
df_diff = df_link[['LINKID', 'TXLEVEL', 'REMOTERXLEVEL', 'RRpath']].copy()
df_diff['PINSTMEAN'] = df_diff['TXLEVEL'] - df_diff['REMOTERXLEVEL']
_log('Built dataframe with mean link difference levels of TXLEVEL and REMOTERXLEVEL')
# get mean of differences per link
df_diff = df_diff.groupby(['RADIOLINKID']).agg({'PINSTMEAN' : 'mean'}).reset_index()
_log('Merged mean link difference levels back to link dataframe')
# get min rainrate of LINK path
df_diff['RRmin'] = np.array([np.array(x).min() for x in df_diff['RRpath'].values])
_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
df_link = pd.merge(df_link, df_diff, how = 'inner', left_on = 'RADIOLINKID', right_on = 'RADIOLINKID')
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')
# 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
......@@ -508,14 +540,9 @@ def prep() -> None:
# calculate differences from instantaneous values and mean link diff. levels
df_link['PDIFF'] = df_link['PINST'] - df_link['PINSTMEAN']
_log('Calculated difference levels PDIFF instantaneous values derivating of daily means of dry periods')
# merge config and link dataframe
drop_cols = ['RADIOLINKID', 'LINKTYPE', 'SITEID_A', 'SITEID_B', 'CAPACITYINTERFACE']
df_link = pd.merge(df_link, df_config, how = 'inner', left_on = 'RADIOLINKID', right_on = 'LINKID').drop(drop_cols, axis = 1)
_log('Merged config data to link dataframe')
# rename and reorder columns to aid RAINLINK format
name_cols = {
'LINKID' : 'ID',
......@@ -547,17 +574,13 @@ def prep() -> None:
'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()))
_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 ********************************')
# build path for clean config and transmissions destination files
......
Markdown is supported
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