SEBAL model by means GRASS and PYTHON SEBAL

Surface Energy Balance Algorithm for Land

Introduction

In few words, the Surface Energy Balance Algorithm for Land (SEBAL) is used to predict some hydrological features like evapotranspiration, water deficit, etc. The main creator of SEBAL is Professor Wim G. M. Bastiaanssen (Bastiaanssen et al., 1998) and his method has been validated under several conditions for different locations ((Bastiaanssen, 2000),(Bastiaanssen et al., 2002), (Santos et al., 2010)).

Around 3 years ago I wrote a code to run the SEBAL, and I still find one or two emails every month asking some doubt about the script (unfortunately I cannot answer all). Thus I will try in this post and with a video to explain how to run the script. You can find the video:

Material and Methods

The basic requirements to run the script are:

  • a computer with 4 GB of RAM and a i3 processor
  • operational system Debian 11, UBUNTU, MINT or similar
  • Python 3.7 or + and PIP3 package manager
  • GRASS GIS 78 or +
  • Landsat8 images and DEM from ASTER
  • files from repository

For a better explanation this tutorial is divided in seven steps:

  1. download the files from repository HERE
  2. download landsat 8 images and DEM file
  3. create a python environment and install all required packages
  4. verify if grass is installed and to find the path
  5. assign GRASS workdir and create location
  6. edit script to assign the paths and variables
  7. run the model

Download files from repository

Create a folder in you system, go to HERE and download the files: sebal_v10.py and requirement_pysebal.txt. I created a folder sebal_tutorial.

Download landsat8 images and DEM

Download all Landsat8 images and save in the same folder created in step 1. Just to remember, I create a folder named as sebal_tutorial . Repeat the process for Digital Elevation Model (DEM) from ASTER.

Once that all images has been downloaded, reproject all the images (LS8 images) for the interested coordinate reference system (e.g. EPSG:32721).

NOTE: You MUST reproject the DEM file for the same coordinate reference system of interest, RENAME it as MDT_Sebal.TIF.

Python environment

To create a python environment, first create a new folder. I will create venv_sebal folder. Now, in Linux Terminal, We can create the python environment with the code:

python3 -m venv ./venv_sebal

Once it is done, We can activate the environment and install the packages. To activate the environment:

source ~/.virtualenvs/venv_sebal/bin/activate

To install all the package, download THIS file into the Downloads folder or any other. Now you can type in terminal:

pip3 install -r /media/rafatieppo/hd_back/sebal_tutorial/requirement_pysebal.txt

Verify if all packs has been installed correctly, You can try to import the packs.

# Order matters
import math
import numpy as np
import os
from grass_session import session
import grass.script as gscript
from grass.script import core as gcore

If all is ok, We can advance for the step 4.

GRASS GIS and config path

If you do not have GRASS GIS in your machine, you can try to install (it requires root privileges):

apt-get install grass
apt-get install grass-gui
apt-get install grass-dev

Let’s find the path?

grass78 --config path

It should return something like this:

usr/lib/grass78

Copy and paste this path in a notepad.

GRASS workdir and location

To assign the GRASS GIS data base, create a GRASS LOCATION and MAPSET, watch the video. Just in case, my GRASS GIS data base is /home/rafatieppo/grassdata . I created a GRASS LOCATION epsg31981, and about the MAPSET I keep the standard, which is PERMANTENT.

Import MDT file in grass

NOTE: The script will make all the processing only for the area covered by MDT image. The GRASS GIS call it as Computational Region. It means that although We will import the full landsat images, the calculations will be just over the MDT area. Thus, BEFORE you import the MDT file, make sure if your field (study area) is covered by the MDT file. You can edit (cut) the MDT file in other software (e.g. QGIS).

To import the file, in main menu click on: File -> Import raster data -> r.import

Fill the required field Source input:

  • click on Browse find the MDT file, and click on Open
  • click on import. After close.

Edit script to assign the paths and variables

To run GRASS GIS it is necessary to set some parameters:

gisbase = '/usr/lib/grass78'
gisdb = '/home/rafatieppo/grassdata'
location = 'epsg31981'
mapset = 'PERMANENT'

# Finding files and assign local variables
# path = "/media/rafatieppo/SSD_24gb/QGIS_SEBAL/20170904"
path = '/media/rafatieppo/hd_back/sebal_tutorial/'

Note that:

  • gisbase is the path for GRASS GIS
  • gisdb is the local folder to store GRASS data
  • location is the local with a particular CRS (we created that)
  • mapset is a kind of subdivision to work into the location (we use PERMANENT location)
  • path is the path for the workdir, where is all files (landsat, DEM, script, …)

After edition, save and close the script.

Run the model

