Commit 55320755 authored by Oscar Corvi's avatar Oscar Corvi
Browse files

update the README and delet the files from location_stress_factor.ipynb -->...

update the README and delet the files from location_stress_factor.ipynb --> everything is done in simpler_model.ipynb
parent 181331f3
Pipeline #235494 passed with stage
in 21 seconds
# LEAVE_II
# LEAVES Project (actuaL-potEntiAl eVapotranspiration rElation aSsessment)
Testing the approach of Feddes (1978) to assess actual evapotranspiration out of potential one.
For the workflow to be reproducible and clear, all computations, models and derivations are implemented using symbolic mathematics (sympy module)
This project investigates the assessment of actual evapo-transpiration out of potential evapo-transpiration models under water stressed conditions. The workflow is coded in python. The scripts tagged **main scripts** produce the main results of the project. The notebooks with the extension `.ran.ipynb` are those created while running renku, they are part of the knowledge graph (accessible from the RenkuLab interface --> files --> tab *Lineage*, next to *Contents*). All the `.png` files in the folder tagged **main scripts** are inlcuded in the knowledge graph as well.
## **Data file structure**
The structure of the repository is the following :
* data : Folder containing all the data sets (experiemental dataset and created datasets during the computations)
* Contains Howard_Spring_L4 data set in the subfolder howard_spring_l4, gap filled time serie of atmospheric variables measured at the Howard Spring location (Australia)
* Results of the different modeling scenarios in subfolders scenario_i
* graphs : Contains all the created graphs, ordered by scenarios their respective sub folders
* data : Folder containing all the data sets used for this project
* eddycovdata
* `.nc files` : NETCFD4 files from the eddy covariance OzFlux database
* `.txt files` : fpar time series of the different sites
* notebooks : All the computationnal material (.ipynb and .py files)
* folder scen1:
* folder naive_run: Scenario with no calibration. Contains :
* evaluation.ipynb : using all the previously defined variables and equations to process the experimental data
* analysis.ipynb : analysing the results obtained in evaluation.ipynb
* folder calibration: Calibration of scen1. Contains :
* calibrationipynb : Monte_carlo run to calibrate the model
* wet_season.txt : coefficient set for the wet season (alpha, theta_1, theta_3 in this order)
* dry_season.txt : coefficient set for the dry season (alpha, theta_1, theta_3 in this order)
* folder theory : contains definition of all variables and equations used in this project:
* theory.ipynb : file defining all the variables
* pyFile_storage : contains the .py files :
* theory_variable.py : all variables defined
* theory_equation.py : all equations defined
* analysis_function.py : RMSE, Nash, ...
* Data_explore:
* `data_explore.ipynb`: visual and basic exploration of the datasets of the different study sites
* theory:
* `theory.ipynb`: notebook defining all the physical variables and equations in the symbolic domain using sympy and ESSM
* pyFile_storage:
* `theory_variable.py`: .py file automatically created from `theory.ipynb` that contains the definition of the different variables used in the project. Having a separated .py file allows to call the variables defined in `theory.ipynb` in other scripts/notebooks.
* `theory_equation.py`: .py file automatically created from `theory.ipynb` that contains the definition of the different equations used in the project. Having a separated .py file allows to call the equations defined in `theory.ipynb` in other scripts/notebooks.
* `analysis_function.py`: .py file containing the function of the different metrics (fitting performance) used in the project
* Finished_project:
* simpler_model:
* `simpler_model.ipynb`: experiments 1.X (exploration and comparison of the different models, sensitivity to changes in atmospheric forcing, sensitivity to calibration parameters, inverse modelling fitting, statistical fitting performance, systematic site assessment), **main script**
* latex_files: store the metric results as latex tables (`.txt` files)
* meaning_stress_factor:
* `meaning_stress_factor.ipynb`: experiments 2.X (information contained in the $f_{PAR}$ coefficient, comparing the complete and incomplete $g_s$ models), **main script**
* stress_factor_shape:
* `stress_factor_shape.ipynb`: experiments 3.X (non linear definition of the stress factor), **main script**
* Ws_sensitivity:
* `wind_speed_sensitivity.ipynb`: investigating the dependance of the Penman-Monteith model to wind speed using sympy and ESSM
* Miscellaneous:
* var_VS_cst:
* var_VS_cst.ipynb
* var_cst_assessment.ipynb
* soilPotential:
* WaterPotential.ipynb
* siteAssessment:
* modelRun.ipynb
* inverseModelling.ipynb
* fParAssess.ipynb
* modelAssessment:
* RsParameterVariability.ipynb
* fPAR_effect:
* LAI_effect.ipynb
* fPAR_effect.ipynb
* conductance:
* YearThetaFunc.ipynb
* modelRun_conductance.ipynb
* fitModel_error.ipynb
* compare_g_VOM:
* soil_conductance.ipynb
* aesara_test:
* aesara_assessment.ipynb
* Dockerfile
* environment.yml
* README.md : information about the project and it organisation
* Renku_commands.txt : All the Renku commands used in this project
* requirements.txt : required python packages for this project
**NB**: Important folders to look into :
* fPAR_effect
* var_VS_cst
* PT_superior
\ No newline at end of file
* requirements.txt : required python packages for this project
\ No newline at end of file
This source diff could not be displayed because it is stored in LFS. You can view the blob instead.
import matplotlib.pyplot as plt
from sympy import latex
from sympy import N
from numpy import arange
from essm.variables.units import derive_unit, SI, Quantity
from essm.variables.utils import markdown
def plot_expr2(xvar_min_max, yldata, yllabel=None, yrdata=None,
yrlabel='', clf=True, npoints=100, ylmin=None, ylmax=None,
yrmin=None, yrmax=None, xlabel=None,
colors=None,
loc_legend_left='best', loc_legend_right='right',
linestylesl=['-', '--', '-.', ':'],
linestylesr=['-', '--', '-.', ':'],
fontsize=None, fontsize_ticks=None, fontsize_labels=None,
fontsize_legend=None, xaxispos=None, yaxispos=None,
fig1=None, **args):
'''
Plot expressions as function of xvar from xmin to xmax.
**Examples:**
from essm.variables import Variable
from essm.variables.physics.thermodynamics import T_a
from essm.equations.physics.thermodynamics import eq_nua, eq_ka
vdict = Variable.__defaults__.copy()
expr = eq_nua.subs(vdict)
exprr = eq_ka.subs(vdict)
xvar = T_a
yldata = [(expr.rhs, 'full'), (expr.rhs/2, 'half')]
yrdata = exprr
plot_expr2((T_a, 273, 373), yldata, yllabel = (nu_a), yrdata=yrdata)
plot_expr2((T_a, 273, 373), yldata, yllabel = (nu_a),
yrdata=[(1/exprr.lhs, 1/exprr.rhs)],
loc_legend_right='lower right')
plot_expr2((T_a, 273, 373), expr)
plot_expr2((T_a, 273, 373), yldata, yllabel = (nu_a))
'''
(xvar, xmin, xmax) = xvar_min_max
if not colors:
if yrdata is not None:
colors = ['black', 'blue', 'red', 'green']
else:
colors = ['blue', 'black', 'red', 'green']
if fontsize:
fontsize_labels = fontsize
fontsize_legend = fontsize
fontsize_ticks = fontsize
if not fig1:
plt.close
plt.clf
fig = plt.figure(**args)
else:
fig = fig1
if hasattr(xvar, 'definition'):
unit1 = xvar.definition.unit
if unit1 != 1:
strunit = ' (' + markdown(unit1) + ')'
else:
strunit = ''
if not xlabel:
xlabel = '$'+latex(xvar)+'$'+ strunit
else:
if not xlabel:
xlabel = xvar
if hasattr(yldata, 'lhs'):
yldata = (yldata.rhs, yldata.lhs)
if not yllabel:
if type(yldata) is tuple:
yllabel = yldata[1]
else:
try:
yllabel = yldata[0][1]
except Exception as e1:
print(e1)
print('yldata must be equation or list of (expr, name) tuples')
if type(yllabel) is not str:
unit1 = yllabel.definition.unit
if unit1 != 1:
strunit = ' (' + markdown(unit1) + ')'
else:
strunit = ''
yllabel = '$'+latex(yllabel)+'$'+ strunit
if type (yldata) is not list and type(yldata) is not tuple:
# If only an expression given
yldata = [(yldata, '')]
if type(yldata[0]) is not tuple:
yldata = [yldata]
if yrdata is not None:
if yrlabel == '':
if hasattr(yrdata, 'lhs'):
yrlabel = yrdata.lhs
if type (yrdata) is not list and type(yrdata) is not tuple:
# If only an expression given
yrdata = [yrdata]
if type(yrlabel) is not str:
yrlabel = '$'+latex(yrlabel)+'$'+ ' (' + markdown(yrlabel.definition.unit) + ')'
xstep = (xmax - xmin)/npoints
xvals = arange(xmin, xmax, xstep)
ax1 = fig.add_subplot(1, 1, 1)
if yrdata is not None:
color = colors[0]
else:
color = 'black'
ax1.set_xlabel(xlabel)
ax1.set_ylabel(yllabel, color=color)
ax1.tick_params(axis='y', labelcolor=color)
i = 0
for (expr1, y1var) in yldata:
linestyle = linestylesl[i]
if yrdata is None:
color = colors[i]
i= i + 1
try:
y1vals = [expr1.subs(xvar, dummy).n() for dummy in xvals]
ax1.plot(xvals, y1vals, color=color, linestyle=linestyle, label=y1var)
except Exception as e1:
print([expr1.subs(xvar, dummy) for dummy in xvals])
print(e1)
if i > 1 or yrdata is not None:
plt.legend(loc=loc_legend_left, fontsize=fontsize_legend)
if ylmin is not None: ax1.set_ylim(bottom=float(ylmin))
if ylmax is not None: ax1.set_ylim(top=float(ylmax))
if yrdata is not None:
ax2 = ax1.twinx() # instantiate a second axes that shares the same x-axis
color = colors[1]
ax2.set_ylabel(yrlabel, color=color)
i = 0
for item in yrdata:
if type(item) is tuple: # if item is tuple
(expr2, y2var) = item
else:
try:
(y2var, expr2) = (item.lhs, item.rhs)
except Exception as e1:
print(e1)
print('yrdata must be a list of equations or tuples (var, expr)')
return
linestyle = linestylesr[i]
i = i + 1
try:
y2vals = [expr2.subs(xvar, dummy).n() for dummy in xvals]
ax2.plot(xvals, y2vals, color=color, linestyle=linestyle, label=y2var)
except Exception as e1:
print(expr2)
print([expr2.subs(xvar, dummy).n() for dummy in xvals])
print(e1)
if not yrlabel:
if hasattr(yrdata[0], 'lhs'):
yrlabel = yrdata[0].lhs
if type(yrlabel) is not str:
yrlabel = '$'+latex(yrlabel)+'$'+ ' (' + markdown(yrlabel.definition.unit) + ')'
ax2.tick_params(axis='y', labelcolor=color)
if yrmin: ax2.set_ylim(ymin=float(yrmin))
if yrmax: ax2.set_ylim(ymax=float(yrmax))
leg=ax2.legend(loc=loc_legend_right, fontsize=fontsize_legend)
ax2.add_artist(leg);
for item in ([ax2.xaxis.label, ax2.yaxis.label]):
item.set_fontsize(fontsize_labels)
ax2.tick_params(axis='both', which='major', labelsize=fontsize_ticks)
for item in ([ax1.xaxis.label, ax1.yaxis.label]):
item.set_fontsize(fontsize_labels)
ax1.tick_params(axis='both', which='major', labelsize=fontsize_ticks)
if yaxispos is not None:
print(yaxispos)
# Make y-axis intersect at xaxispos and remove frame
ax1.spines['left'].set_position(('data', yaxispos))
ax1.spines['right'].set_visible(False)
ax1.spines['top'].set_visible(False)
if xaxispos is not None:
print(xaxispos)
# Make x-axiss intersect at xaxispos and remove frame
ax1.spines['bottom'].set_position(('data', xaxispos))
ax1.spines['right'].set_visible(False)
ax1.spines['top'].set_visible(False)
fig.tight_layout() # otherwise the right y-label is slightly clipped
return fig
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