Skip to content
Snippets Groups Projects
Commit 08d4d7a3 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

First version with charts and cool stuff!

parent 3710f9cc
No related branches found
No related tags found
No related merge requests found
File added
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-09-01 14:19+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: templates/calculators/eil.html:25
#: templates/calculators/eil.html.py:27
msgid "Economic injury level (EIL) calculator"
msgstr "Økonomisk skadeterskelkalkulator (EIL)"
#: templates/calculators/eil.html:32
msgid "Input"
msgstr "Inndata"
#: templates/calculators/eil.html:35
msgid "The cost of purchasing and applying the control action (insecticide)"
msgstr "Kostnaden ved innkjøp og bruk av bekjempelsesmetode (f.eks. plantevernmiddel)"
#: templates/calculators/eil.html:36
msgid "Control cost"
msgstr "Bekjempelseskostnad"
#: templates/calculators/eil.html:42
msgid "The market value of the crop in local currency per weight unit"
msgstr "Markedsverdi i lokal valuta pr vektenhet"
#: templates/calculators/eil.html:43
msgid "Market value"
msgstr "Markedsverdi i lokal valuta"
#: templates/calculators/eil.html:49
msgid ""
"The maximum yield per production unit. Historical values are typically used "
"for this expression."
msgstr "Maksimalt avlingsnivå per arealenhet. Det er vanlig å bruke historiske "
"verdier."
#: templates/calculators/eil.html:50
msgid "Yield potential"
msgstr "Avlingspotensial"
#: templates/calculators/eil.html:57
msgid "The proportion of the pest population killed."
msgstr "Andelen av skadegjører som drepes"
#: templates/calculators/eil.html:58
msgid "Control efficacy"
msgstr "Bekjempelseseffekt"
#: templates/calculators/eil.html:64
msgid "Damage expressed as crop yield loss per pest measuring unit"
msgstr "Skade uttrykt som avlingstap per skadegjørermåleenhet"
#: templates/calculators/eil.html:65
msgid "Damage per pest measuring unit"
msgstr "Skade per skadegjørermåleenhet"
#: templates/calculators/eil.html:69
msgid "Settings"
msgstr "Innstillinger"
#: templates/calculators/eil.html:71
msgid "Currency"
msgstr "Valuta"
#: templates/calculators/eil.html:75
msgid "Crop mass unit"
msgstr "Avlingsmasseenhet"
#: templates/calculators/eil.html:79
msgid "Crop area unit"
msgstr "Avlingsarealenhet"
#: templates/calculators/eil.html:83
msgid "Pest measuring unit"
msgstr "Skadegjørermåleenhet"
#: templates/calculators/eil.html:84
msgid "Number of aphids per plant"
msgstr "Antall bladlus per plante"
#: templates/calculators/eil.html:87
msgid "Run model"
msgstr "Kjør modell"
#: templates/calculators/eil.html:91
msgid "Results"
msgstr "Resultater"
#: templates/calculators/eil.html:93
msgid "Calculated EIL"
msgstr "Beregnet EIL"
#: templates/calculators/eil.html:115
msgid "EIL as a function of yield loss per pest unit"
msgstr "EIL som funksjon av avlingstap per skadegjørerenhet"
#: templates/calculators/eil.html:116
msgid "EIL as a function of control cost"
msgstr "EIL som funksjon av bekjempelseskostnad"
#: templates/calculators/eil.html:117
msgid "EIL as a function of market value"
msgstr "EIL som funksjon av markedsverdi"
#: templates/calculators/eil.html:118
msgid "EIL as a function of yield potential"
msgstr "EIL som funksjon av avlingspotensial"
#: templates/calculators/eil.html:119
msgid "EIL as a function of insecticide efficacy"
msgstr "EIL som funksjon av bekjempelseseffekt"
#: templates/calculators/index.html:25
#: templates/calculators/index.html:27
msgid "Calculators"
msgstr "Kalkulatorer"
......@@ -35,6 +35,7 @@ function calculateEIL(C,V,Yp,K,D)
{
// From Pedigo et al (1986)
return C / (V * Yp * (K/100) * D);
//return C / (V * Yp * K * D);
}
function renderResult(formId)
......@@ -52,4 +53,89 @@ function renderResult(formId)
document.getElementById("resultParameters").innerHTML = resultParameters;
document.getElementById("resultValue").innerHTML = resultValue;
}
function renderCharts(formId){
var chartContainerIds = ["EILvC","EILvV","EILvYp","EILvK"];
var theForm = document.getElementById(formId);
// Get the settings right
var currency = theForm["currency"].value;
document.getElementById("currency1").innerHTML=currency;
document.getElementById("currency2").innerHTML=currency;
var cropAreaUnit = theForm["cropAreaUnit"].value;
document.getElementById("cropAreaUnit1").innerHTML=cropAreaUnit;
document.getElementById("cropAreaUnit2").innerHTML=cropAreaUnit;
var cropMassUnit = theForm["cropMassUnit"].value;
document.getElementById("cropMassUnit1").innerHTML=cropMassUnit;
document.getElementById("cropMassUnit2").innerHTML=cropMassUnit;
document.getElementById("cropMassUnit3").innerHTML=cropMassUnit;
var pestMeasuringUnit = theForm["pestMeasuringUnit"].value;
document.getElementById("pestMeasuringUnit").innerHTML = pestMeasuringUnit;
if(theForm["D"].value != "")
{
for(var i in chartContainerIds)
{
document.getElementById(chartContainerIds[i]).style.display="block";
//document.getElementById(chartContainerIds[i]).style.width=document.getElementById("EILvD").style.width;
}
renderEILChart(formId, "EILvC", "C", currency + "/" + cropAreaUnit, 0,500,1,chartTitles["EILvC"]);
renderEILChart(formId, "EILvV", "V", currency + "/" + cropMassUnit, 1,100,1,chartTitles["EILvV"]);
renderEILChart(formId, "EILvYp", "Yp", cropMassUnit + "/" + cropAreaUnit, 1,200,1,chartTitles["EILvYp"]);
renderEILChart(formId, "EILvK", "K", "%", 1,100,0.1,chartTitles["EILvK"]);
//document.getElementById("chartContainer").style.display="block";
renderResult(formId);
}
else
{
for(var i in chartContainerIds)
{
document.getElementById(chartContainerIds[i]).style.display="none";
}
//
}
renderEILChart(formId, "EILvD", "D", cropMassUnit + "/" + pestMeasuringUnit, 0.1,5,0.1,chartTitles["EILvD"]);
}
function renderEILChart(formId, containerId, paramName, paramUnit, paramMin, paramMax, step, chartTitle)
{
// Create the data set
var theForm = document.getElementById(formId);
var data = [];
for(var i=paramMin;i<=paramMax;i+=step)
{
data[data.length] = [i,calculateEIL(
paramName == "C" ? i : theForm["C"].value,
paramName == "V" ? i : theForm["V"].value,
paramName == "Yp" ? i : theForm["Yp"].value,
paramName == "K" ? i : theForm["K"].value,
paramName == "D" ? i : theForm["D"].value
)
];
}
//console.log(data);var pestMeasuringUnit = theForm["pestMeasuringUnit"].value;
var options = {
title: {
text: chartTitle,
},
chart: {
renderTo: containerId,
type: 'spline',
zoomType: "x"
},
xAxis: {
title: {text:paramName + " (" + paramUnit + ")"}
},
yAxis: {
title: {text:"EIL (" + theForm["pestMeasuringUnit"].value + ")"},
floor: 0
},
series: [
{"data":data}
],
legend: {enabled: false}
};
var chart = new Highcharts.Chart(options);
}
\ No newline at end of file
......@@ -28,51 +28,77 @@
<p>(Forklaring...)</p>
<form role="form" id="{{ form_id }}">
<div class="row">
<div class="col-md-6">
<div class="col-md-3">
<h1>{% trans "Input" %}</h1>
<div class="form-group">
<label for="C">{% trans "Control cost" %} (C) [NOK/daa]</label> <br/>
(the cost of purchasing and applying the control action (insecticide), expressed as dollar amount per acre ($/acre).)
<input type="number" name="C" class="form-control" min="0" onblur="validateField(this);"/>
<label for="C" data-toggle="tooltip" data-placement="top"
title="{% trans "The cost of purchasing and applying the control action (insecticide)" %}"
>{% trans "Control cost" %} (C) [<span id="currency1">NOK</span>/<span id="cropAreaUnit1">daa</span>]</label><br/>
<input type="number" name="C" class="form-control" min="0" value="200" onblur="validateField(this);" onchange="renderCharts('{{ form_id }}');"/>
<span class="help-block" id="{{ form_id }}_C_validation"></span>
</div>
<div class="form-group">
<label for="V">{% trans "Market value" %} (V) [NOK/kg]</label><br/>
the market value of peas or the contracted price per hundred-weight, expressed as the dollar amount per hundred-weight ($/cwt).
<input type="number" name="V" class="form-control" min="0" onblur="validateField(this);"/>
<label for="V" data-toggle="tooltip" data-placement="top"
title="{% trans "The market value of the crop in local currency per weight unit" %}"
>{% trans "Market value" %} (V) [<span id="currency2">NOK</span>/<span id="cropMassUnit1">kg</span>]</label><br/>
<input type="number" name="V" class="form-control" min="0" value="40" onblur="validateField(this);" onchange="renderCharts('{{ form_id }}');"/>
<span class="help-block" id="{{ form_id }}_V_validation"></span>
</div>
<div class="form-group">
<label for="Yp">{% trans "Yield potential" %} (Yp) [kg/daa]</label><br/>
the maximum yield per production unit, expressed as hundred-weight per acre (cwt/acre), historical values are typically used for this expression.
<input type="number" name="Yp" class="form-control" min="0" onblur="validateField(this);"/>
<label for="Yp" data-toggle="tooltip" data-placement="top"
title="{% trans "The maximum yield per production unit. Historical values are typically used for this expression." %}"
>{% trans "Yield potential" %} (Yp) [<span id="cropMassUnit2">kg</span>/<span id="cropAreaUnit2">daa</span>]</label><br/>
<input type="number" name="Yp" class="form-control" min="0" value="1000" onblur="validateField(this);" onchange="renderCharts('{{ form_id }}');"/>
<span class="help-block" id="{{ form_id }}_Yp_validation"></span>
</div>
<div class="form-group">
<button type="button" class="btn btn-default" onclick="if(validateForm(document.getElementById('{{ form_id }}'))){renderResult('{{ form_id }}');}">{% trans "Run model" %}</button>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="K">{% trans "Insecticide efficacy" %} (K) [%]</label><br/>
the efficacy of any insecticide is the proportion of the pest population killed, it can range from 0 to 1 (typically it is expressed as 1, meaning 100% of the pest population is killed).
<input type="number" name="K" class="form-control" min="0" max="1" onblur="validateField(this);"/>
<label for="K" data-toggle="tooltip" data-placement="top"
title="{% trans "The proportion of the pest population killed." %}"
>{% trans "Control efficacy" %} (K) [%]</label><br/>
<input type="number" name="K" class="form-control" min="0" max="100" value="50" onblur="validateField(this);" onchange="renderCharts('{{ form_id }}');"/>
<span class="help-block" id="{{ form_id }}_K_validation"></span>
</div>
<div class="form-group">
<label for="D">{% trans "Damage per pest individual" %} (?) (D) [kg/skadegjørermåleenhet]</label> <br/>
Damage per aphid, expressed as a percentage of crop yield loss per aphid during the start of flowering.
<input type="number" name="D" class="form-control" min="0" onblur="validateField(this);"/>
<label for="D" data-toggle="tooltip" data-placement="top"
title="{% trans "Damage expressed as crop yield loss per pest measuring unit" %}"
>{% trans "Damage per pest measuring unit" %} (D) [<span id="cropMassUnit3">kg</span>/<span id="pestMeasuringUnit">skadegjørermåleenhet</span>]</label> <br/>
<input type="number" name="D" class="form-control" min="0" onblur="validateField(this);" onchange="renderCharts('{{ form_id }}');"/>
<span class="help-block" id="{{ form_id }}_D_validation"></span>
</div>
<h2>{% trans "Settings" %}</h2>
<div class="form-group">
<label for="currency">{% trans "Currency" %}</label>
<input type="text" name="currency" class="form-control" onchange="renderCharts('{{ form_id }}')" value="NOK"/>
</div>
<div class="form-group">
<label for="cropMassUnit">{% trans "Crop mass unit" %}</label>
<input type="text" name="cropMassUnit" class="form-control" onchange="renderCharts('{{ form_id }}')" value="kg"/>
</div>
<div class="form-group">
<label for="cropAreaUnit">{% trans "Crop area unit" %}</label>
<input type="text" name="cropAreaUnit" class="form-control" onchange="renderCharts('{{ form_id }}')" value="daa"/>
</div>
<div class="form-group">
<label for="pestMeasuringUnit">{% trans "Pest measuring unit" %}</label>
<input type="text" name="pestMeasuringUnit" class="form-control" onchange="renderCharts('{{ form_id }}')" value="{% trans "Number of aphids per plant" %}"/>
</div>
<!--div class="form-group">
<button type="button" class="btn btn-default" onclick="if(validateForm(document.getElementById('{{ form_id }}'))){renderResult('{{ form_id }}');}">{% trans "Run model" %}</button>
</div-->
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="col-md-9">
<h1>{% trans "Results" %}</h1>
<div id="result" style="font-weight: bold;">
{% trans "Calculated EIL" %} = C / (V * Yp * D * (K/100))<span id="resultParameters"></span>: <span id="resultValue"></span>
</div>
<div id="EILvC" style="width:50%; height:300px;float: right;"></div>
<div id="EILvV" style="width:50%; height:300px; "></div>
<div id="EILvYp" style="width:50%; height:300px;float: right;"></div>
<div id="EILvK" style="width:50%; height:300px;"></div>
<div id="EILvD" style="width:100%; height:300px;"></div>
</div>
</div>
</form>
......@@ -81,10 +107,23 @@
{% block customJS %}
<script type="text/javascript" src="{% url "django.views.i18n.javascript_catalog" %}"></script>
<script type="text/javascript" src="{% static "js/validateForm.js" %}"></script>
<script type="text/javascript" src="{% static "js/util.js" %}"></script>
<script type="text/javascript" src="{% static "js/3rdparty/highcharts.js" %}"></script>
<script type="text/javascript" src="{% static "calculators/js/eil.js" %}"></script>
<script type="text/javascript">
var chartTitles = {
"EILvD" : "{% trans "EIL as a function of yield loss per pest unit" %}",
"EILvC" : "{% trans "EIL as a function of control cost" %}",
"EILvV" : "{% trans "EIL as a function of market value" %}",
"EILvYp" : "{% trans "EIL as a function of yield potential" %}",
"EILvK" : "{% trans "EIL as a function of insecticide efficacy" %}",
};
$(document).ready(function() {
$('[data-toggle="tooltip"]').tooltip();
loadFormDefinition("{{ form_id }}","/static/calculators/formdefinitions/");
renderCharts("{{ form_id }}");
});
</script>
{% endblock %}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment