Skip to content

Instantly share code, notes, and snippets.

@pradal
Created February 25, 2018 12:54
Show Gist options
  • Save pradal/36ad6aa4d30b995b0488f9a44c4ee4f7 to your computer and use it in GitHub Desktop.
Save pradal/36ad6aa4d30b995b0488f9a44c4ee4f7 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Automatic generation of Notebook using PyCropML\n",
"This notebook implements a crop model."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"def my_first_plant_growth_model(BaseTemp=0.0,\n",
" MinTemp=0.0,\n",
" GrowthRate=0.01,\n",
" GrowthRateResponse=0.1,\n",
" PlantAvailableWater=0.35,\n",
" DroughtSensitivity=0.35,\n",
" AvailableWater=0.35,\n",
" BoltzmannConstant=2.4903,\n",
" AtmosphericEmisivity=0.5):\n",
"\n",
" \"\"\" My First Plant Growth Model\n",
"\n",
" Author: AMEI Workshop Participants\n",
" Reference: absolutely non\n",
" Instituton: INRA Paris\n",
" Abstract: Extremely complex value calculator\n",
" \"\"\"\n",
" FW = ( ( ( PlantAvailableWater - AvailableWater ) / PlantAvailableWater ) ** DroughtSensitivity )\n",
" FNLW = BoltzmannConstant * AtmosphericEmisivity * MinTemp ** 4\n",
" PlantGrowth = GrowthRate * ( BaseTemp - MinTemp ) * FW * FNLW\n",
" return PlantGrowth\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Run the model with a set of parameters.\n",
"Each run will be defined in its own cell."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2.63\n"
]
}
],
"source": [
"params= my_first_plant_growth_model(\n",
" AvailableWater = 45,\n",
" DroughtSensitivity = 0.75,\n",
" BaseTemp = 5.0,\n",
" GrowthRateResponse = 0.12,\n",
" MinTemp = 4,\n",
" GrowthRate = 0.02,\n",
" PlantAvailableWater = 65.0,\n",
" )\n",
"print(round(params, 2))\n",
"\n",
"\n",
"# output = 2.63"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2.26\n"
]
}
],
"source": [
"params= my_first_plant_growth_model(\n",
" AvailableWater = 35.0,\n",
" DroughtSensitivity = 0.75,\n",
" BaseTemp = 5.0,\n",
" GrowthRateResponse = 0.12,\n",
" MinTemp = 3,\n",
" GrowthRate = 0.02,\n",
" PlantAvailableWater = 65.0,\n",
" )\n",
"print(round(params, 2))\n",
"\n",
"\n",
"# output = 2.26"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"3.3\n"
]
}
],
"source": [
"params= my_first_plant_growth_model(\n",
" AvailableWater = 38.0,\n",
" DroughtSensitivity = 0.75,\n",
" BaseTemp = 5.0,\n",
" GrowthRateResponse = 0.12,\n",
" MinTemp = 4.0,\n",
" GrowthRate = 0.02,\n",
" PlantAvailableWater = 65.0,\n",
" )\n",
"print(round(params, 2))\n",
"\n",
"\n",
"# output = 3.3"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "IPython (Python 2)",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.14"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
@cyrillemidingoyi
Copy link

Hi Christophe.
I test it.

@marcellodonatelli
Copy link

Do you plan to make any use of info on declarative representation to generate code for unit tests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment