-
Notifications
You must be signed in to change notification settings - Fork 4
/
scatter_plots_traits.py
104 lines (85 loc) · 2.88 KB
/
scatter_plots_traits.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
'''
This script recreates the scatterplots of the traits shown in the paper.
@author: Lukas Valentin Graf
'''
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
from pathlib import Path
from utils import plot_prediction, TraitLimits
plt.style.use('bmh')
mpl.rc('font', size=20)
trait_settings = {
'lai': {
'trait_name': 'Green Leaf Area Index',
'trait_unit': r'$m^2$ $m^{-2}$',
'trait_lims': TraitLimits(0, 8),
},
'ccc': {
'trait_name': 'Canopy Chlorophyll Content',
'trait_unit': r'$g$ $m^{-2}$',
'trait_lims': TraitLimits(0, 4),
}
}
if __name__ == '__main__':
traits = ['lai', 'ccc']
results_dir = Path('../../results/lut_based_inversion')
out_dir = Path('../../results/Figures')
for trait in traits:
fpath_agdds = results_dir.joinpath(
'agdds_only'
).joinpath(
f'validation_{trait}'
).joinpath(
f'inv_res_joined_with_insitu_{trait}.csv'
)
fpath_agdds_s2 = results_dir.joinpath(
'agdds_and_s2'
).joinpath(
f'validation_{trait}'
).joinpath(
f'inv_res_joined_with_insitu_{trait}.csv'
)
df_agdds = pd.read_csv(fpath_agdds)
df_agdds.dropna(subset=[trait], inplace=True)
df_agdds_s2 = pd.read_csv(fpath_agdds_s2)
df_agdds_s2.dropna(subset=[trait], inplace=True)
# extract the year
df_agdds['year'] = pd.to_datetime(
df_agdds['date_model']).dt.year
df_agdds_s2['year'] = pd.to_datetime(
df_agdds_s2['date_model']).dt.year
f, ax = plt.subplots(ncols=3, figsize=(30, 10), sharey=True)
# NO-PHENO experiment
_, errors_no_pheno = plot_prediction(
true=df_agdds[trait],
pred=df_agdds[f'{trait}_all'],
ax=ax[0],
hue=df_agdds['year'],
**trait_settings[trait]
)
ax[0].set_title('(a) NO-PHENO')
errors_no_pheno['experiment'] = 'NO-PHENO'
# AGDD-PHENO
_, errors_agdd_pheno = plot_prediction(
true=df_agdds[trait],
pred=df_agdds[f'{trait} (Phenology)'],
ax=ax[1],
hue=df_agdds['year'],
**trait_settings[trait]
)
ax[1].set_title('(b) AGDD-PHENO')
errors_agdd_pheno['experiment'] = 'AGDD-PHENO'
# AGDD-S2-PHENO
_, errors_agdd_s2_pheno = plot_prediction(
true=df_agdds_s2[trait],
pred=df_agdds_s2[f'{trait} (Phenology)'],
ax=ax[2],
hue=df_agdds_s2['year'],
**trait_settings[trait]
)
ax[2].set_title('(c) AGDD-S2-PHENO')
errors_agdd_pheno['experiment'] = 'AGDD-S2-PHENO'
fpath_plt = out_dir.joinpath(f'{trait}_scatter_plot.png')
f.savefig(fpath_plt, bbox_inches='tight')
plt.close(f)