IPM Decisions models in VIPS
The Horizon 2020 project IPM Decisions has produced a
[..]“one stop shop” for decisions support in integrated pest management. It is a web-based framework providing farmers, advisors and researchers access to a wide range of Decision Support Systems and weather data from across Europe through a set of four dashboards[...]
A curated set of European DSSs and weather data sources have been made available in the platform through APIs developed by NIBIO, Met Norway and LUKE.
The DSSs have been made available through the IPM Decisions platform (see screenshot below) where farmers, advisors and researchers can log in and configure their farm and fields and choose between the available DSSs. Weather data can either be provided by the user's private weather station or by the open weather data sources available in the platform.

Screenshot of the IPM Decisions platform
The APIs are designed as web services that are open for use by other clients than the IPM Decisions platform. This means that a DSS provider can use the APIs to discover and make other DSSs available directly from their DSS platform/web page, without having to implement the algorithms for that DSS. In the platform, metadata are available for all DSSs and weather data sources. These metadata are structured in a way that as soon as client code has been implemented for one DSS (from IPM Decisions), only minimal adaptations are needed to add new DSSs (from IPM Decisions).
Saddle gall midge model from ADAS made available in VIPS
In VIPS, we have created a web page to test/run the Saddle Gall Midge model developed and hosted by the UK advisory organization ADAS. The code for this is found in these files:
static/ipmdlib.js
This file contains JavaScript functions for retrieving metadata, showing data in maps and displaying results. They are intended to be usable for all potential uses of the IPM Decisions API.
templates/ipmd/saddlegallmidgeform.html
This file is specific for the Saddle Gall Midge model, but contains a lot of JavaScript code, some of which probably could be refactored and moved into ipmdlib.js
Workflow/data flow of the application
After the browser has rendered the page and the document is ready, this is what happens
1. Retrieve and display metadata for the Saddle Gall Midge model
The application sends a request to the IPM Decisions DSS API for metadata about the model.

It pulls the description
out of the returned data and displays it in a box on the page (see screenshot below)

Screenshot of the upper part of the model web page
The metadata also accurately and machine readably describes the input data that it needs, using Json schema. Here's the input data definition for the Saddle Gall Midge model (which is part of the metadata returned from IPM Decisions):
{
"type":"object",
"properties": {
"modelId": {"type": "string", "pattern":"^HAPDMA$", "title": "Model Id", "default":"HAPDMA", "description":"Must be HAPDMA"},
"weatherData": {
"$ref": "https://platform.ipmdecisions.net/api/wx/rest/schema/weatherdata"
},
"optionalData" :{
"title":"Optional parameters for the DSS",
"type": "object",
"properties": {
"rain_threshold": {"type": "number", "default":"1","title": "Rainfall Threshold" },
"dry_day": {"type": "number", "default":"3", "title": "Dry Day Threshold"},
"temp_threshold": {"type": "number", "default":"0", "title": "Temperature Threshold"},
"degree_day": {"type": "number", "default":"512", "title": "Degree Days"},
"startDate": {"type":"string","format": "date", "title": "Model Start Date/Biofix (YYYY-MM-DD)", "default": "{CURRENT_YEAR}-03-01"},
"endDate": {"type":"string","format": "date", "title": "Model End Date (YYYY-MM-DD)", "default": "{CURRENT_YEAR}-07-31"}
}
}
},
"required": ["modelId"]
}
We are using the JSON Editor JavaScript library to automatically render this schema into an HTML Form (see the screenshot above). The JSON Editor also validates the input data and upon submission formats the entered data into Json.
2. Retrieve and display metadata for all available weatherdatasources
The application sends a request to the IPM Decisions platform for a list of all the available weatherdatasources.

It filters out the ones that require login, as we don't support login yet, and then the sources are listed in two different lists: One for sources that provide measured/seasonal weatherdata and one for weather forecast services. Some of the data sources provide data for both past, present and future, and they are listed in both categories.

Weatherdata sources list
When the user selects the historic weatherdata source, they are requested to either select a weather station or a location - depending on whether the data source contains a set of weather stations or if it provides data for all lat/lon combinations within a certain area. See examples of both types below

Location based weatherdata source (Denmark)

Station based weatherdata source (Norway)
3. Collate input data
3.1. Weatherdata
When the user clicks the Run
button, the application first sends requests for weatherdata to the historic and forecast weatherdata services. The retrieved data are then merged into one data set.

3.2 Model form data
The application uses the JSON Editor to convert the values of the form (assuming that the form data has been found to be valid) into Json.
4. Request running of the model from ADAS
When the input data has been collated, it is sent as part of a request to the ADAS DSS web service.

5. Retrieve and display results
If the input data are correct and the model runs, the web service returns result data in the IPM Decisions standard format, see an example below (contains only two days of results for clarity)
{
"timeStart": "2024-02-27T23:00:00+00:00",
"timeEnd": "2024-02-29T22:00:00+00:00",
"interval": 86400,
"resultParameters": [
"Cumulative_DayDegrees",
"StartOfEmergenceThreshold",
"FirstThreshold",
"SecondThreshold",
"ThirdThreshold"
],
"locationResult": [
{
"longitude": 10.75427,
"latitude": 59.39805,
"altitude": 35,
"data": [
[
3.4077916666666668,
500,
750.47,
1023.93,
1500
],
[
7.378176282051282,
500,
750.47,
1023.93,
1500
]
],
"warningStatus": [
2,
2
],
"width": 5,
"length": 2
}
],
"message": "Start of cumulative emergence hasn't been reached.",
"messageType": 0
}
These results are then rendered into a chart (see example below), only using the metadata provided. The weatherdata passed on to the ADAS web service are displayed in a table at the bottom of the page (see example below).

DSS results and weathedata displayed after the model has been run