diff --git a/NAERSTADMO.py b/NAERSTADMO.py index b1ec6c38d39d8afd127f57bb03d726710f8cead5..77eb4d8ef4b0f05fac03cb5ae135b5dd26c7e46a 100644 --- a/NAERSTADMO.py +++ b/NAERSTADMO.py @@ -1,5 +1,24 @@ #!/usr/bin/python3 +""" + 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/>. +""" + +# Author: Brita Linnestad <brita.linnestad@nibio.no> + import os, shutil import subprocess,glob from dotenv import load_dotenv diff --git a/README.md b/README.md index 0af07e81b03d9bc9be07ba7c7af11a104a321fe5..c7d2f2c620e3d9c3b420a2cece40e38838fbb19e 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,70 @@ -# Naerstad Poteto Blight - spatial version - +# Naerstad Potato Blight Model - spatial version +The model is based on several years of experiments where trap plants have been placed next to a potato field infected with late blight. Infections on these plants have been correlated with weather conditions the day of exposure, and this is the data the model is based on. The model predicts if there are favorable conditions for spore production and the following spread, survival and infection of these spores. The model produces an infection risk, and a value of 2.5 corresponds to one spot of late blight on each trap plant exposed. This value of 2.5 is the threshold where the model issues a warning. ## Technical description - - -###Software requirements +### Software requirements The model can only be run on Linux, as some of the tools mentioned below are only available on Linux. The development and testing of the model has been done using Ubuntu Linux 22.04LTS. -####CDO and GDAL +#### CDO and GDAL The heavy lifting in this model is done by the tools CDO and GDAL. These tools need to be installed and available. CDO is only available on Linux. -####Python requirements -The Python requirements are specified in requirements.txt file, and are included in the virtualenv created by the run_NAERSTADMO.sh (see below). +#### Python requirements +The Python requirements are specified in the `requirements.txt` file, and are included in the virtualenv created by the `run_NAERSTADMO.sh` (see below). + +#### Input data requirements +The model assumes weather data files named `met_1_0km_nordic-[YYYY-MM-DD].nc` with hourly values of: +* Temperature (TM) +* Relative humidity (UM) +* Precipitation (RR) +* Wind speed (FF) +* Global radiation (Q0) + +#### Running the model +It is required that you have set the following environment variables: + +```bash +# Path to this code (HOME_DIR + NAERSTADMO) +HOME_DIR=/foobar/gridmodels/ +# Path to the weather data files. Expecting hourly values in files named met_1_0km_nordic-[YYYY-MM-DD].nc +WEATHER_DATA_DIR=/foobar/met_1_0km_nordic/2024/ +# Start date for the model +START_DATE=2024-05-15 +# Use this file to crop the output of the grid +MASK_FILE=Norge_landomrader.csv +# Where the GeoTIFF files will be output +DATA_DIR=/foobar/mapserver/data/NAERSTADMO/ +# Where the mapfile will be output +MAPFILE_DIR=/foobar/mapserver/wms/NAERSTADMO/ +# Path to the GeoTIFF files used by mapserver (written to mapfile) +MAPSERVER_DATA_DIR=/foobar2/mapserver/data/NAERSTADMO/ +# Path to the mapfile used by mapserver (written to mapfile) +MAPSERVER_MAPFILE_DIR=/foobar2/mapserver/wms/NAERSTADMO/ +# Path to the mapserver log file for this WMS (written to mapfile) +MAPSERVER_LOG_FILE=/foobar2/mapserver/log/NAERSTADMO.log +# Path for mapserver to store tmp images (written to mapfile) +MAPSERVER_IMAGE_PATH=/foobar2/mapserver/tmp/ +# Extent of map (written to mapfile) +MAPSERVER_EXTENT="-1.5831861262936526 52.4465003983706595 39.2608060398730458 71.7683216082912736" +``` + +...this is the contents of the `env-sample` file + +```bash +$ ./run_PSILARTEMP.sh +``` +This creates a Python virtualenv, installs all the Python dependencies, runs the model and stores output in a log file. + +Alternatively, primarily for development purposes, you can run the Python script PSILARTEMP directly: + +```bash +$ ./PSILARTEMP.py +``` -####Input data requirements +#### Viewing the result of the model -####Running the model +**TODO** Add more details -####Viewing the resault of the model + diff --git a/env-sample b/env-sample new file mode 100644 index 0000000000000000000000000000000000000000..d96ced325ca284ccc0f28227433f9bf67239cb8b --- /dev/null +++ b/env-sample @@ -0,0 +1,23 @@ +# Use this example to create your own .env file +# Path to this code (HOME_DIR + NAERSTADMO) +HOME_DIR=/foobar/gridmodels/ +# Path to the weather data files. Expecting hourly values in files named met_1_0km_nordic-[YYYY-MM-DD].nc +WEATHER_DATA_DIR=/foobar/met_1_0km_nordic/2024/ +# Start date for the model +START_DATE=2024-05-15 +# Use this file to crop the output of the grid +MASK_FILE=Norge_landomrader.csv +# Where the GeoTIFF files will be output +DATA_DIR=/foobar/mapserver/data/NAERSTADMO/ +# Where the mapfile will be output +MAPFILE_DIR=/foobar/mapserver/wms/NAERSTADMO/ +# Path to the GeoTIFF files used by mapserver (written to mapfile) +MAPSERVER_DATA_DIR=/foobar2/mapserver/data/NAERSTADMO/ +# Path to the mapfile used by mapserver (written to mapfile) +MAPSERVER_MAPFILE_DIR=/foobar2/mapserver/wms/NAERSTADMO/ +# Path to the mapserver log file for this WMS (written to mapfile) +MAPSERVER_LOG_FILE=/foobar2/mapserver/log/NAERSTADMO.log +# Path for mapserver to store tmp images (written to mapfile) +MAPSERVER_IMAGE_PATH=/foobar2/mapserver/tmp/ +# Extent of map (written to mapfile) +MAPSERVER_EXTENT="-1.5831861262936526 52.4465003983706595 39.2608060398730458 71.7683216082912736" diff --git a/wms_illustration.png b/wms_illustration.png new file mode 100644 index 0000000000000000000000000000000000000000..2cc29fe3bf0f06d26f591203ab4589b6ecd9d100 Binary files /dev/null and b/wms_illustration.png differ