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

Add BasisTemp to config file

parent 735cef0f
No related branches found
No related tags found
1 merge request!2Main
Pipeline #3721 passed
...@@ -52,18 +52,15 @@ import no.nibio.vips.util.WeatherUtil; ...@@ -52,18 +52,15 @@ import no.nibio.vips.util.WeatherUtil;
public class DayDegreeModel implements Model { public class DayDegreeModel implements Model {
private ModelUtil modelUtil; private ModelUtil modelUtil;
//private Double dayDegreeBaseTemp; private Float dayDegreeBaseTemp;
private List<WeatherObservation> TM; private List<WeatherObservation> TM;
private final Double dayDegreeBaseTemp = 0.0;
private final static TimeZone DEFAULT_TIME_ZONE = TimeZone.getTimeZone("Europe/Oslo"); private final static TimeZone DEFAULT_TIME_ZONE = TimeZone.getTimeZone("Europe/Oslo");
private DataMatrix dataMatrix;
public final static ModelId MODEL_ID = new ModelId("DAYDEGREES"); public final static ModelId MODEL_ID = new ModelId("DAYDEGREES");
public DayDegreeModel() public DayDegreeModel()
{ {
//super("");
this.modelUtil = new ModelUtil(); this.modelUtil = new ModelUtil();
} }
...@@ -71,14 +68,14 @@ public class DayDegreeModel implements Model { ...@@ -71,14 +68,14 @@ public class DayDegreeModel implements Model {
public List<Result> getResult() throws ModelExcecutionException { public List<Result> getResult() throws ModelExcecutionException {
Collections.sort(this.TM); Collections.sort(this.TM);
Double dayDegreeSum = 0.0; Double dayDegreeSum = 0.0;
List<Result> results = new ArrayList<>(); List<Result> results = new ArrayList<>();
Calendar cal = Calendar.getInstance(this.DEFAULT_TIME_ZONE); Calendar cal = Calendar.getInstance(this.DEFAULT_TIME_ZONE);
DecimalFormat dFormat = new DecimalFormat("###.##"); DecimalFormat dFormat = new DecimalFormat("###.##");
for(WeatherObservation obs:this.TM) for(WeatherObservation obs:this.TM)
{ {
...@@ -86,7 +83,7 @@ public class DayDegreeModel implements Model { ...@@ -86,7 +83,7 @@ public class DayDegreeModel implements Model {
{ {
dayDegreeSum += obs.getValue(); dayDegreeSum += obs.getValue();
} }
Result result = new ResultImpl(); Result result = new ResultImpl();
result.setValidTimeStart(obs.getTimeMeasured()); result.setValidTimeStart(obs.getTimeMeasured());
result.setValue(this.getModelId().toString(), "DayDegreeSum", dayDegreeSum.toString()); result.setValue(this.getModelId().toString(), "DayDegreeSum", dayDegreeSum.toString());
...@@ -105,12 +102,11 @@ public class DayDegreeModel implements Model { ...@@ -105,12 +102,11 @@ public class DayDegreeModel implements Model {
@Override @Override
public String getModelName() { public String getModelName() {
return null;//this.getModelName(Model.DEFAULT_LANGUAGE); return null;
} }
@Override @Override
public String getModelName(String language) { public String getModelName(String language) {
//return this.getText("name", language);
return "Day Degree model"; return "Day Degree model";
} }
...@@ -148,27 +144,27 @@ public class DayDegreeModel implements Model { ...@@ -148,27 +144,27 @@ public class DayDegreeModel implements Model {
@Override @Override
public String getModelDescription(String language) { public String getModelDescription(String language) {
return null; //this.modelUtil.getTextWithBase64EncodedImages(this.getText("description", language), this.getClass()); return null;
} }
@Override @Override
public String getWarningStatusInterpretation() { public String getWarningStatusInterpretation() {
return null;//this.getWarningStatusInterpretation(Model.DEFAULT_LANGUAGE); return null;
} }
@Override @Override
public String getWarningStatusInterpretation(String language) { public String getWarningStatusInterpretation(String language) {
return null;//this.getText("statusInterpretation", language); return null;
} }
@Override @Override
public String getModelUsage() { public String getModelUsage() {
return null; //this.getModelUsage(Model.DEFAULT_LANGUAGE); return null;
} }
@Override @Override
public String getModelUsage(String language) { public String getModelUsage(String language) {
return null;//this.getText("usage", language); return null;
} }
@Override @Override
...@@ -181,6 +177,7 @@ public class DayDegreeModel implements Model { ...@@ -181,6 +177,7 @@ public class DayDegreeModel implements Model {
"\t},\n" + "\t},\n" +
"\t\"modelId\":\"" + MODEL_ID.toString() + "\",\n" + "\t\"modelId\":\"" + MODEL_ID.toString() + "\",\n" +
"\t\"configParameters\":{\n" + "\t\"configParameters\":{\n" +
"\t\t\"basisTemp\":0,\n" +
"\t\t\"observations\":[\n" + "\t\t\"observations\":[\n" +
"\t\t{\n" + "\t\t{\n" +
"\t\t\t\t\"timeMeasured\": \"2015-01-01T00:00:00+02:00\",\n" + "\t\t\t\t\"timeMeasured\": \"2015-01-01T00:00:00+02:00\",\n" +
...@@ -193,8 +190,11 @@ public class DayDegreeModel implements Model { ...@@ -193,8 +190,11 @@ public class DayDegreeModel implements Model {
@Override @Override
public void setConfiguration(ModelConfiguration config) throws ConfigValidationException { public void setConfiguration(ModelConfiguration config) throws ConfigValidationException {
// Initialize the weather data collections // Initialize the weather data collections
this.TM = new ArrayList<>(); this.TM = new ArrayList<>();
this.dayDegreeBaseTemp = Float.parseFloat((String) config.getConfigParameter("basisTemp"));
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
List<WeatherObservation> observations = this.modelUtil.extractWeatherObservationList(config.getConfigParameter("observations")); List<WeatherObservation> observations = this.modelUtil.extractWeatherObservationList(config.getConfigParameter("observations"));
...@@ -216,7 +216,7 @@ public class DayDegreeModel implements Model { ...@@ -216,7 +216,7 @@ public class DayDegreeModel implements Model {
{ {
this.TM.add(o); this.TM.add(o);
} }
break; break;
default: default:
// TODO: Throw validation error? // TODO: Throw validation error?
break; break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment