# **Sensitivity of the PM model to wind speed: Sympy study**
%% Cell type:markdown id:heavy-plastic tags:
%% Cell type:markdown id:superb-progressive tags:
# Part I - Methodology
## <u> Motivation </u>
### Theoretical background
When assessing the models sensitivity to changes in atmospheric forcings in notebook simpler_model.ipynb, we found out that the potential evapo-transpiration models had a counter intuitive sensitivity to wind speed:
This otebook aims at investigating the mathematical structure of the Penman-Monteith model to investigate the variation behavior of the equation to wind speed.
### Modelling experiements
Sympy is used in this notebook in order to compute the derivative of the Penman-Monteith equation to wind speed and to study its sign
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:theta_sat" will be overridden by "e/theory_variable:<class 'e/theory_variable.theta_sat'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:theta_res" will be overridden by "e/theory_variable:<class 'e/theory_variable.theta_res'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:alpha" will be overridden by "e/theory_variable:<class 'e/theory_variable.alpha'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:n" will be overridden by "e/theory_variable:<class 'e/theory_variable.n'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:m" will be overridden by "e/theory_variable:<class 'e/theory_variable.m'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:S_mvg" will be overridden by "e/theory_variable:<class 'e/theory_variable.S_mvg'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:theta" will be overridden by "e/theory_variable:<class 'e/theory_variable.theta'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:h" will be overridden by "e/theory_variable:<class 'e/theory_variable.h'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:S" will be overridden by "e/theory_variable:<class 'e/theory_variable.S'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:theta_4" will be overridden by "e/theory_variable:<class 'e/theory_variable.theta_4'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:theta_3" will be overridden by "e/theory_variable:<class 'e/theory_variable.theta_3'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:theta_2" will be overridden by "e/theory_variable:<class 'e/theory_variable.theta_2'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:theta_1" will be overridden by "e/theory_variable:<class 'e/theory_variable.theta_1'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:L" will be overridden by "e/theory_variable:<class 'e/theory_variable.L'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:Mw" will be overridden by "e/theory_variable:<class 'e/theory_variable.Mw'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:Pv" will be overridden by "e/theory_variable:<class 'e/theory_variable.Pv'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:Pvs" will be overridden by "e/theory_variable:<class 'e/theory_variable.Pvs'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:R" will be overridden by "e/theory_variable:<class 'e/theory_variable.R'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:T" will be overridden by "e/theory_variable:<class 'e/theory_variable.T'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:c1" will be overridden by "e/theory_variable:<class 'e/theory_variable.c1'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:T0" will be overridden by "e/theory_variable:<class 'e/theory_variable.T0'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:Delta" will be overridden by "e/theory_variable:<class 'e/theory_variable.Delta'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:E" will be overridden by "e/theory_variable:<class 'e/theory_variable.E'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:G" will be overridden by "e/theory_variable:<class 'e/theory_variable.G'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:H" will be overridden by "e/theory_variable:<class 'e/theory_variable.H'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:Rn" will be overridden by "e/theory_variable:<class 'e/theory_variable.Rn'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:LE" will be overridden by "e/theory_variable:<class 'e/theory_variable.LE'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:gamma" will be overridden by "e/theory_variable:<class 'e/theory_variable.gamma'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:alpha_PT" will be overridden by "e/theory_variable:<class 'e/theory_variable.alpha_PT'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:c_p" will be overridden by "e/theory_variable:<class 'e/theory_variable.c_p'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:w" will be overridden by "e/theory_variable:<class 'e/theory_variable.w'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:kappa" will be overridden by "e/theory_variable:<class 'e/theory_variable.kappa'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:z" will be overridden by "e/theory_variable:<class 'e/theory_variable.z'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:u_star" will be overridden by "e/theory_variable:<class 'e/theory_variable.u_star'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:VH" will be overridden by "e/theory_variable:<class 'e/theory_variable.VH'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:d" will be overridden by "e/theory_variable:<class 'e/theory_variable.d'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:z_om" will be overridden by "e/theory_variable:<class 'e/theory_variable.z_om'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:z_oh" will be overridden by "e/theory_variable:<class 'e/theory_variable.z_oh'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:r_a" will be overridden by "e/theory_variable:<class 'e/theory_variable.r_a'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:g_a" will be overridden by "e/theory_variable:<class 'e/theory_variable.g_a'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:r_s" will be overridden by "e/theory_variable:<class 'e/theory_variable.r_s'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:g_s" will be overridden by "e/theory_variable:<class 'e/theory_variable.g_s'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:c1_e" will be overridden by "e/theory_variable:<class 'e/theory_variable.c1_e'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:c2_e" will be overridden by "e/theory_variable:<class 'e/theory_variable.c2_e'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:e" will be overridden by "e/theory_variable:<class 'e/theory_variable.e'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:T_min" will be overridden by "e/theory_variable:<class 'e/theory_variable.T_min'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:T_max" will be overridden by "e/theory_variable:<class 'e/theory_variable.T_max'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:RH_max" will be overridden by "e/theory_variable:<class 'e/theory_variable.RH_max'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:RH_min" will be overridden by "e/theory_variable:<class 'e/theory_variable.RH_min'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:e_a" will be overridden by "e/theory_variable:<class 'e/theory_variable.e_a'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:e_s" will be overridden by "e/theory_variable:<class 'e/theory_variable.e_s'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:iv_T" will be overridden by "e/theory_variable:<class 'e/theory_variable.iv_T'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:T_kv" will be overridden by "e/theory_variable:<class 'e/theory_variable.T_kv'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:P" will be overridden by "e/theory_variable:<class 'e/theory_variable.P'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:rho_a" will be overridden by "e/theory_variable:<class 'e/theory_variable.rho_a'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/variables/_core.py:89: UserWarning: "e/theory_variable:VPD" will be overridden by "e/theory_variable:<class 'e/theory_variable.VPD'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/equations/_core.py:107: UserWarning: "e/theory_equation:eq_m_n" will be overridden by "e/theory_equation:<class 'e/theory_equation.eq_m_n'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/equations/_core.py:107: UserWarning: "e/theory_equation:eq_MVG_neg_case" will be overridden by "e/theory_equation:<class 'e/theory_equation.eq_MVG_neg_case'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/equations/_core.py:107: UserWarning: "e/theory_equation:eq_MVG" will be overridden by "e/theory_equation:<class 'e/theory_equation.eq_MVG'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/equations/_core.py:107: UserWarning: "e/theory_equation:eq_sat_degree" will be overridden by "e/theory_equation:<class 'e/theory_equation.eq_sat_degree'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/equations/_core.py:107: UserWarning: "e/theory_equation:eq_MVG_h" will be overridden by "e/theory_equation:<class 'e/theory_equation.eq_MVG_h'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/equations/_core.py:107: UserWarning: "e/theory_equation:eq_h_FC" will be overridden by "e/theory_equation:<class 'e/theory_equation.eq_h_FC'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/equations/_core.py:107: UserWarning: "e/theory_equation:eq_theta_4_3" will be overridden by "e/theory_equation:<class 'e/theory_equation.eq_theta_4_3'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/equations/_core.py:107: UserWarning: "e/theory_equation:eq_theta_2_1" will be overridden by "e/theory_equation:<class 'e/theory_equation.eq_theta_2_1'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/equations/_core.py:107: UserWarning: "e/theory_equation:eq_water_stress_simple" will be overridden by "e/theory_equation:<class 'e/theory_equation.eq_water_stress_simple'>"
instance[expr] = instance
%%%% Output: stream
theta_sat
theta_res
alpha
n
m
S_mvg
theta
h
S
theta_4
theta_3
theta_2
theta_1
L
Mw
Pv
Pvs
R
T
c1
T0
Delta
E
G
H
Rn
LE
gamma
alpha_PT
c_p
w
kappa
z
u_star
VH
d
z_om
z_oh
r_a
g_a
r_s
g_s
c1_e
c2_e
e
T_min
T_max
RH_max
RH_min
e_a
e_s
iv_T
T_kv
P
rho_a
VPD
%%%% Output: stream
/opt/conda/lib/python3.8/site-packages/essm/equations/_core.py:107: UserWarning: "e/theory_equation:eq_Pvs_T" will be overridden by "e/theory_equation:<class 'e/theory_equation.eq_Pvs_T'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/equations/_core.py:107: UserWarning: "e/theory_equation:eq_Delta" will be overridden by "e/theory_equation:<class 'e/theory_equation.eq_Delta'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/equations/_core.py:107: UserWarning: "e/theory_equation:eq_PT" will be overridden by "e/theory_equation:<class 'e/theory_equation.eq_PT'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/equations/_core.py:107: UserWarning: "e/theory_equation:eq_PM" will be overridden by "e/theory_equation:<class 'e/theory_equation.eq_PM'>"
instance[expr] = instance
%%%% Output: stream
eq_m_n
eq_MVG_neg_case
eq_MVG
eq_sat_degree
eq_MVG_h
eq_h_FC
eq_theta_4_3
eq_theta_2_1
eq_water_stress_simple
eq_Pvs_T
eq_Delta
eq_PT
eq_PM
eq_PM_VPD
eq_PM_g
eq_PM_inv
%%%% Output: stream
/opt/conda/lib/python3.8/site-packages/essm/equations/_core.py:107: UserWarning: "e/theory_equation:eq_PM_VPD" will be overridden by "e/theory_equation:<class 'e/theory_equation.eq_PM_VPD'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/equations/_core.py:107: UserWarning: "e/theory_equation:eq_PM_g" will be overridden by "e/theory_equation:<class 'e/theory_equation.eq_PM_g'>"
instance[expr] = instance
/opt/conda/lib/python3.8/site-packages/essm/equations/_core.py:107: UserWarning: "e/theory_equation:eq_PM_inv" will be overridden by "e/theory_equation:<class 'e/theory_equation.eq_PM_inv'>"
## Data import, preprocess and shape for the computations
%% Cell type:markdown id:deadly-drove tags:
%% Cell type:markdown id:express-acoustic tags:
### Get the different files where data are stored
Eddy-covariance data from the OzFlux network are stored in **.nc** files (NetCDF4 files) which is roughly a panda data frame with meta-data (see https://www.unidata.ucar.edu/software/netcdf/ for more details about NetCDF4 file format). fPAR data are stored in **.txt** files
### Define and test a function that process the fPAR data
In the **.txt** files, only one value per month is given for the fPAR. The following function takes one .txt file containing data about the fPAR coefficients, and the related dates, stored in the a seperate file. The fPAR data (date and coefficients) are cleaned (good string formatting), mapped together and averaged to output one value per month (the fPAR measurement period doesn't spans the measurement period of the eddy covariance data)
Map the fPAR time serie to the given eddy-covariance data. Takes two dataframes as input (one containing the fPAR data, the other containing the eddy-covariance data) and returns a data frame where the fPAR monthly values have been scaled to the time scale of the eddy covariance data
%% Cell type:code id:widespread-subsection tags:
%% Cell type:code id:increasing-franchise tags:
``` python
deffPARSet(df_add,fPAR_pd):
# construct the time serie of the fPAR coefficients
Function taking the raw netcdf4 data file from the eddy covariance measurement and shape it such that it can be used for the computations. Only relevant variables are kept (latent heat flux, net radiation, ground heat flux, soil water content, wind speed, air temperature, VPD, bed shear stress). The desired data period is selected and is reshaped at the desired time scale (daily by default). Uses the fPARSet function defined above