This project contains Python code for Two Source Energy Balance models (Priestley-Taylor TSEB-PT, Dual Time Difference DTD and TSEB with component soil and canopy temperatures TSEB-2T) for estimating sensible and latent heat flux (evapotranspiration) based on measurements of radiometric surface temperature.
The project consists of:
lower-level modules with the basic functions needed in any resistance energy balance model
higher-level scripts for easily running TSEB with tabulated data and/or satellite/airborne imagery.
Download the project to your local system, enter the download directory and then type
python setup.py install
if you want to install pyTSEB and its low-level modules in your Python distribution.
The following Python libraries will be required:
conda, you can create a complete environment with
conda env create -f environment.yml
The easiest way to get a feeling of TSEB and its configuration is through the provided ipython/jupyter notebooks. In a terminal shell, navigate to your working folder and type
jupyter notebook ProcessPointTimeSeries.ipynb
for configuring and running TSEB over a time series of tabulated data
jupyter notebook ProcessLocalImage.ipynb
for configuring and running TSEB over an image/scene using local meteorological data
In addition, you can also run TSEB with the scripts TSEB_local_image_main.py and TSEB_point_time_series_main.py, which will read an input configuration file (defaults are Config_LocalImage.txt and Config_PointTimeSeries.txt respectively). You can edit these configuration files or make a copy to fit your data and site characteristics and either run any of these two scripts in a Python GUI or in a terminal shell:
python TSEB_local_image_main.py <configuration file>
points to a customized configuration file... leave it blank if you want to use the default file Config_LocalImage.txt
python TSEB_point_time_series.py <configuration file>
points to a customized configuration file... leave it blank if you want to use the default file Config_PointTimeSeries.txt
You can run any TSEB model or any related process in python by importing the module TSEB from the pyTSEB package.
It will also import the ancillary modules (resitances.py as
res, netRadiation as
MO, ClumpingIndex.py as
CI and meteoUtils.py as
import pyTSEB.TSEB as TSEB
output=TSEB.TSEB_PT(Tr_K, vza, Ta_K, u, ea, p, Sdn_dir, Sdn_dif, fvis, fnir, sza, Lsky, LAI, hc, emisVeg, emisGrd, spectraVeg, spectraGrd, z_0M, d_0, zu, zt)
You can type
to understand better the inputs needed and the outputs returned
The direct and difuse shortwave radiation (
fnir) and the downwelling longwave radiation (
Lsky) can be estimated by
emisAtm = TSEB.rad.calc_emiss_atm(ea,Ta_K_1) # Estimate atmospheric emissivity from vapour pressure (mb) and air Temperature (K)
Lsky = emisAtm * TSEB.met.calc_stephan_boltzmann(Ta_K_1) # in W m-2
difvis,difnir, fvis,fnir=TSEB.rad.calc_difuse_ratio(Sdn,sza,press=p, Wv=1) # fraction of difuse and PAR/NIR radiation from shortwave irradiance (W m-2, solar zenith angle, atmospheric pressure and precipitable water vapour )
Skyl=difvis*fvis+difnir*fnir # broadband difuse fraction
.pyTSEB/pyTSEB.py, class object for TSEB scripting
ProcessPointTimeSeries.ipynb and ProcessLocalImage.ipynb notebooks for using TSEB and configuring TSEB through a Graphical User Interface, GUI
TSEB_local_image_main.py and TSEB_point_time_series.py, high level scripts for running TSEB through a configuration file (Config_LocalImage.txt or Config_PointTimeSeries.txt)
The low-level modules in this project are aimed at providing customisation and more flexibility in running TSEB. The following modules are included
core functions for running different TSEB models (
DTD (*args,**kwargs)), or a One Source Energy Balance model (
functions for estimating net radiation and its partitioning between soil and canopy
functions for estimating the different resistances for momemtum and heat transport and surface roughness
functions for computing adiabatic corrections for heat and momentum transport, Monin-Obukhov length, friction velocity and wind profiles
functions for estimating the canopy clumping index and get effective values of Leaf Area Index
functions for estimating meteorolgical-related variables such as density of air, heat capacity of air or latent heat of vaporization.
The folder ./Input contains examples for running TSEB in a tabulated time series (ExampleTableInput.txt) and in an image (ExampleImage_\< variable >.tif). Just run the high-level scripts with the configuration files provided by default and compare the resulting outputs with the files stored in ./Output/
pyTSEB: a Python Two Source Energy Balance Model
Copyright 2016 Hector Nieto and contributors.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU 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 General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Recently, I have tried to use ProcessLocalImage.ipynb to process my urban data that were derived from UAV. I used the model of Priestley Taylor. However, the results seems to have many abnormal values (i.e. NaN): The black pixels of the following pictures show NaN, and such areas are almost trees. I don't know whether can I use this method to derive the spatial ET of urban scenes.
Greetings! I noticed that method _setup_tkinter referred a StackOverflow post, while a recent comment to it advised using root.attributes('-alpha', 0.3) to make the window invisible. I'm trying to learn the usefulness of such small updates on StackOverflow. Would this comment help improve your code? I understand that such improvement might not be helpful in real life situation. In that case, do you think this comment can help prevent future bugs (for example, when the code were reused somewhere else)? I'll really appreciate it if you could kindly give me some feedback or suggestions. Thank you very much for your time. Have a nice day!
Updated docs sources for updated ReadTheDocs site
Version from which ESA ET4FAO code is based on
Mostly refactoring but also bug fixes and some new functions to bring the code in line with the development version.
source-energy-balance canopy soil radiometric-temperatures heat satellite-imagery evapotranspiration