Skip to content
Snippets Groups Projects
Commit 80e477bc authored by Brita Linnestad's avatar Brita Linnestad
Browse files

Differentiate MSC-calculation for VekstStart before or after April 7th

parent 23c90d9f
No related branches found
No related tags found
2 merge requests!8Main,!7Differentiate MSC-calculation for VekstStart before or after April 7th
Pipeline #3693 passed
......@@ -10,7 +10,7 @@
<groupId>no.nibio.vips.model</groupId>
<artifactId>RoughageNutritionModel</artifactId>
<version>1.1.10-SNAPSHOT</version>
<version>1.1.11-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
......
......@@ -755,7 +755,25 @@ public class RoughageNutritionModelImpl implements CostFunction {
return wUtil.normalizeToExactDate(cal.getTime(), timeZone);
}
/**
* @return
* @throws ModelExcecutionException
*/
private Date getSyvendeApril() 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, 7);
WeatherUtil wUtil = new WeatherUtil();
return wUtil.normalizeToExactDate(cal.getTime(), timeZone);
}
/**
* Løper gjennom eksisterende klimadatasett og beregner utvikling
* (MSC_BEREGNET) Dette trenger man bare å gjøre en gang pr. modellberegning
......@@ -779,16 +797,46 @@ public class RoughageNutritionModelImpl implements CostFunction {
//Setter 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)
// Endret fra mars 2024 etter innspill fra Anne Kjersti Bakken:
// Dersom vekststart er før 7 april akkumuleres temperatursum fra vekststart
// Dersom vekstart er 7 april eller senere, akkumuleres temperatursum fra 1 april
// Dvs at
// 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));
// }
// }
// fra mars 2024 er byttet ut med
if (this.getVekstStart().compareTo(this.getSyvendeApril()) >= 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));
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));
}
}
}
else
{
if (temperatur.getTimeMeasured().compareTo(this.getVekstStart()) >= 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
double DVR;
if (temperatur.getTimeMeasured().compareTo(this.getVekstStart()) >= 0 && this.AIBakgrunnsdataMatrise.getParamDoubleValueForDate(temperatur.getTimeMeasured(), AIDataMatrix.TS1) > 150) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment