diff --git a/README.md b/README.md index e58728d69f0483eb223fa1eabee2be48cf28da29..62f8412a9de6b1bc4a87053b6f66481044557609 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Tor-Einar Skog, NIBIO -Last edit: 2023-02-23 +Last edit: 2023-11-15 ## About this project Since VIPS consists of multiple subsystems, this project is a starting point for VIPS documentation, describing the system as a whole. Documentation to each subsystem is linked from here. diff --git a/examples/PSILARTEMP.map b/examples/PSILARTEMP.map new file mode 100644 index 0000000000000000000000000000000000000000..732cd607f0840668f25536729d079bce8e33de0f --- /dev/null +++ b/examples/PSILARTEMP.map @@ -0,0 +1,319 @@ +MAP + + # This mapfile is generated using Jinja2 templates + # + # Copyright (C) 2023 NIBIO <https://www.nibio.no/> + # This program is free software: you can redistribute it and/or modify + # it under the terms of the GNU Affero General Public License as published by + # the Free Software Foundation, either version 3 of the License, or + # (at your option) any later version. + # + # This program 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 + # GNU Affero General Public License for more details. + # + # You should have received a copy of the GNU Affero General Public License + # along with this program. If not, see <https://www.gnu.org/licenses/>. + + NAME "VIPS.PSILARTEMP" + + # WGS84 + EXTENT -1.5831861262936526 52.4465003983706595 39.2608060398730458 71.7683216082912736 + UNITS DD + + CONFIG "MS_ERRORFILE" "/disks/data01/mapserver/log/PSILARTEMP.log" + + PROJECTION + "init=epsg:4326" + END + + + WEB + IMAGEPATH "/disks/data01/mapserver/tmp/" + IMAGEURL "/tmp/" + # List of standard metadata: https://mapserver.org/ogc/wms_server.html#web-object-metadata + # i18n support: https://mapserver.org/ogc/inspire.html#inspire-multi-language-support + METADATA + "wms_keywordlist" "VIPS model Carrot Rust Fly (PSILARTEMP)" + "wms_abstract" " + <p>The warning system model «Carrot rust fly temperature» is based on a Finnish temperature-based model (Markkula <em>et al</em>, 1998; Tiilikkala & Ojanen, 1999; Markkula <em>et al</em>, 2000). The model determines the start of the flight period for the 1st and 2nd generation of carrot rust fly based on accumuleted degree-days (day-degrees) over a base temperature of 5,0 °C. VIPS uses the model for the 1st generation only.</p> + <p>Standard air temperature (temperature measured 2 m above ground) is used in the model. Degree-days are defined for this model as the sum of the difference between a base temperature of 5,0 °C and the mean temperature for all days with a temperature >5,0 °C, in other words (daily mean temperature – 5,0 °C) from 1 March (beginning when the ground has thawed).</p> + <h3>Interpretation of the warning</h3> + <p>Green rectangles indicate that the flight period has not yet begun. The accumulated day-degrees are < 260 degree-days (day-degrees).</p> + <p>Yellow rectangles indicate that the flight period is beginning and that flies can be coming into the field. The accumulated day-degrees are ≥ 260 degree-days (day-degrees).</p> + <p>Red rectangles indicate peak flight period. The accumulated day-degrees are ≥ 360 degree-days (day-degrees).</p> + <p>Grey rectangles indicate that the flight period of the 1st generation is over. The accumulated day-degrees are ≥ 560 degree-days (day-degrees).</p> + <p>Be aware that in areas with field covers (plastic, single or double non-woven covers, etc.) with early crops the preceding season (either on the current field or neighboring fields), the flight period can start earlier due to higher soil temperature under the covers.</p> + <p>The graphic presentation shows the progress of the day-degree calculation that is the basis for the green, yellow and red warnings (the line: «Accumulated day-degrees with the base temperature of 5 degrees C»). The graph show straight horizontal lines for the threshold values. «Day-degree threshold for low likelihood of attack» corresponds to when the warning changes from green to yellow (260 day-degrees). «Day-degree threshold for high likelihood of attack » corresponds to when the warning changes from yellow to red (360 day-degrees). «Day-degree threshold for end of flight period» corresponds to when the warning changes from red to grey (560 day-degrees) and the flight period for the 1st generation is considered to be over. When the line « Accumulated day-degrees with the base temperature of 5 degrees C» intersects one of the lines for the day-degree threshold, the warning will advance to the next level and the color of the warning rectangle will change. The graph also shows the daily mean temperature for the relevant weather station. The graph is dynamic and the user can choose which parameters that are shown by clicking on the explanation below the graph.</p> + <h3>Warning season – start and end of the warning</h3> + <p>Starting time: Shown in VIPS from 1 April (starting date for accumulation of degree-days beginning from when the ground has thawed).<br /> Ending time: When the model has reached the requirement for the end of the flight period for the 1st generation (560 day-degrees).</p> + <h3>Testing and validation of the model</h3> + <h4>National</h4> + <p>The model has been tested for Norwegian conditions in the period of 2011-2015. Validation has shown that the model was accurate for most locations for the 1st generation. The model was, however, inaccurate for the 2nd generation for many locations and was totally incorrect for the district of Jæren. Based on the validation results, we have therefore chosen to remove warning of the 2nd generation of carrot rust fly from this model.</p> + <h4>International</h4> + <p>The model is in use in Finland. The extent to which the model has been validated in Finland is uncertain, but a validation was done in the summer of 1997. This validation showed that the model was quite accurate, but that the threshold temperature sm should be lowered to 255 day-degrees for the start of the flight period (as opposed to 260 degree-days in the original model) and 355 degree-days forthe peak flight period (as opposed to 360 degree-days in the original model) (Tiilikkala & Ojanen, 1999).</p> + <h3>Literature</h3> + <p>Markkula, I., H. Ojanen and K. Tiilikkala. 1998. Forecasting and monitoring of the carrot fly (<em>Psila rosae</em>) in Finland. The 1998 Brighton Conference: Pests and Diseases: Conference Proceedings, Volume 2, pages 657-662.</p> + <p>Tiilikkala, K. and H. Ojanen. 1999. Use of a geographical information system (GIS) for forecasting the activities of carrot fly and cabbage root fly. IOBC/WPRS Bulletin 22 (5): 15-24.</p> + <p>Markkula, I., A. Hannukkala, A. Lehtinen, I. Mattila, H. Ojanen, S. Raisjio, P. Reijonen and K. Tiilikkala. 2000. Pest warnings and forecasts sent as SMS messages from models into \"farmer's pocket\". In publication: Pests & Diseases 2000. Proceedings of an international conference held at the Brighton Hilton Metropole Hotel, UK, 13-16 November 2000. BCPC Conference Proceedings pages 285-290.</p> + <p> </p> + <p><strong>Contacts</strong></p> + <p>Annette Folkedal Schjøll <a href=\"mailto:annette.folkedal.schjoll@nibio.no\">annette.folkedal.schjoll@nibio.no</a><br />Tor J. Johansen <a href=\"mailto:tor.johansen@nibio.no\">tor.johansen@nibio.no</a></p> + " + "wms_enable_request" "*" + "wms_title" "Carrot rust fly (Psila rosae) temperature model" + "wms_getfeatureinfo_formatlist" "text/plain,text/html,text/xml" + "wms_accessconstraints" "none" + "wms_addresstype" "" + "wms_address" "Høgskoleveien 7" + "wms_city" "Ås" + "wms_stateorprovince" "Ås" + "wms_postcode" "1430" + "wms_country" "Norway" + "wms_contactelectronicmailaddress" "vips@nibio.no" + "wms_feature_info_mime_type" "text/html" + "wms_contactperson" "Berit Nordskog" + "wms_contactposition" "owner" + "wms_contactorganization" "Norsk institutt for bioøkonomi (NIBIO)" + END + END #web + + ############################# Start of legend ######################################################### + # The legend configuration uses the CLASSITEM information in each layer to generate colour icons and labels + LEGEND + STATUS ON + KEYSIZE 16 12 + LABEL + TYPE TRUETYPE + SIZE 10 + COLOR 0 0 0 + OFFSET 0 -3 + END + END + + + LAYER + NAME "PSILARTEMP.WARNING_STATUS.2023-04-01" + DATA "/disks/data01/mapserver/data/PSILARTEMP/result_WARNING_STATUS_2023-04-01.tif" + TEMPLATE "/disks/data01/mapserver/wms/PSILARTEMP/query_template.xml" TOLERANCE 1 TOLERANCEUNITS PIXELS + TYPE RASTER + PROCESSING "BANDS=1" # WARNING_STATUS band on top (others invisible, but band values are available in the query template) + PROCESSING "NODATA=-1" + + + STATUS ON + METADATA + "wms_title" "Carrot rust fly (Psila rosae) temperature model 2023-04-01" + END + CLASSITEM "[pixel]" + + # class using simple string comparison, equivalent to ([pixel] = 0) + + CLASS + NAME "Model not running" + EXPRESSION ([pixel] >= 0 AND [pixel] < 2) + STYLE + COLOR 112 112 112 + END + END + CLASS + NAME "No infection risk" + EXPRESSION ([pixel] >= 2 AND [pixel] < 3) + STYLE + COLOR 0 180 87 + END + END + CLASS + NAME "Possible infection risk" + EXPRESSION ([pixel] >= 3 AND [pixel] < 4) + STYLE + COLOR 255 204 0 + END + END + CLASS + NAME "High infection risk" + EXPRESSION ([pixel] >= 4) + STYLE + COLOR 255 0 0 + END + END + END # Layer + + LAYER + NAME "PSILARTEMP.DD.2023-04-01" + DATA "/disks/data01/mapserver/data/PSILARTEMP/result_2023-04-01.tif" + TEMPLATE "/disks/data01/mapserver/wms/PSILARTEMP/query_template_DD.xml" TOLERANCE 1 TOLERANCEUNITS PIXELS + TYPE RASTER + #PROCESSING "BANDS=1" # DD band on top (others invisible, but band values are available in the query template) + #PROCESSING "SCALE=AUTO" + #PROCESSING "NODATA=-1" + + + STATUS ON + METADATA + "wms_title" "Carrot rust fly (Psila rosae) temperature model Day Degrees 2023-04-01" + END + CLASSITEM "[pixel]" + CLASS + NAME "Day degrees" + #EXPRESSION ([pixel] >= 0 AND [pixel] <= 72) + STYLE + DATARANGE 0 1000 + COLORRANGE 0 0 255 255 0 0 + END + END + + END # Layer + + + LAYER + NAME "PSILARTEMP.WARNING_STATUS.2023-04-02" + DATA "/disks/data01/mapserver/data/PSILARTEMP/result_WARNING_STATUS_2023-04-02.tif" + TEMPLATE "/disks/data01/mapserver/wms/PSILARTEMP/query_template.xml" TOLERANCE 1 TOLERANCEUNITS PIXELS + TYPE RASTER + PROCESSING "BANDS=1" # WARNING_STATUS band on top (others invisible, but band values are available in the query template) + PROCESSING "NODATA=-1" + + + STATUS ON + METADATA + "wms_title" "Carrot rust fly (Psila rosae) temperature model 2023-04-02" + END + CLASSITEM "[pixel]" + + # class using simple string comparison, equivalent to ([pixel] = 0) + + CLASS + NAME "Model not running" + EXPRESSION ([pixel] >= 0 AND [pixel] < 2) + STYLE + COLOR 112 112 112 + END + END + CLASS + NAME "No infection risk" + EXPRESSION ([pixel] >= 2 AND [pixel] < 3) + STYLE + COLOR 0 180 87 + END + END + CLASS + NAME "Possible infection risk" + EXPRESSION ([pixel] >= 3 AND [pixel] < 4) + STYLE + COLOR 255 204 0 + END + END + CLASS + NAME "High infection risk" + EXPRESSION ([pixel] >= 4) + STYLE + COLOR 255 0 0 + END + END + END # Layer + + LAYER + NAME "PSILARTEMP.DD.2023-04-02" + DATA "/disks/data01/mapserver/data/PSILARTEMP/result_2023-04-02.tif" + TEMPLATE "/disks/data01/mapserver/wms/PSILARTEMP/query_template_DD.xml" TOLERANCE 1 TOLERANCEUNITS PIXELS + TYPE RASTER + #PROCESSING "BANDS=1" # DD band on top (others invisible, but band values are available in the query template) + #PROCESSING "SCALE=AUTO" + #PROCESSING "NODATA=-1" + + + STATUS ON + METADATA + "wms_title" "Carrot rust fly (Psila rosae) temperature model Day Degrees 2023-04-02" + END + CLASSITEM "[pixel]" + CLASS + NAME "Day degrees" + #EXPRESSION ([pixel] >= 0 AND [pixel] <= 72) + STYLE + DATARANGE 0 1000 + COLORRANGE 0 0 255 255 0 0 + END + END + + END # Layer + + + LAYER + NAME "PSILARTEMP.WARNING_STATUS.2023-04-03" + DATA "/disks/data01/mapserver/data/PSILARTEMP/result_WARNING_STATUS_2023-04-03.tif" + TEMPLATE "/disks/data01/mapserver/wms/PSILARTEMP/query_template.xml" TOLERANCE 1 TOLERANCEUNITS PIXELS + TYPE RASTER + PROCESSING "BANDS=1" # WARNING_STATUS band on top (others invisible, but band values are available in the query template) + PROCESSING "NODATA=-1" + + + STATUS ON + METADATA + "wms_title" "Carrot rust fly (Psila rosae) temperature model 2023-04-03" + END + CLASSITEM "[pixel]" + + # class using simple string comparison, equivalent to ([pixel] = 0) + + CLASS + NAME "Model not running" + EXPRESSION ([pixel] >= 0 AND [pixel] < 2) + STYLE + COLOR 112 112 112 + END + END + CLASS + NAME "No infection risk" + EXPRESSION ([pixel] >= 2 AND [pixel] < 3) + STYLE + COLOR 0 180 87 + END + END + CLASS + NAME "Possible infection risk" + EXPRESSION ([pixel] >= 3 AND [pixel] < 4) + STYLE + COLOR 255 204 0 + END + END + CLASS + NAME "High infection risk" + EXPRESSION ([pixel] >= 4) + STYLE + COLOR 255 0 0 + END + END + END # Layer + + LAYER + NAME "PSILARTEMP.DD.2023-04-03" + DATA "/disks/data01/mapserver/data/PSILARTEMP/result_2023-04-03.tif" + TEMPLATE "/disks/data01/mapserver/wms/PSILARTEMP/query_template_DD.xml" TOLERANCE 1 TOLERANCEUNITS PIXELS + TYPE RASTER + #PROCESSING "BANDS=1" # DD band on top (others invisible, but band values are available in the query template) + #PROCESSING "SCALE=AUTO" + #PROCESSING "NODATA=-1" + + + STATUS ON + METADATA + "wms_title" "Carrot rust fly (Psila rosae) temperature model Day Degrees 2023-04-03" + END + CLASSITEM "[pixel]" + CLASS + NAME "Day degrees" + #EXPRESSION ([pixel] >= 0 AND [pixel] <= 72) + STYLE + DATARANGE 0 1000 + COLORRANGE 0 0 255 255 0 0 + END + END + + END # Layer + +END #map + + \ No newline at end of file diff --git a/grid_models.md b/grid_models.md new file mode 100644 index 0000000000000000000000000000000000000000..fc75d5ef4b2324d24f873c0e8e462e849e5ebb86 --- /dev/null +++ b/grid_models.md @@ -0,0 +1,96 @@ +<img src="illustrations/vipslogo_512.png" alt="VIPS Logo" height="250"/> + +# VIPS Grid models + +Tor-Einar Skog, Senior developer, NIBIO + +Updated: 2023-11-17 + +## What you will learn +This document describes how to set up a VIPS compatible DSS model displaying results in a grid, such as in the screenshot below: + +<img src="illustrations/grid_models_01.png" alt="Grid models example" width="1024"/> + +## Prerequisites +* You should be familiar with web maps and WMS services +* You should be familiar with using and manipulating gridded weatherdata files, e.g. NetCDF files or GRIB files + +## Architecture of the VIPS gridded model system +**TODO**: Architecture overview illustration + +## Structure of the WMS Service +VIPS expects the WMS Service to follow certain patterns in order to display it in a map. + +### Model metadata +You need at least these metadata set: +* `wms_title` - Used to display the model's name (see illustration above) +* `wms_abstract` - This is used to display the model's description (see illustration above) + +### WMS Layers +In order for VIPS to be able to utilize your WMS, you need to structure the layers in a specific way: +* The layer names must follow this namespacing pattern: `[MODEL_ID].[PARAMETER ID].[YYYY-MM-DD]`. For instance, the PSILARTEMP (Carrot Rust Fly) model has these layers (for one day): + * `PSILARTEMP.WARNING_STATUS.2023-04-01` + * `PSILARTEMP.DD.2023-04-01` + +For each layer, you need to specify metadata for classification and legend building, e.g. like in this mapfile excerpt: + +```mapfile +LAYER + NAME "PSILARTEMP.WARNING_STATUS.2023-04-01" + DATA "/disks/data01/mapserver/data/PSILARTEMP/result_WARNING_STATUS_2023-04-01.tif" + TEMPLATE "/disks/data01/mapserver/wms/PSILARTEMP/query_template.xml" TOLERANCE 1 TOLERANCEUNITS PIXELS + TYPE RASTER + PROCESSING "BANDS=1" # WARNING_STATUS band on top (others invisible, but band values are available in the query template) + PROCESSING "NODATA=-1" + + + STATUS ON + METADATA + "wms_title" "Carrot rust fly (Psila rosae) temperature model 2023-04-01" + END + CLASSITEM "[pixel]" + + # class using simple string comparison, equivalent to ([pixel] = 0) + + CLASS + NAME "Model not running" + EXPRESSION ([pixel] >= 0 AND [pixel] < 2) + STYLE + COLOR 112 112 112 + END + END + CLASS + NAME "No infection risk" + EXPRESSION ([pixel] >= 2 AND [pixel] < 3) + STYLE + COLOR 0 180 87 + END + END + CLASS + NAME "Possible infection risk" + EXPRESSION ([pixel] >= 3 AND [pixel] < 4) + STYLE + COLOR 255 204 0 + END + END + CLASS + NAME "High infection risk" + EXPRESSION ([pixel] >= 4) + STYLE + COLOR 255 0 0 + END + END + END # Layer +``` +This will result in correct color presentation in the map, and the availability of a legend for the map (see the upper right corner in the screenshot above) + +### Example Mapserver file +For your reference, please see the file `examples/PSILARTEMP.map` in this repository. + +## Existing VIPS grid models for reference: +* The Carrot Rust Fly Temperature Model + * [Source code](https://gitlab.nibio.no/VIPS/models/grid/grid-psilartemp) + * [In action](https://testvips.nibio.no/spatial/gridmap/PSILARTEMP/) +* Septoria Reference Humidity Model + * [Source code](https://gitlab.nibio.no/VIPS/models/grid/SEPTREFHUM) + * [In action](https://testvips.nibio.no/spatial/gridmap/SEPTREFHUM/) \ No newline at end of file diff --git a/illustrations/grid_models_01.png b/illustrations/grid_models_01.png new file mode 100644 index 0000000000000000000000000000000000000000..bc687bbc77a4af591adcde60f6c3041edf24f518 Binary files /dev/null and b/illustrations/grid_models_01.png differ