diff --git a/src/main/java/no/bioforsk/vips/model/naerstadmodel/NaerstadModel.java b/src/main/java/no/bioforsk/vips/model/naerstadmodel/NaerstadModel.java index 7fbe9277891d1078e59ff1c78c3db36b22d81ac6..1066a88c1b2f5ddc6417189e3d55eaaa11f1ac60 100644 --- a/src/main/java/no/bioforsk/vips/model/naerstadmodel/NaerstadModel.java +++ b/src/main/java/no/bioforsk/vips/model/naerstadmodel/NaerstadModel.java @@ -36,6 +36,7 @@ import no.bioforsk.vips.model.ConfigValidationException; import no.bioforsk.vips.model.Model; import no.bioforsk.vips.model.ModelExcecutionException; import no.bioforsk.vips.model.ModelId; +import no.bioforsk.vips.util.CommonNamespaces; import no.bioforsk.vips.util.WeatherElements; import no.bioforsk.vips.util.WeatherUtil; import org.codehaus.jackson.map.ObjectMapper; @@ -107,23 +108,26 @@ public class NaerstadModel extends I18nImpl implements Model{ } if(this.DEBUG) System.out.println("RISK(" + thePresent + ")=" + RISK); - result.setValue("RISK", dFormat.format(RISK)); - result.setValue("TSHH", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.TSHH))); - result.setValue("SPH", dFormat.format(this.backgroundData.getParamIntValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.SPH))); - result.setValue("VAS", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.VAS))); - result.setValue("VRS", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.VRS))); - result.setValue("WHS", dFormat.format(this.backgroundData.getParamIntValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.WHS))); - result.setValue("WD", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.WD))); - result.setValue("WH", dFormat.format(this.backgroundData.getParamIntValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.WH))); - result.setValue("IR", dFormat.format(this.backgroundData.getParamIntValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.IR))); + + result.setValue(this.getModelId().toString(), "THRESHOLD_LOW", THRESHOLD_MINOR_RISK.toString()); + result.setValue(this.getModelId().toString(), "THRESHOLD_HIGH", THRESHOLD_HIGH_RISK.toString()); + result.setValue(this.getModelId().toString(), "RISK", dFormat.format(RISK)); + result.setValue(this.getModelId().toString(), "TSHH", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.TSHH))); + result.setValue(this.getModelId().toString(), "SPH", dFormat.format(this.backgroundData.getParamIntValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.SPH))); + result.setValue(this.getModelId().toString(), "VAS", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.VAS))); + result.setValue(this.getModelId().toString(), "VRS", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.VRS))); + result.setValue(this.getModelId().toString(), "WHS", dFormat.format(this.backgroundData.getParamIntValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.WHS))); + result.setValue(this.getModelId().toString(), "WD", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.WD))); + result.setValue(this.getModelId().toString(), "WH", dFormat.format(this.backgroundData.getParamIntValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.WH))); + result.setValue(this.getModelId().toString(), "IR", dFormat.format(this.backgroundData.getParamIntValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.IR))); result.setWarningStatus(this.getWarningStatus(RISK)); // Adding weather data - result.setValue("TM", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.TM))); - result.setValue("UM", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.UM))); - result.setValue("RR", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.RR))); - result.setValue("Q0", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.Q0))); - result.setValue("BT", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.BT))); + result.setValue(CommonNamespaces.NS_WEATHER, "TM", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.TM))); + result.setValue(CommonNamespaces.NS_WEATHER, "UM", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.UM))); + result.setValue(CommonNamespaces.NS_WEATHER, "RR", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.RR))); + result.setValue(CommonNamespaces.NS_WEATHER, "Q0", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.Q0))); + result.setValue(CommonNamespaces.NS_WEATHER, "BT", dFormat.format(this.backgroundData.getParamDoubleValueForDate(thePresent, NaerstadModelBackgroundDataMatrix.BT))); results.add(result); @@ -530,7 +534,7 @@ public class NaerstadModel extends I18nImpl implements Model{ } /** - * Calculating the VSR value + * Calculating the VRS value * @param VAS * @param RTA * @param IRTA diff --git a/src/test/java/no/bioforsk/vips/model/naerstadmodel/NaerstadModelTest.java b/src/test/java/no/bioforsk/vips/model/naerstadmodel/NaerstadModelTest.java index c2c976ed6f2b631254ee0461937aae9cb1baac3c..84d0438bed91fdc0f3c1e9897c9dfd160f383eb3 100644 --- a/src/test/java/no/bioforsk/vips/model/naerstadmodel/NaerstadModelTest.java +++ b/src/test/java/no/bioforsk/vips/model/naerstadmodel/NaerstadModelTest.java @@ -65,7 +65,7 @@ public class NaerstadModelTest extends TestCase { { if(res.getResultValidTime().compareTo(cal.getTime()) == 0) { - assertTrue(res.getAllValues().get("RISK").equals("5.36")); + assertTrue(res.getValue(instance.getModelId().toString(),"RISK").equals("5.36")); } System.out.println("Res[" + res.getResultValidTime() + "]:" + res.getAllValues());