Skip to content
Snippets Groups Projects
Commit f776b48b authored by Bhabesh Bhabani Mukhopadhyay's avatar Bhabesh Bhabani Mukhopadhyay
Browse files

Initial commit with set configuration

Initial commit with set configuration for Altanaria model. This will  calculate the daily mean temperature from hourly temperature and calculate leaf wetness hour using given threshhold value 30. Using leaf wetness hour it will calculate daily leaf wetness hour. Using daily leaf wetness hour and daily mean temperature it will calculate daily disease severity value 
parent 15934105
Branches
Tags
No related merge requests found
Showing
with 1150 additions and 0 deletions
Copyright (c) 2016 NIBIO <http://www.nibio.no/>.
This file is part of AlternariaModel.
AlternariaModel is free software: you can redistribute it and/or modify
it under the terms of the NIBIO Open Source License as published by
NIBIO, either version 1 of the License, or (at your option) any
later version.
AlternariaModel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
NIBIO Open Source License for more details.
You should have received a copy of the NIBIO Open Source License
along with AlternariaModel. If not, see <http://www.nibio.no/licenses/>.
<?xml version="1.0" encoding="UTF-8"?>
<project-shared-configuration>
<!--
This file contains additional configuration written by modules in the NetBeans IDE.
The configuration is intended to be shared among all the users of project and
therefore it is assumed to be part of version control checkout.
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
-->
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
<!--
Properties that influence various parts of the IDE, especially code formatting and the like.
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
That way multiple projects can share the same settings (useful for formatting rules for example).
Any value defined here will override the pom.xml file value but is only applicable to the current project.
-->
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.otherBracePlacement>NEW_LINE</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.otherBracePlacement>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.enable-indent>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.enable-indent>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.moduleDeclBracePlacement>NEW_LINE</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.moduleDeclBracePlacement>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement>NEW_LINE</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement>NEW_LINE</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement>
<org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap>none</org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap>
<org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width>4</org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width>
<org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab>4</org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab>
<org-netbeans-modules-editor-indent.CodeStyle.project.tab-size>8</org-netbeans-modules-editor-indent.CodeStyle.project.tab-size>
<org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width>80</org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width>
<org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs>true</org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs>
<org-netbeans-modules-editor-indent.CodeStyle.usedProfile>project</org-netbeans-modules-editor-indent.CodeStyle.usedProfile>
<org-netbeans-modules-javascript2-requirejs.enabled>true</org-netbeans-modules-javascript2-requirejs.enabled>
<netbeans.hint.licensePath>${project.basedir}/headerFileAltanaria.txt</netbeans.hint.licensePath>
</properties>
</project-shared-configuration>
pom.xml 0 → 100644
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>no.nibio.vips.model</groupId>
<artifactId>AlternariaModel</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>no.nibio.vips.common</groupId>
<artifactId>VIPSCommon</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.3.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
</project>
\ No newline at end of file
This diff is collapsed.
/**
* Project : AlternariaModel
* Organization : NIBIO, Ås
* Department : VIPS
*
* Author : bhabesh
*
*
* File Name : DataMatrix.java
* Package Name : no.nibio.vips.model.alternariamodel
* Date of creation : 3 Mar. 2020 8:24:53 am
* Date of modification :
*
* Summary :
*
*/
/*
*
Copyright (c) 2016 NIBIO <http://www.nibio.no/>.
This file is part of AlternariaModel.
AlternariaModel is free software: you can redistribute it and/or modify
it under the terms of the NIBIO Open Source License as published by
NIBIO, either version 1 of the License, or (at your option) any
later version.
AlternariaModel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
NIBIO Open Source License for more details.
You should have received a copy of the NIBIO Open Source License
along with AlternariaModel. If not, see <http://www.nibio.no/licenses/>.
*/
package no.nibio.vips.model.alternariamodel;
import no.nibio.vips.util.DateMap;
/**
*
* @author bhabesh
*/
public class DataMatrix extends DateMap{
public final static String LEAF_WETNESS_DURATION = "BT"; // Leaf wetness 2 m, minutes per hour
public final static String TEMPERATURE_MEAN = "TM"; // Mean Temperature
public final static String DAILY_DISEASE_SEVERITY_VALUE = "DSV"; // Daily Disease Severity Value
}
/**
* Project : AlternariaModel
* Organization : NIBIO, Ås
* Department : VIPS
*
* Author : bhabesh
*
*
* File Name : AltanariaWeather.java
* Package Name : no.nibio.vips.model.alternariamodel
* Date of creation : 4 Mar. 2020 1:28:14 pm
* Date of modification :
*
* Summary :
*
*/
/*
*
Copyright (c) 2016 NIBIO <http://www.nibio.no/>.
This file is part of AlternariaModel.
AlternariaModel is free software: you can redistribute it and/or modify
it under the terms of the NIBIO Open Source License as published by
NIBIO, either version 1 of the License, or (at your option) any
later version.
AlternariaModel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
NIBIO Open Source License for more details.
You should have received a copy of the NIBIO Open Source License
along with AlternariaModel. If not, see <http://www.nibio.no/licenses/>.
*/
package no.nibio.vips.model.alternariamodel.bo;
import no.nibio.vips.entity.WeatherObservation;
/**
*
* @author bhabesh
*/
public class AltanariaWeatherBO
{
/**
* BT : Leaf wetness TM : Temperature mean
*/
private WeatherObservation weatherObservation;
private String observationType;
public AltanariaWeatherBO() {}
public AltanariaWeatherBO(WeatherObservation weatherObservation, String observationType)
{
this.weatherObservation = weatherObservation;
this.observationType = observationType;
}
/**
* @return the weatherObservation
*/
public WeatherObservation getWeatherObservation()
{
return weatherObservation;
}
/**
* @param weatherObservation the weatherObservation to set
*/
public void setWeatherObservation(WeatherObservation weatherObservation)
{
this.weatherObservation = weatherObservation;
}
/**
* @return the observationType
*/
public String getObservationType()
{
return observationType;
}
/**
* @param observationType the observationType to set
*/
public void setObservationType(String observationType)
{
this.observationType = observationType;
}
@Override
public String toString()
{
return "AltanariaWeatherBO{" + "weatherObservation=" + weatherObservation + ", observationType=" + observationType + '}';
}
}
src/main/resources/images/early_blight.png

133 KiB

# Copyright (c) 2016 NIBIO <http://www.nibio.no/>.
#
# This file is part of MamestraBrassicaeModel.
# MamestraBrassicaeModel is free software: you can redistribute it and/or modify
# it under the terms of the NIBIO Open Source License as published by
# NIBIO, either version 1 of the License, or (at your option) any
# later version.
#
# MamestraBrassicaeModel is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# NIBIO Open Source License for more details.
#
# You should have received a copy of the NIBIO Open Source License
# along with MamestraBrassicaeModel. If not, see <http://www.nibio.no/licenses/>.
#
name=TOMCAST (FAST - Dew) model
description={{filename="/images/early_blight.jpg" description="Photo: -"}}\n<h3>Description of model</h3>\n<p>TODO</p>
statusInterpretation=Early blight are primarily foliar pathogens. It typically appear first on older leaves after fruit set begins. Early bilght causes dark brown leaf spots with concentric rings. \t
usage=TODO
# Copyright (c) 2016 NIBIO <http://www.nibio.no/>.
#
# This file is part of MamestraBrassicaeModel.
# MamestraBrassicaeModel is free software: you can redistribute it and/or modify
# it under the terms of the NIBIO Open Source License as published by
# NIBIO, either version 1 of the License, or (at your option) any
# later version.
#
# MamestraBrassicaeModel is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# NIBIO Open Source License for more details.
#
# You should have received a copy of the NIBIO Open Source License
# along with MamestraBrassicaeModel. If not, see <http://www.nibio.no/licenses/>.
#
name=TOMCAST (FAST - Dew) model
description={{filename="/images/early_blight.jpg" description="Photo: -"}}\n<h3>Description of model</h3>\n<p>TODO</p>
statusInterpretation=Early blight are primarily foliar pathogens. It typically appear first on older leaves after fruit set begins. Early bilght causes dark brown leaf spots with concentric rings.
usage=TODO
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package no.nibio.vips.model.alternariamodel;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.MappingJsonFactory;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import no.nibio.vips.entity.ModelConfiguration;
import no.nibio.vips.entity.Result;
import no.nibio.vips.entity.WeatherObservation;
import no.nibio.vips.model.ModelId;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
/**
*
* @author bhabesh
*/
public class AlternariaModelTest {
private DataMatrix dataMatrix;
public AlternariaModelTest() {
}
@BeforeAll
public static void setUpClass() {
}
@AfterAll
public static void tearDownClass() {
}
@BeforeEach
public void setUp() {
}
@AfterEach
public void tearDown() {
}
/**
* Test of getResult method, of class AlternariaModel.
*/
@org.junit.jupiter.api.Test
public void testGetResult() throws Exception {
System.out.println("getResult");
ModelConfiguration config = this.getConfiguration("/weatherdata_leaf_wetness_temperature.json");
// dataMatrix = new DataMatrix();
//Date currentDate = this.dataMatrix.getFirstDateWithParameterValue(DataMatrix.BT);
//System.out.println("Current Date : "+currentDate.toString());
AlternariaModel instance = new AlternariaModel();
instance.setConfiguration(config);
//TODO temporary commented out
// List<Result> expResult = null;
List<Result> result = instance.getResult();
// assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
assertNotSame(0, result.size());
//fail("The test case is a prototype.");
}
/**
* Test of getModelId method, of class AlternariaModel.
*/
@org.junit.jupiter.api.Test
public void testGetModelId() {
System.out.println("getModelId");
AlternariaModel instance = new AlternariaModel();
ModelId expResult = null;
ModelId result = instance.getModelId();
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getModelName method, of class AlternariaModel.
*/
@org.junit.jupiter.api.Test
public void testGetModelName_0args() {
System.out.println("getModelName");
AlternariaModel instance = new AlternariaModel();
String expResult = "";
String result = instance.getModelName();
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getModelName method, of class AlternariaModel.
*/
@org.junit.jupiter.api.Test
public void testGetModelName_String() {
System.out.println("getModelName");
String language = "";
AlternariaModel instance = new AlternariaModel();
String expResult = "";
String result = instance.getModelName(language);
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getLicense method, of class AlternariaModel.
*/
@org.junit.jupiter.api.Test
public void testGetLicense() {
System.out.println("getLicense");
AlternariaModel instance = new AlternariaModel();
String expResult = "";
String result = instance.getLicense();
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getCopyright method, of class AlternariaModel.
*/
@org.junit.jupiter.api.Test
public void testGetCopyright() {
System.out.println("getCopyright");
AlternariaModel instance = new AlternariaModel();
String expResult = "";
String result = instance.getCopyright();
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getModelDescription method, of class AlternariaModel.
*/
@org.junit.jupiter.api.Test
public void testGetModelDescription_0args() {
System.out.println("getModelDescription");
AlternariaModel instance = new AlternariaModel();
String expResult = "";
String result = instance.getModelDescription();
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getModelDescription method, of class AlternariaModel.
*/
@org.junit.jupiter.api.Test
public void testGetModelDescription_String() {
System.out.println("getModelDescription");
String language = "";
AlternariaModel instance = new AlternariaModel();
String expResult = "";
String result = instance.getModelDescription(language);
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getWarningStatusInterpretation method, of class AlternariaModel.
*/
@org.junit.jupiter.api.Test
public void testGetWarningStatusInterpretation_0args() {
System.out.println("getWarningStatusInterpretation");
AlternariaModel instance = new AlternariaModel();
String expResult = "";
String result = instance.getWarningStatusInterpretation();
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getWarningStatusInterpretation method, of class AlternariaModel.
*/
@org.junit.jupiter.api.Test
public void testGetWarningStatusInterpretation_String() {
System.out.println("getWarningStatusInterpretation");
String language = "";
AlternariaModel instance = new AlternariaModel();
String expResult = "";
String result = instance.getWarningStatusInterpretation(language);
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getModelUsage method, of class AlternariaModel.
*/
@org.junit.jupiter.api.Test
public void testGetModelUsage_0args() {
System.out.println("getModelUsage");
AlternariaModel instance = new AlternariaModel();
String expResult = "";
String result = instance.getModelUsage();
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getModelUsage method, of class AlternariaModel.
*/
@org.junit.jupiter.api.Test
public void testGetModelUsage_String() {
System.out.println("getModelUsage");
String language = "";
AlternariaModel instance = new AlternariaModel();
String expResult = "";
String result = instance.getModelUsage(language);
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getSampleConfig method, of class AlternariaModel.
*/
@org.junit.jupiter.api.Test
public void testGetSampleConfig() {
System.out.println("getSampleConfig");
AlternariaModel instance = new AlternariaModel();
String expResult = "";
String result = instance.getSampleConfig();
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of setConfiguration method, of class AlternariaModel.
*/
@org.junit.jupiter.api.Test
public void testSetConfiguration() throws Exception {
System.out.println("setConfiguration");
ModelConfiguration config = null;
AlternariaModel instance = new AlternariaModel();
instance.setConfiguration(config);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
private ModelConfiguration getConfiguration(String fileName)
{
try {
ModelConfiguration config = new ModelConfiguration();
config.setModelId(AlternariaModel.MODEL_ID.toString());
config.setConfigParameter("timeZone", "Europe/Oslo");
BufferedInputStream inputStream = new BufferedInputStream(this.getClass().getResourceAsStream(fileName));
JsonFactory f = new MappingJsonFactory();
JsonParser jp = f.createParser(inputStream);
JsonNode all = jp.readValueAsTree();
List<WeatherObservation> observations = new ArrayList<>();
ObjectMapper mapper = new ObjectMapper();
Date firstDate = null;
Date lastDate = null;
if(all.isArray())
{
for(JsonNode node : all){
Date timeMeasured = (Date)mapper.convertValue(node.get("timeMeasured").asText(), new TypeReference<Date>(){});
if(firstDate == null || firstDate.compareTo(timeMeasured) > 0)
{
firstDate = timeMeasured;
}
if(lastDate == null || lastDate.compareTo(timeMeasured) < 0)
{
lastDate = timeMeasured;
}
//System.out.println(node.toString());
WeatherObservation observation = new WeatherObservation();
observation.setTimeMeasured(timeMeasured);
observation.setLogIntervalId(node.get("logIntervalId").asInt());
observation.setElementMeasurementTypeId(node.get("elementMeasurementTypeId").asText());
observation.setValue(node.get("value").asDouble());
observations.add(observation);
}
}
else
{
fail("Data input from file is not a JSON array");
}
config.setConfigParameter("observations", observations);
return config;
} catch (IOException ex) {
ex.printStackTrace();
return null;
}
}
}
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment