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

Merge branch 'main' into 'release'

Main

See merge request !2
parents cd7e52ea e31bc170
Branches
Tags
1 merge request!2Main
Pipeline #2313 passed
# Grovfôrmodellen
## Bruksområde
Modellen skal underveis i vekstsesongen gi støtte for valg av høstetid i to- og
treslåttsystem i eng som brukes til fôrproduksjon. Den er utvikla på grunnlag av
data fra timoteidominert eng, men kan også brukes på bestand dominert av fleirårig raigras.
......
......@@ -10,7 +10,7 @@
<groupId>no.nibio.vips.model</groupId>
<artifactId>RoughageNutritionModel</artifactId>
<version>1.1.2</version>
<version>1.1.3-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
......
......@@ -36,6 +36,7 @@ import java.util.logging.Logger;
import java.util.stream.Collectors;
import no.nibio.vips.entity.WeatherObservation;
import no.nibio.vips.model.ModelExcecutionException;
import no.nibio.vips.util.WeatherUtil;
// Using Commons math and Nelder-Mead for parameter optimization
import org.apache.commons.math.ConvergenceException;
......@@ -736,6 +737,24 @@ public class RoughageNutritionModelImpl implements CostFunction {
//System.out.println("m=" + m);
return m;
}
/**
* @return
* @throws ModelExcecutionException
*/
private Date getForsteApril() throws ModelExcecutionException
{
// Calculating start and end date of weather data retrieval
// Start is April 1st
Calendar cal = Calendar.getInstance(timeZone);
cal.setTime(this.getVekstStart());
cal.set(Calendar.MONTH, Calendar.APRIL);
cal.set(Calendar.DATE, 1);
WeatherUtil wUtil = new WeatherUtil();
return wUtil.normalizeToExactDate(cal.getTime(), timeZone);
}
/**
* Løper gjennom eksisterende klimadatasett og beregner utvikling
......@@ -751,6 +770,7 @@ public class RoughageNutritionModelImpl implements CostFunction {
}
boolean first = true;
boolean firstTemperaturSum = true;
Date forrigeDato = null;
List<WeatherObservation> tempCopy = new ArrayList<>(this.luftTemperaturVerdier);
for (Iterator<WeatherObservation> tempI = tempCopy.iterator(); tempI.hasNext();) {
......@@ -758,10 +778,15 @@ public class RoughageNutritionModelImpl implements CostFunction {
temperatur = tempI.next();
//Setter Ts1
if (first) {
this.AIBakgrunnsdataMatrise.setParamDoubleValueForDate(temperatur.getTimeMeasured(), AIDataMatrix.TS1, temperatur.getValue());
} else {
this.AIBakgrunnsdataMatrise.setParamDoubleValueForDate(temperatur.getTimeMeasured(), AIDataMatrix.TS1, temperatur.getValue() + this.AIBakgrunnsdataMatrise.getParamDoubleValueForDate(forrigeDato, AIDataMatrix.TS1));
// At første april (og ikke f.eks. vekststart) er grense her, er pr. 2023-09 til vurdering av Anne Kjersti Bakken
if (temperatur.getTimeMeasured().compareTo(this.getForsteApril()) >= 0)
{
if (firstTemperaturSum) {
this.AIBakgrunnsdataMatrise.setParamDoubleValueForDate(temperatur.getTimeMeasured(), AIDataMatrix.TS1, temperatur.getValue());
firstTemperaturSum = false;
} else {
this.AIBakgrunnsdataMatrise.setParamDoubleValueForDate(temperatur.getTimeMeasured(), AIDataMatrix.TS1, temperatur.getValue() + this.AIBakgrunnsdataMatrise.getParamDoubleValueForDate(forrigeDato, AIDataMatrix.TS1));
}
}
// Beregner DVR
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment