Skip to content
Snippets Groups Projects
Commit 6742839b authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Add documentation and license

parent cb6bf95f
No related branches found
No related tags found
2 merge requests!3Main,!2Main
#!/usr/bin/python3 #!/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 os, shutil
import subprocess,glob import subprocess,glob
from dotenv import load_dotenv from dotenv import load_dotenv
......
# 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 ## 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. 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. 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 #### 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). 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 ![WARNING_STATUS example. Showing Norway and surrounding area](./wms_illustration.png)
# 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"
wms_illustration.png

545 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment