Commit 9be50dee authored by Oscar Corvi's avatar Oscar Corvi
Browse files

remove useless parts of code in shape_stress_factor.ipynb

parent a832a12d
......@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "affecting-methodology",
"id": "perfect-deputy",
"metadata": {},
"source": [
"# **Mathematical shape of the stress factor function**"
......@@ -10,7 +10,7 @@
},
{
"cell_type": "markdown",
"id": "alternate-infection",
"id": "ruled-calcium",
"metadata": {
"slideshow": {
"slide_type": "slide"
......@@ -64,7 +64,7 @@
},
{
"cell_type": "markdown",
"id": "inappropriate-steel",
"id": "biblical-solution",
"metadata": {},
"source": [
"# Part II - Functions set up"
......@@ -72,7 +72,7 @@
},
{
"cell_type": "markdown",
"id": "cooked-investigator",
"id": "rational-adrian",
"metadata": {},
"source": [
"## Importing relevant packages"
......@@ -81,7 +81,7 @@
{
"cell_type": "code",
"execution_count": 1,
"id": "indian-sperm",
"id": "individual-amount",
"metadata": {},
"outputs": [
{
......@@ -146,7 +146,7 @@
},
{
"cell_type": "markdown",
"id": "industrial-signal",
"id": "swiss-article",
"metadata": {},
"source": [
"## Path of the different files (pre-defined python functions, sympy equations, sympy variables)"
......@@ -155,7 +155,7 @@
{
"cell_type": "code",
"execution_count": 57,
"id": "affecting-cursor",
"id": "independent-circular",
"metadata": {
"tags": [
"parameters"
......@@ -175,7 +175,7 @@
},
{
"cell_type": "markdown",
"id": "restricted-scheduling",
"id": "unauthorized-grill",
"metadata": {},
"source": [
"## Importing the sympy variables and equations defined in the theory.ipynb notebook"
......@@ -184,7 +184,7 @@
{
"cell_type": "code",
"execution_count": 3,
"id": "curious-incidence",
"id": "dedicated-fiction",
"metadata": {},
"outputs": [
{
......@@ -281,7 +281,7 @@
},
{
"cell_type": "markdown",
"id": "indie-grace",
"id": "latter-whale",
"metadata": {},
"source": [
"## Importing the performance assessment functions defined in the analysis_function.py file"
......@@ -290,7 +290,7 @@
{
"cell_type": "code",
"execution_count": 4,
"id": "increased-china",
"id": "dental-luxembourg",
"metadata": {},
"outputs": [
{
......@@ -342,7 +342,7 @@
},
{
"cell_type": "markdown",
"id": "after-theme",
"id": "happy-nursery",
"metadata": {},
"source": [
"## Data import, preprocess and shape for the computations"
......@@ -350,7 +350,7 @@
},
{
"cell_type": "markdown",
"id": "dietary-marker",
"id": "massive-processor",
"metadata": {},
"source": [
"### Get the different files where data are stored\n",
......@@ -361,7 +361,7 @@
{
"cell_type": "code",
"execution_count": 5,
"id": "aggressive-lithuania",
"id": "distant-validation",
"metadata": {},
"outputs": [
{
......@@ -391,7 +391,7 @@
},
{
"cell_type": "markdown",
"id": "pretty-colony",
"id": "excellent-nicholas",
"metadata": {},
"source": [
"### Define and test a function that process the fPAR data\n",
......@@ -401,7 +401,7 @@
{
"cell_type": "code",
"execution_count": 6,
"id": "suffering-modern",
"id": "negative-ambassador",
"metadata": {},
"outputs": [],
"source": [
......@@ -440,7 +440,7 @@
{
"cell_type": "code",
"execution_count": 7,
"id": "invisible-federal",
"id": "abandoned-symbol",
"metadata": {},
"outputs": [
{
......@@ -566,7 +566,7 @@
},
{
"cell_type": "markdown",
"id": "opened-assumption",
"id": "improving-triangle",
"metadata": {},
"source": [
"### fPARSet function\n",
......@@ -576,7 +576,7 @@
{
"cell_type": "code",
"execution_count": 8,
"id": "imperial-oxide",
"id": "cloudy-response",
"metadata": {},
"outputs": [],
"source": [
......@@ -607,7 +607,7 @@
},
{
"cell_type": "markdown",
"id": "vocal-lounge",
"id": "later-algebra",
"metadata": {},
"source": [
"### DataChose function\n",
......@@ -628,7 +628,7 @@
{
"cell_type": "code",
"execution_count": 9,
"id": "adult-default",
"id": "solar-closure",
"metadata": {},
"outputs": [],
"source": [
......@@ -721,7 +721,7 @@
},
{
"cell_type": "markdown",
"id": "amber-alexander",
"id": "auburn-pledge",
"metadata": {},
"source": [
"## Compile the different functions defined in the symbolic domain\n",
......@@ -730,7 +730,7 @@
},
{
"cell_type": "markdown",
"id": "cosmetic-failure",
"id": "supposed-merit",
"metadata": {},
"source": [
"### Water stress functions"
......@@ -739,7 +739,7 @@
{
"cell_type": "code",
"execution_count": 10,
"id": "friendly-convertible",
"id": "assured-infrared",
"metadata": {},
"outputs": [],
"source": [
......@@ -760,7 +760,7 @@
},
{
"cell_type": "markdown",
"id": "precious-feeding",
"id": "outdoor-festival",
"metadata": {},
"source": [
"### Soil water potential"
......@@ -769,7 +769,7 @@
{
"cell_type": "code",
"execution_count": 11,
"id": "requested-renaissance",
"id": "robust-geography",
"metadata": {},
"outputs": [],
"source": [
......@@ -785,7 +785,7 @@
{
"cell_type": "code",
"execution_count": 12,
"id": "sought-northwest",
"id": "neural-incidence",
"metadata": {},
"outputs": [],
"source": [
......@@ -802,7 +802,7 @@
},
{
"cell_type": "markdown",
"id": "selective-helen",
"id": "disturbed-arena",
"metadata": {},
"source": [
"### Penman-Monteith"
......@@ -811,7 +811,7 @@
{
"cell_type": "code",
"execution_count": 13,
"id": "broke-sessions",
"id": "aware-satisfaction",
"metadata": {},
"outputs": [],
"source": [
......@@ -830,7 +830,7 @@
{
"cell_type": "code",
"execution_count": 14,
"id": "aquatic-douglas",
"id": "atomic-masters",
"metadata": {},
"outputs": [],
"source": [
......@@ -858,7 +858,7 @@
{
"cell_type": "code",
"execution_count": 15,
"id": "native-college",
"id": "distributed-press",
"metadata": {},
"outputs": [],
"source": [
......@@ -880,7 +880,7 @@
{
"cell_type": "code",
"execution_count": 16,
"id": "bound-perth",
"id": "bibliographic-banner",
"metadata": {},
"outputs": [],
"source": [
......@@ -902,7 +902,7 @@
{
"cell_type": "code",
"execution_count": 17,
"id": "brazilian-calvin",
"id": "acceptable-nursery",
"metadata": {},
"outputs": [],
"source": [
......@@ -924,7 +924,7 @@
{
"cell_type": "code",
"execution_count": 18,
"id": "center-minister",
"id": "compliant-instruction",
"metadata": {},
"outputs": [],
"source": [
......@@ -952,7 +952,7 @@
{
"cell_type": "code",
"execution_count": 19,
"id": "fuzzy-crawford",
"id": "sophisticated-edwards",
"metadata": {},
"outputs": [],
"source": [
......@@ -983,7 +983,7 @@
{
"cell_type": "code",
"execution_count": 20,
"id": "cordless-master",
"id": "passive-compiler",
"metadata": {},
"outputs": [],
"source": [
......@@ -1012,7 +1012,7 @@
{
"cell_type": "code",
"execution_count": 21,
"id": "impressed-coordination",
"id": "sonic-thumbnail",
"metadata": {},
"outputs": [],
"source": [
......@@ -1046,7 +1046,7 @@
{
"cell_type": "code",
"execution_count": 22,
"id": "increased-windows",
"id": "chronic-tobacco",
"metadata": {},
"outputs": [],
"source": [
......@@ -1069,7 +1069,7 @@
{
"cell_type": "code",
"execution_count": 23,
"id": "olive-infrastructure",
"id": "gross-flashing",
"metadata": {},
"outputs": [],
"source": [
......@@ -1087,7 +1087,7 @@
},
{
"cell_type": "markdown",
"id": "massive-community",
"id": "meaningful-adaptation",
"metadata": {},
"source": [
"### Assign the different compiled functions to variables functions (create the functions in python)"
......@@ -1096,7 +1096,7 @@
{
"cell_type": "code",
"execution_count": 24,
"id": "worldwide-kentucky",
"id": "recent-guidance",
"metadata": {},
"outputs": [],
"source": [
......@@ -1124,7 +1124,7 @@
{
"cell_type": "code",
"execution_count": 25,
"id": "excited-collection",
"id": "proper-venue",
"metadata": {},
"outputs": [],
"source": [
......@@ -1158,7 +1158,7 @@
},
{
"cell_type": "markdown",
"id": "strange-inventory",
"id": "technical-making",
"metadata": {},
"source": [
"## Functions to run the different models\n",
......@@ -1167,7 +1167,7 @@
},
{
"cell_type": "markdown",
"id": "square-ready",
"id": "desperate-copyright",
"metadata": {},
"source": [
"### Varying surface resistance model"
......@@ -1176,7 +1176,7 @@
{
"cell_type": "code",
"execution_count": 26,
"id": "classified-concept",
"id": "floppy-nomination",
"metadata": {},
"outputs": [],
"source": [
......@@ -1239,7 +1239,7 @@
},
{
"cell_type": "markdown",
"id": "editorial-murder",
"id": "basic-municipality",
"metadata": {},
"source": [
"### Constant surface conductance model"
......@@ -1248,7 +1248,7 @@
{
"cell_type": "code",
"execution_count": 27,
"id": "removed-timing",
"id": "arabic-yorkshire",
"metadata": {},
"outputs": [],
"source": [
......@@ -1312,7 +1312,7 @@
},
{
"cell_type": "markdown",
"id": "junior-organizer",
"id": "incredible-costa",
"metadata": {},
"source": [
"### Benchmark Penman-Monteith model"
......@@ -1321,7 +1321,7 @@
{
"cell_type": "code",
"execution_count": 28,
"id": "indian-newark",
"id": "pressed-neutral",
"metadata": {},
"outputs": [],
"source": [
......@@ -1380,7 +1380,7 @@
},
{
"cell_type": "markdown",
"id": "improving-floating",
"id": "bottom-cooler",
"metadata": {},
"source": [
"### Modified version of the PM equation\n",
......@@ -1396,7 +1396,7 @@
{
"cell_type": "code",
"execution_count": 29,
"id": "three-response",
"id": "alpha-renaissance",
"metadata": {},
"outputs": [],
"source": [
......@@ -1460,7 +1460,7 @@
{
"cell_type": "code",
"execution_count": 30,
"id": "raised-nowhere",
"id": "inside-startup",
"metadata": {},
"outputs": [],
"source": [
......@@ -1524,7 +1524,7 @@
},
{
"cell_type": "markdown",
"id": "municipal-pakistan",
"id": "brave-folks",
"metadata": {},
"source": [
"### Priestley and Taylor model"
......@@ -1533,7 +1533,7 @@
{
"cell_type": "code",
"execution_count": 31,
"id": "massive-jurisdiction",
"id": "passive-integral",
"metadata": {},
"outputs": [],
"source": [
......@@ -1588,7 +1588,7 @@
},
{
"cell_type": "markdown",
"id": "raising-preference",
"id": "consecutive-ordinary",
"metadata": {},
"source": [
"### Inverse modelling\n",
......@@ -1598,7 +1598,7 @@
{
"cell_type": "code",
"execution_count": 32,
"id": "spare-cache",
"id": "convenient-privilege",
"metadata": {},
"outputs": [],
"source": [
......@@ -1652,7 +1652,7 @@
},
{
"cell_type": "markdown",
"id": "banner-beast",
"id": "armed-penalty",
"metadata": {},
"source": [
"## Calibration algorithm"
......@@ -1660,7 +1660,7 @@
},
{
"cell_type": "markdown",
"id": "particular-heating",
"id": "brilliant-agent",
"metadata": {},
"source": [
"Use the global optimizer from the `scipy.optimize` package. Minimize the squared residual :\n",
......@@ -1672,7 +1672,7 @@
{
"cell_type": "code",
"execution_count": 33,
"id": "stylish-myrtle",
"id": "ranging-broad",
"metadata": {},
"outputs": [],
"source": [
......@@ -1702,7 +1702,7 @@
{
"cell_type": "code",
"execution_count": 34,
"id": "original-spell",
"id": "liberal-letters",
"metadata": {},
"outputs": [],
"source": [
......@@ -1721,7 +1721,7 @@
},
{
"cell_type": "markdown",
"id": "abandoned-saver",
"id": "virgin-pointer",
"metadata": {},
"source": [
"# Part III - Experiments"
......@@ -1729,7 +1729,7 @@
},
{
"cell_type": "markdown",
"id": "flying-blocking",
"id": "continuing-distributor",
"metadata": {},
"source": [
"## One site, one year\n",
......@@ -1739,7 +1739,7 @@
{
"cell_type": "code",
"execution_count": 35,
"id": "plain-cycle",
"id": "buried-narrative",
"metadata": {},
"outputs": [
{
......@@ -10426,7 +10426,7 @@
{
"cell_type": "code",
"execution_count": 36,
"id": "solved-wagon",
"id": "incorrect-shopping",
"metadata": {},
"outputs": [
{
......@@ -10814,597 +10814,7 @@
},
{
"cell_type": "markdown",
"id": "facial-basketball",
"metadata": {},
"source": [
"## Focusing on the constant surface resistance model"
]
},
{
"cell_type": "code",
"execution_count": 39,
"id": "silent-scheduling",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([ 0.01, 0.1 , -5. ])"
]
},
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Res_PM_var = calibration(Data, PM_run_var, bounds = [(0.01,0.2),(0.1,1),(-5,2)])\n",
"Res_PM_cst = calibration(Data,PM_run_cst, bounds = [(0.01,0.2),(0.1,1),(-5,2)])\n",
"Res_PM_cst"
]
},
{
"cell_type": "markdown",
"id": "established-principle",
"metadata": {},
"source": [
"### Compute the model results with the optimimum parameters"
]
},
{
"cell_type": "code",
"execution_count": 40,
"id": "understanding-positive",
"metadata": {},
"outputs": [
{
"ename": "TypeError",
"evalue": "PM_run_var() missing 1 required positional argument: 'shape'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-40-934efa5859b0>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mTimeSerie_var\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mPM_run_var\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mData\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mRes_PM_var\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mRes_PM_var\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mTimeSerie_cst\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mPM_run_cst\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mData\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mRes_PM_cst\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mRes_PM_cst\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mTimeSerie_PM\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mPM_run_classic\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mData\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mTypeError\u001b[0m: PM_run_var() missing 1 required positional argument: 'shape'"
]
}
],
"source": [
"TimeSerie_var = PM_run_var(Data, Res_PM_var[0], Res_PM_var[1])\n",
"TimeSerie_cst = PM_run_cst(Data, Res_PM_cst[0], Res_PM_cst[1])\n",
"TimeSerie_PM = PM_run_classic(Data)"
]
},
{
"cell_type": "markdown",
"id": "confidential-transport",
"metadata": {},
"source": [
"### Aggregate the results in a single matrix"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "positive-multimedia",
"metadata": {},
"outputs": [],
"source": [
"DummyVar = pd.DataFrame(TimeSerie_var, index = Data.index)\n",
"DummyVar = DummyVar.rename(columns = {0:\"Varying_gS\"})\n",
"TimeSerie_mat = pd.concat([Data.Fe,DummyVar], axis = 1)\n",
"DummyVar = pd.DataFrame(TimeSerie_cst, index = Data.index)\n",
"DummyVar = DummyVar.rename(columns = {0:\"Constant_gS\"})\n",
"TimeSerie_mat = pd.concat([TimeSerie_mat,DummyVar], axis = 1)\n",
"DummyVar = pd.DataFrame(TimeSerie_PM, index = Data.index)\n",
"DummyVar = DummyVar.rename(columns = {0:\"Benchmark_PM\"})\n",
"TimeSerie_mat = pd.concat([TimeSerie_mat,DummyVar], axis = 1)\n",
"\n",
"# convert into mm/day\n",
"TimeSerie_mat = TimeSerie_mat*60*60*24"
]
},