-
Notifications
You must be signed in to change notification settings - Fork 0
/
z_correction.py
52 lines (43 loc) · 2.24 KB
/
z_correction.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from config import *
# Read csv as df
df_kfs = pd.read_csv('computed_kfs.csv', delimiter=',', index_col=0)
z_dict = pd.read_excel('meas-z.xlsx', engine='openpyxl', index_col=0, skiprows=[1]).squeeze().to_dict()
# Read excel for getting measurement depths
df_input = pd.read_excel('input-data.xlsx', usecols=['corrected_depth'], skiprows=[1])
df_kfs['corrected_depth'] = df_input
# Create array for subsequent loop
meas_array = df_kfs['sample'].unique().tolist()
nested_colors_locations = {
'before': {'1': 'blue', '2': 'lightblue', None: 'blue'},
'after': {'1': 'green', '2': 'lightgreen', None: 'green'}
}
df_kfs[['location', 'campaign']] = df_kfs['sample'].str.split(' ', expand=True)
df_kfs[['site', 'up or downstream']] = df_kfs['location'].str.split('-', expand=True)
# Loop through measurement location
for site in df_kfs['site'].unique().tolist():
fig, ax = plt.subplots(figsize=(6, 6))
meas_array_site = df_kfs[df_kfs['site'] == site]
meas_array_site_list = meas_array_site['sample'].unique().tolist()
# for each measurement location loop through kf values computed with different qapproaches
for meas in meas_array_site_list:
df_toplot = df_kfs[df_kfs['sample'] == meas]
campaign, up_or_down = df_toplot['campaign'].iloc[0], df_toplot['up or downstream'].iloc[0]
df_toplot.plot(x='Wooster et al. (2008) [Estimated kf]',
y='corrected_depth',
color=nested_colors_locations[campaign][up_or_down],
ax=ax,
label=meas,
grid=True,
marker='o')
ax.set_xlabel('kf [m/s]')
ax.set_ylabel('Streambed depth * [m]')
ax.xaxis.set_label_position('top') # axis label is located on the top, instead of on the bottom as usual
ax.xaxis.tick_top()
ax.set_ylim(bottom=0.8, top=0)
ax.set_xscale('log')
ax.xaxis.set_major_formatter(FormatStrFormatter('%1.0e'))
ax.set_xlim(0.000001, 0.030)
ax.legend(loc='center left', bbox_to_anchor=(1, 0.5), fontsize=7)
ax.text(0.2, 0.05, '* in ref. to bed elevation before', fontsize=10, transform=ax.transAxes, verticalalignment='bottom')
plt.tight_layout()
fig.savefig('final-plots/' + site + '-z-corrected.png', dpi=300)