Newer
Older
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 6 10:39:50 2023
@author: rivallandv
"""
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
# Modspa excel file - Reference Simmonneaux !
# xls_file_path = './SAMIR_xls/SAMIRpixel_Reference_Simonneaux2012.xls'
xls_file_path = 'SAMIRxls_Reference.FR-Lam2019.xls'
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
titre = 'Irrigated Maize - France (Lam-2019)'
figname = '-Maize-Lam-2019'
def rmse_calc(predictions, targets):
"""
RMSE calculate.
Parameters
----------
predictions : TYPE
model.
targets : TYPE
observation.
Returns
-------
Real
RMSE.
"""
return np.sqrt(((predictions - targets) ** 2).mean())
# %% Lecture de l'ensemble des variables au format dataframe
df_samir_xls = pd.read_excel(xls_file_path, sheet_name='Table', header=10, index_col=0)
df_samir_xls = df_samir_xls.loc[:, ~df_samir_xls.columns.str.contains('^Unnamed')]
# df_samir_xls
dates = df_samir_xls.index
# %% NDVI and co.
plt.figure(1)
plt.plot(dates, df_samir_xls.NDVI, "green")
plt.plot(dates, df_samir_xls.Kcb, "blue")
plt.plot(dates, df_samir_xls.FCov, "red")
plt.legend(['NDVI', 'Kcb', 'FCov'])
plt.xticks(rotation=20)
plt.title(titre)
plt.savefig('NDVI-Kcb-FCov'+figname+'.png')
# %% ET0 to ETR
plt.figure(2)
plt.plot(dates, df_samir_xls.ET0, "red")
plt.plot(dates, df_samir_xls.ETobs, 'ok')
plt.text(dates[4], 5, "rmse="+str(round(rmse_calc(df_samir_xls.ET0, df_samir_xls.ETobs), 2)))
plt.legend(['ET0', 'ETobs'])
plt.xticks(rotation=20)
plt.ylim([0, 10])
plt.title(titre)
plt.savefig('ET0toETR-Wheat'+figname+'.png')
# %%
plt.figure(3)
plt.plot(dates, df_samir_xls.ET0, "skyblue")
plt.plot(dates, df_samir_xls.ET0*df_samir_xls.Kcb, "red")
plt.plot(dates, df_samir_xls.ETobs, 'ok')
plt.text(dates[4], 4, "rmse="+str(round(rmse_calc(df_samir_xls.ET0*df_samir_xls.Kcb, df_samir_xls.ETobs), 2)))
plt.legend(['ET0', 'Kcb.ET0', 'ETobs'])
plt.xticks(rotation=20)
plt.ylim([0, 10])
plt.title(titre)
plt.savefig('ET0toETR'+figname+'.3.png')
# %%
plt.figure(4)
plt.plot(dates, df_samir_xls.ET0, "skyblue")
plt.plot(dates, df_samir_xls.ET0*df_samir_xls.Kcb, "gray")
plt.plot(dates, df_samir_xls.ET0*df_samir_xls.Kcb+df_samir_xls.E, "red")
plt.plot(dates, df_samir_xls.ETobs, 'ok')
plt.text(dates[4], 4, "rmse="+str(round(rmse_calc(df_samir_xls.ET0*df_samir_xls.Kcb+df_samir_xls.E, df_samir_xls.ETobs), 2)))
plt.legend(['ET0', 'Kcb.ET0', 'Kcb.ET0+Ke.ET0', 'ETobs'])
plt.xticks(rotation=20)
plt.ylim([0, 10])
plt.title(titre)
plt.savefig('ET0toETR'+figname+'.4.png')
# %%
plt.figure(5)
plt.plot(dates, df_samir_xls.ET0, "skyblue")
plt.plot(dates, df_samir_xls.ET0*df_samir_xls.Kcb, "lightgray")
plt.plot(dates, df_samir_xls.ET0*df_samir_xls.Kcb+df_samir_xls.E, "gray")
plt.plot(dates, df_samir_xls.ET, "red")
plt.plot(dates, df_samir_xls.ETobs, 'ok')
plt.text(dates[4], 4, "rmse="+str(round(rmse_calc(df_samir_xls.ET, df_samir_xls.ETobs), 2)))
plt.legend(['ET0', 'Kcb.ET0', 'Kcb.ET0+Ke.ET0', 'Kcb.Ks.ET0+Ke.ET0', 'ETobs'])
plt.xticks(rotation=20)
plt.ylim([0, 10])
plt.title(titre)
plt.savefig('ET0toETR'+figname+'.5.png')
# %%
plt.figure(6)
plt.subplot(221)
plt.plot(dates, df_samir_xls.swc5obsvol, marker="o", color="chocolate", linestyle='', markersize=3)
plt.plot(dates, df_samir_xls.swc10obsvol, marker="s", color="gray", linestyle='', markersize=3)
plt.plot(dates, df_samir_xls.SWCe, color="red")
plt.ylabel('% of TAW')
plt.legend(['obs 5', 'obs 10', 'SWCe'])
plt.xticks(rotation=20)
plt.subplot(222)
plt.plot(dates, df_samir_xls.swc30obsvol, marker="o", color="chocolate", linestyle='', markersize=3)
plt.plot(dates, df_samir_xls.swc50obsvol, marker="s", color="gray", linestyle='', markersize=3)
plt.plot(dates, df_samir_xls.SWCr, color="red")
plt.ylabel('% of TAW')
plt.legend(['obs 30', 'obs 50', 'SWCroot'])
plt.xticks(rotation=20)
plt.subplot(223)
plt.plot(dates, df_samir_xls.swc100obsvol, marker="o", color="chocolate", linestyle='', markersize=3)
plt.plot(dates, df_samir_xls.SWCd, color="blue")
plt.ylabel('% of TAW')
plt.legend(['obs 100', 'SWCd'])
plt.xticks(rotation=20)
plt.subplot(224)
plt.plot(dates, df_samir_xls.Ks, "red")
plt.plot(dates, df_samir_xls.Kei+df_samir_xls.Kep, "sienna")
plt.plot(dates, df_samir_xls.Kcb, "green")
plt.plot(dates, df_samir_xls.FCov, "chocolate")
plt.legend(['Ks', 'Ke', 'Kcb', "Fcov"])
plt.xticks(rotation=20)
plt.suptitle(titre)
# plt.ylim([0, 7])
plt.savefig('SWC-Ks'+figname+'.1.png')
# %% Etude entre rapport ETRobs/ET0 et Kc
df_samir_xls['Kcobs'] = df_samir_xls['ETobs_ET0'].rolling(window=5).mean()
plt.figure()
plt.plot(dates, df_samir_xls.ETobs/df_samir_xls.ET0, 'or', markersize=3)
plt.plot(dates, df_samir_xls.NDVI, 'green')
plt.plot(dates, df_samir_xls.Kcobs, 'r')
plt.plot(dates, df_samir_xls.Kcb*df_samir_xls.Ks, 'chocolate')
plt.plot(dates, df_samir_xls.Kcb*df_samir_xls.Ks+(df_samir_xls.Kei+df_samir_xls.Kep), 'gray')
plt.legend(['Kcobs', 'NDVI', 'Kcobsmean', 'KcbxKs', 'KcbxKs+Ke', 'Kc_obs=ETobs/ET0'], loc='best')
plt.xticks(rotation=20)
plt.title(titre)
# %% ETRobs vs ETRsim
plt.figure()
plt.plot(df_samir_xls.ET, df_samir_xls.ETobs, 'ok', markersize=3)
plt.plot([0, 10], [0, 10], 'r')
plt.xlabel("ETR sim mm/d")
plt.ylabel("ETR obs mm/d")
plt.text(0, 6, "rmse="+str(round(rmse_calc(df_samir_xls.ET, df_samir_xls.ETobs), 2)))
plt.title(titre)
plt.axis('square')