Skip to content
Snippets Groups Projects

Main

Merged Tor-Einar Skog requested to merge main into release
3 files
+ 31
5
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -36,6 +36,7 @@ import java.util.logging.Logger;
@@ -36,6 +36,7 @@ import java.util.logging.Logger;
import java.util.stream.Collectors;
import java.util.stream.Collectors;
import no.nibio.vips.entity.WeatherObservation;
import no.nibio.vips.entity.WeatherObservation;
import no.nibio.vips.model.ModelExcecutionException;
import no.nibio.vips.model.ModelExcecutionException;
 
import no.nibio.vips.util.WeatherUtil;
// Using Commons math and Nelder-Mead for parameter optimization
// Using Commons math and Nelder-Mead for parameter optimization
import org.apache.commons.math.ConvergenceException;
import org.apache.commons.math.ConvergenceException;
@@ -736,6 +737,24 @@ public class RoughageNutritionModelImpl implements CostFunction {
@@ -736,6 +737,24 @@ public class RoughageNutritionModelImpl implements CostFunction {
//System.out.println("m=" + m);
//System.out.println("m=" + m);
return 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
* Løper gjennom eksisterende klimadatasett og beregner utvikling
@@ -751,6 +770,7 @@ public class RoughageNutritionModelImpl implements CostFunction {
@@ -751,6 +770,7 @@ public class RoughageNutritionModelImpl implements CostFunction {
}
}
boolean first = true;
boolean first = true;
 
boolean firstTemperaturSum = true;
Date forrigeDato = null;
Date forrigeDato = null;
List<WeatherObservation> tempCopy = new ArrayList<>(this.luftTemperaturVerdier);
List<WeatherObservation> tempCopy = new ArrayList<>(this.luftTemperaturVerdier);
for (Iterator<WeatherObservation> tempI = tempCopy.iterator(); tempI.hasNext();) {
for (Iterator<WeatherObservation> tempI = tempCopy.iterator(); tempI.hasNext();) {
@@ -758,10 +778,15 @@ public class RoughageNutritionModelImpl implements CostFunction {
@@ -758,10 +778,15 @@ public class RoughageNutritionModelImpl implements CostFunction {
temperatur = tempI.next();
temperatur = tempI.next();
//Setter Ts1
//Setter Ts1
if (first) {
// At første april (og ikke f.eks. vekststart) er grense her, er pr. 2023-09 til vurdering av Anne Kjersti Bakken
this.AIBakgrunnsdataMatrise.setParamDoubleValueForDate(temperatur.getTimeMeasured(), AIDataMatrix.TS1, temperatur.getValue());
if (temperatur.getTimeMeasured().compareTo(this.getForsteApril()) >= 0)
} else {
{
this.AIBakgrunnsdataMatrise.setParamDoubleValueForDate(temperatur.getTimeMeasured(), AIDataMatrix.TS1, temperatur.getValue() + this.AIBakgrunnsdataMatrise.getParamDoubleValueForDate(forrigeDato, AIDataMatrix.TS1));
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
// Beregner DVR
Loading