Once you are in correct folder (that one with all your files), just run:

python3 SEBAL_v10.py,

Three variables will be required:

  • wind speed value in the weather station (height of the 2 m (m/s))
  • instantaneous value of reference evapotranspiration (EToi) in the weather station (time of the satellite overpass (mm))
  • daily value of reference evapotranspiration (ETo) from the weather station (mm)

After that, several process will be started, after some of them, the coordinates for cold pixel and hot pixel will be required. For a better choice of this coordinates, I recommend to read the references. Just for a very short explanation, at moment that the cold pixel coordinate is required, you may:

  • open GRASS GIS
  • add raster layers: AS LAI CC_432 COLDPIX
  • for COLDPIX layer create a histogram plot, note the temperature values in X axis
    • it is necessary a point with low temperature, but no extremely cold (in my case around 299)
    • go to the COLDPIX layer, find a pixel with this temperature and get its coordinates
    • once you found this pixel, make sure that its LAI value is between 4 and 6, and AS value is between 0.22 and 0.24
    • if conditions are not satisfied, look for another point
    • look for areas with irrigation system
    • copy and paste the coordinates in terminal like this: 453086.876501,8379695.52117
    • to copy coordinates from GRASS press CTRL+C, to paste in terminal press CTRL+SHIFT+V
    • press ENTER

For hot pixel coordinates, it is the same idea:

  • add HOTPIX layer and create a histogram plot, note the temperature values in X axis
    • find a high temperature but not extreme, and check values for LAI and aS
    • copy and paste the coordinates in terminal like this: 452632.542909,8379983.49339
    • to copy coordinates from GRASS press CTRL+C, to paste in terminal press CTRL+SHIFT+V
    • press ENTER

If all worked well, It is possible to find all files in GRASS GIS. Just export the raster files if you desire.

References

  • Bastiaanssen, W.G.M., 2000. SEBAL-based sensible and latent heat fluxes in the irrigated Gediz Basin, Turkey. Journal of Hydrology 229, 87–100. https://doi.org/https://doi.org/10.1016/S0022-1694(99)00202-4
  • Bastiaanssen, W.G.M., Ahmad, M.-u.-D., Chemin, Y., 2002. Satellite surveillance of evaporative depletion across the Indus Basin. Water Resources Research 38, 9–1–9–9. https://doi.org/10.1029/2001WR000386
  • Bastiaanssen, W.G.M., Menenti, M., Feddes, R.A., Holtslag, A.A.M., 1998. A remote sensing surface energy balance algorithm for land (SEBAL). 1. Formulation. Journal of Hydrology 212-213, 198–212. https://doi.org/https://doi.org/10.1016/S0022-1694(98)00253-4
  • Bernardo, S., Soares, A.A., Mantovani, E.C., 2006. Manual de irrigação, 8th ed. UFV, Viçosa.
  • Cavalcante, L.B., Inácio, A. da S., Barros, H.G., Jiménez, Nicácio, R.M., Coelho, S.M.S. da C., 2016. Cálculo do saldo de radiação pelo algoritmo sebal na porção do baixo-médio São Francisco, Brasil, utilizando um software de código livre. Revista Brasileira de Cartografia 1515–1529.
  • Gondim, R., Teixeira, A.d.S., Barbosa, F., 2005. Novo paradigma para a água e coeficientes de cultivos aplicados à gestão de recursos hídricos em nível de bacia hidrográfica. Revista Item Irrigação e Tecnologia 14–18.
  • Hessels, T., Opstal, J. van, Trambauer, P., Bastiaanssen, W., Smiej, M.F., Mohamed, Y., Er-Raji, A., 2017. pySEBAL_3.3.8.
  • Neteler, M., Bowman, M.H., Landa, M., Metz, M., 2012. GRASS GIS: a multi-purpose Open Source GIS. Environmental Modelling & Software 31, 124–130. https://doi.org/10.1016/j.envsoft.2011.11.014
  • Rossum, G. van, 1995. Python tutorial (No. CS-R9526). Centrum voor Wiskunde en Informatica (CWI), Amsterdam.
  • Santos, T.V. dos, Fontana, D.C., Alves, R.C.M., 2010. Avaliação de fluxos de calor e evapotranspiração pelo modelo SEBAL com uso de dados do sensor ASTER. Pesquisa Agropecuária Brasileira 45, 488–496. https://doi.org/10.1590/S0100-204X2010000500008
  • Wolff, W., 2016. wwolff7/SEBAL_GRASS. https://doi.org/10.5281/zenodo.167350
  • PYTHON
  • Python GDAL/OGR Cookbook 1.0 documentation
  • GDAL/OGR
  • GDAL API Python

 Share!

 
comments powered by Disqus