Code Monkey home page Code Monkey logo

pytseb's Introduction

PyTSEB

Synopsis

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:

  1. lower-level modules with the basic functions needed in any resistance energy balance model

  2. higher-level scripts for easily running TSEB with tabulated data and/or satellite/airborne imagery.

Installation

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:

With conda, you can create a complete environment with

conda env create -f environment.yml

Code Example

High-level example

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>

where <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>

where <configuration file> points to a customized configuration file... leave it blank if you want to use the default file Config_PointTimeSeries.txt

Low-level example

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 rad, MOsimilarity.py as MO, ClumpingIndex.py as CI and meteoUtils.py as met)

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 help(TSEB.TSEB_PT) to understand better the inputs needed and the outputs returned

The direct and difuse shortwave radiation (Sdn_dir, Sdn_dif, fvis, 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
Sdn_dir=Sdn*(1.0-Skyl)
Sdn_dif=Sdn*Skyl

Basic Contents

High-level modules

  • .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)

Low-level modules

The low-level modules in this project are aimed at providing customisation and more flexibility in running TSEB. The following modules are included

  • .pyTSEB/TSEB.py

core functions for running different TSEB models (TSEB_PT (*args,**kwargs), TSEB_2T(*args,**kwargs), DTD (*args,**kwargs)), or a One Source Energy Balance model (OSEB(*args,**kwargs)).

  • .pyTSEB/net_radiation.py

functions for estimating net radiation and its partitioning between soil and canopy

  • .pyTSEB/resistances.py

functions for estimating the different resistances for momemtum and heat transport and surface roughness

  • .pyTSEB/MO_similarity.py

functions for computing adiabatic corrections for heat and momentum transport, Monin-Obukhov length, friction velocity and wind profiles

  • .pyTSEB/clumping_index.py

functions for estimating the canopy clumping index and get effective values of Leaf Area Index

  • .pyTSEB/meteo_utils.py

functions for estimating meteorolgical-related variables such as density of air, heat capacity of air or latent heat of vaporization.

API Reference

http://pytseb.readthedocs.org/en/latest/index.html

Main Scientific References

  • Norman, J. M., Kustas, W. P., Prueger, J. H., and Diak, G. R.: Surface flux estimation using radiometric temperature: a dual-temperature-difference method to minimize measurement errors, Water Resour. Res., 36, 2263, doi: 10.1029/2000WR900033, 2000
  • Norman, J., Kustas, W., and Humes, K.: A two-source approach for estimating soil and vegetation fluxes from observations of directional radiometric surface temperature, Agr. Forest Meteorol., 77, 263–293, doi: 10.1016/0168-1923(95)02265-Y, 1995
  • Kustas, W. P. and Norman, J. M.: A two-source approach for estimating turbulent fluxes using multiple angle thermal infrared observations, Water Resour. Res., 33, 1495–1508, 199
  • Kustas, W. P. and Norman, J. M.: Evaluation of soil and vegetation heat flux prediction using a simple two-source model with radiometric temperatures for partial canopy cover, Agr. Forest Meteorol., 94, 13–29, 199
  • Guzinski, R., Nieto, H., Stisen, S., and Fensholt, R.: Inter-comparison of energy balance and hydrological models for land surface energy flux estimation over a whole river catchment, Hydrol. Earth Syst. Sci., 19, 2017-2036, doi:10.5194/hess-19-2017-2015, 2015.
  • William P. Kustas, Hector Nieto, Laura Morillas, Martha C. Anderson, Joseph G. Alfieri, Lawrence E. Hipps, Luis Villagarcía, Francisco Domingo, Monica Garcia: Revisiting the paper “Using radiometric surface temperature for surface energy flux estimation in Mediterranean drylands from a two-source perspective”, Remote Sensing of Environment, In Press. doi:10.1016/j.rse.2016.07.024.

Tests

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/

Contributors

License

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/.

pytseb's People

Contributors

clairebrenner avatar gabrielmini avatar hectornieto avatar j08lue avatar mrpgraae avatar radosuav avatar roscavm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pytseb's Issues

zero-size array error

I am trying to using point time series, I used this datas as an input with Component temperature model in tseb: "year", "DOY", "time", "S_dn", "T_A1", "u" ,"T_S", "T_C", "RH", "ea", "LAI", "h_C", "f_c", "VZA".

However pytseb resulted this error given below. How can we solve this issue or what is the source of this error?

Processing...
Iteration 0, max. L diff: inf
Iteration 1, max. L diff: inf
Iteration 2, max. L diff: inf
Iteration 3, max. L diff: inf
Iteration 4, max. L diff: inf
c:\Work\coding\Python\pyTSEB\pyTSEB-master\pyTSEB\TSEB.py:1956: RuntimeWarning: invalid value encountered in divide
L_diff = np.asarray(np.fabs(L - L_old) / np.fabs(L_old), dtype=np.float32)

ValueError Traceback (most recent call last)
File c:\Work\coding\Python\pyTSEB\pyTSEB-master\pyTSEB\TSEBIPythonInterface.py:1101, in TSEBIPythonInterface._on_runmodel_clicked(self, b)
1099 self.get_data_TSEB_widgets(is_image=self.is_image)
1100 # run TSEB
-> 1101 self.run(is_image=self.is_image)
1102 # Change the colour of the button to know it has finished
1103 self.w_runmodel.background_color = 'green'

File c:\Work\coding\Python\pyTSEB\pyTSEB-master\pyTSEB\TSEBConfigFileInterface.py:276, in TSEBConfigFileInterface.run(self, is_image)
274 model.process_local_image()
275 else:
--> 276 in_data, out_data = model.process_point_series_array()
277 return in_data, out_data
278 else:

File c:\Work\coding\Python\pyTSEB\pyTSEB-master\pyTSEB\PyTSEB.py:412, in PyTSEB.process_point_series_array(self)
407 self.res_params['KN_C_dash'] = np.ones(dims) * self.p['KN_C_dash']
409 # ======================================
410 # Run the chosen model
--> 412 out_data = self.run(in_data.to_records(index=False))
413 out_data = pd.DataFrame(data=np.stack(out_data.values()).T,
414 index=in_data.index,
415 columns=out_data.keys())
417 # ======================================
...
83 else:
84 return reduction(axis=axis, out=out, **passkwargs)
---> 86 return ufunc.reduce(obj, axis, dtype, out, **passkwargs)

ValueError: zero-size array to reduction operation maximum which has no identity

sza and saa missing parameter

Dear Creators,
I have been at https://landtraining2022.esa.int/ and i am trying to use your module but i have several problems.

after running the following command in the terminal inside of the folder

python TSEB_local_image_main.py Config_LocalImage.txt

with two different methods TSEB_PT and DTD i have the following output in the console

Run pyTSEB with configuration file = Config_LocalImage.txt
Error: missing parameter sza
pyTSEB will not be run due to errors in the input data.
Run pyTSEB with configuration file = Config_LocalImage.txt
Error: missing parameter saa
pyTSEB will not be run due to errors in the input data.

How can i solve this?

A problem about TSEB_point_time_series_main.py

When I run the two tests of TSEB, the TSEB_local_image_main.py can run , although it show a error 4:
image
But when I run the Tseb_point_time_series_main.py, It's not finished, and give me some error.
image

something wrong with the guide documentation

The ancillary result doesn't match the guide documentation from the fifth band, 11 and 13 are the same, called “Friction velocity (m s-1)” shown in the picture.
image
Is something wrong with the guide documentation?

How to determine the S_dn_dir and S_dn_dif?

Sn_C = ((1.0 - taubt[0]) * (1.0- albb[0]) * S_dn_dir*fvis

Hi, author. Thank you for your sharing about the TSEB-PT code. Now we only have sunshine duration data for the sun radiation. Then we can estimate the total shortwave radiation (Rs). In order to obtain the S_dn_dir and S_dn_dif, we want to know whether the following equations are correct:
S_dn_dir = Rsfvisdirvis+Rsfnirdirnir;
S_dn_dif = Rsfvisdifvis+Rsfnirdifnir;
where, fvis, fnir, dirvis, dirnir, difvis, difnir derive from
def calc_difuse_ratio(S_dn, sza, press=1013.25, SOLAR_CONSTANT=1320):
.

deltaT in calc_R_S_Kustas

Hi,

I was wondering about the correct value for deltaT as argument to the function calc_R_S_Kustas.
The docstring says:
deltaT : float
Surface to air temperature gradient (K).
However, in the the TSEB_PT function the difference in T_C and T_S is used "deltaT": T_S[i] - T_C[i] (line 715).

I checked the given reference (Kustas 1999) there the T_S - T_C difference is used in Eq. 5. However, the texted says: "Since the model derives both soil and canopy temperatures, as a first approximation, TC was substituted for TA".

I am not sure which gradient should be used - in the old version of pyTSEB (before this major update) the T_S - T_A gradient war used.

Thanks in advance for your help.

Improvement to give tkinter file dialog focus

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!

leaf width units

What is the unit for leaf width? I saw meters in the sample code, however I get model failure when I use values less that 0.5. Thoughts? Thanks.

Inconsistent temperature units

Input temperatures are provided in degrees Celsius, while output temperatures are saved in degrees Kelvin. This is inconsistent and potentially confusing. Both input and output temperatures should have the same units, probably Kelvin since this is an SI base unit.

L_diff

Hello, your code is exquisite. But I encountered an issue while running the test data for TSEB-2T (as follows). I hope you can help me solve it. Thank you very much

Iteration 0, max. L diff: inf
Iteration 1, max. L diff: inf
D:\Desktop\pyTSEB-master\pyTSEB\TSEB.py:1956: RuntimeWarning: invalid value encountered in divide
  L_diff = np.asarray(np.fabs(L - L_old) / np.fabs(L_old), dtype=np.float32)
Iteration 2, max. L diff: inf
Iteration 3, max. L diff: inf
Iteration 4, max. L diff: inf
Iteration 5, max. L diff: inf
Traceback (most recent call last):
  File "D:\Desktop\pyTSEB-master\TSEB_local_image_main.py", line 36, in <module>
    run_TSEB_from_config_file(config_file)
  File "D:\Desktop\pyTSEB-master\TSEB_local_image_main.py", line 28, in run_TSEB_from_config_file
    setup.run(is_image=True)
  File "D:\Desktop\pyTSEB-master\pyTSEB\TSEBConfigFileInterface.py", line 274, in run
    model.process_local_image()
  File "D:\Desktop\pyTSEB-master\pyTSEB\PyTSEB.py", line 260, in process_local_image
    out_data = self.run(in_data, mask)
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Desktop\pyTSEB-master\pyTSEB\PyTSEB.py", line 624, in run
    self._call_flux_model_veg(in_data, out_data, model_params, i)
  File "D:\Desktop\pyTSEB-master\pyTSEB\PyTSEB.py", line 1422, in _call_flux_model_veg
    out_data['u_friction'][i], out_data['L'][i], out_data['n_iterations'][i]] = TSEB.TSEB_2T(
                                                                                ^^^^^^^^^^^^^
  File "D:\Desktop\pyTSEB-master\pyTSEB\TSEB.py", line 463, in TSEB_2T
    i, l_queue, l_converged, l_diff_max = monin_obukhov_convergence(L,
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Desktop\pyTSEB-master\pyTSEB\TSEB.py", line 3761, in monin_obukhov_convergence
    l_diff_max = np.max(_L_diff(l_queue[0][i], l_queue[1][i]))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<__array_function__ internals>", line 200, in amax
  File "E:\python\Lib\site-packages\numpy\core\fromnumeric.py", line 2820, in amax
    return _wrapreduction(a, np.maximum, 'max', axis, None, out,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\python\Lib\site-packages\numpy\core\fromnumeric.py", line 86, in _wrapreduction
    return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
zero-size array to reduction operation maximum which has no identity

'dict' object has no attribute 'myget'

Hi @hectornieto!

First of all, I'd like to thank you for releasing your code.

I tried to run TSEB_local_image_main.py but I got the following error:

Exception has occurred: AttributeError
'dict' object has no attribute 'myget'

  File "/mnt/c/Users/User/Projects/pyTSEB/pyTSEB/TSEBConfigFileInterface.py", line 163, in _parse_common_config
    conf['model'] = parser.myget('model')
  File "/mnt/c/Users/User/Projects/pyTSEB/pyTSEB/TSEBConfigFileInterface.py", line 243, in get_data
    conf = self._parse_common_config(parser)
  File "/mnt/c/Users/User/Projects/pyTSEB/TSEB_point_time_series_main.py", line 26, in run_TSEB_from_config_file
    setup.get_data(config_data, is_image=False)
  File "/mnt/c/Users/User/Projects/pyTSEB/TSEB_point_time_series_main.py", line 41, in <module>
    run_TSEB_from_config_file(config_file)

After some troubleshooting, I found out that the cause is parse_input_config(), which returns dict(parser.items("top")).

If I change the return statement to return parser, everything works perfectly.

KeyError: 'model'

I install everything sucsessfully. When I was trying to load configure file Config_LocalImage, I got an error like this:
image

Issues importing gdal

"import gdal\n",

returns No module named 'gdal'
However the gdal manual states, that import gdal is deprecated and should be replaced by from osgeo import gdal

I installed gdal with
conda install -c conda-forge gdal
and importing with from osgeo import gdal results in no issues, so gdal is installed correctly.

but doing so in the script returns issues:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Input In [3], in <cell line: 29>()
     27 # Setup the figure
     28 s1= figure(title="H",plot_width=cols, plot_height=rows, x_range=[0, cols], y_range=[0, rows])
---> 29 s1.axis.visible = None
     30 s1.image(image=[np.flipud(H)],x=[0],y=[0],dw=cols,dh=rows,color_mapper=map_LE)
     31 s2= figure(title="LE",plot_width=cols, plot_height=rows, x_range=s1.x_range, y_range=s1.y_range)

File ~/anaconda3/envs/pyTSEB/lib/python3.10/site-packages/bokeh/models/plots.py:787, in _list_attr_splat.__setattr__(self, attr, value)
    785 def __setattr__(self, attr, value):
    786     for x in self:
--> 787         setattr(x, attr, value)

File ~/anaconda3/envs/pyTSEB/lib/python3.10/site-packages/bokeh/core/has_props.py:230, in HasProps.__setattr__(self, name, value)
    228 properties = self.properties(_with_props=True)
    229 if name in properties:
--> 230     return super().__setattr__(name, value)
    232 descriptor = getattr(self.__class__, name, None)
    233 if isinstance(descriptor, property): # Python property

File ~/anaconda3/envs/pyTSEB/lib/python3.10/site-packages/bokeh/core/property/descriptors.py:283, in PropertyDescriptor.__set__(self, obj, value, setter)
    280     class_name = obj.__class__.__name__
    281     raise RuntimeError(f"{class_name}.{self.name} is a readonly property")
--> 283 value = self.property.prepare_value(obj, self.name, value)
    284 old = self._get(obj)
    285 self._set(obj, old, value, setter=setter)

File ~/anaconda3/envs/pyTSEB/lib/python3.10/site-packages/bokeh/core/property/bases.py:365, in Property.prepare_value(self, owner, name, value, hint)
    363 else:
    364     obj_repr = owner if isinstance(owner, HasProps) else owner.__name__
--> 365     raise ValueError(f"failed to validate {obj_repr}.{name}: {error}")
    367 if isinstance(owner, HasProps):
    368     obj = owner

ValueError: failed to validate LinearAxis(id='1015', ...).visible: expected a value of type bool or bool_, got None of type NoneType

tested with Python Version: 3.10.4

Error running TSEB-2T when using TIFF as input for canopy temperature (first band)

I am using the most recent version of pyTSEB and I am having a strange issue when using the TSEB-2T version of it. Below is the error I am getting. I have also attached a screen capture.

gdal version 3.4
python version 3.10.9

Provide a valid S_dn_24 (Daily shortwave irradiance) value if you want to estimate daily ET F:/Raw_Data/2021/Selhausen/20210720_ICOS/FLIR/1325_flight/720_FLIR_Removed_modified3_kelvin_resample_crop.tif image not present for parameter T_R1 ERROR: file read T_S Please type a valid filename or a numeric value for

I have used several different TIFF files and still get the same error and the files are used successfully with the DTD and default TSEB versions. It runs when I put in a numerical value for the first band and TIFF for second band. If I use a TIFF for first band and numerical value for the second band, same error.

Need help

Great work. I have a question. If I run 1*1 degrees on a global scale, how to set up the Standard longitude of the time zone (degrees) for each grid?
Thank you very much for your kindly help.
Best

KeyError: 'time' with G_form=2; model tseb-pt

Traceback (most recent call last): File "C:/Users/user/Documents/UNI/masterarbeit/Modelle_skript/TSEB/pyTSEB-master/pyTSEB-master/TSEB_local_image_main.py", line 37, in <module> run_TSEB_from_config_file(config_file) File "C:/Users/user/Documents/UNI/masterarbeit/Modelle_skript/TSEB/pyTSEB-master/pyTSEB-master/TSEB_local_image_main.py", line 29, in run_TSEB_from_config_file setup.run(is_image=True) File "C:\Users\user\Documents\UNI\masterarbeit\Modelle_skript\TSEB\pyTSEB-master\pyTSEB-master\pyTSEB\TSEBConfigFileInterface.py", line 269, in run model.process_local_image() File "C:\Users\user\Documents\UNI\masterarbeit\Modelle_skript\TSEB\pyTSEB-master\pyTSEB-master\pyTSEB\PyTSEB.py", line 193, in process_local_image self.G_form[1] = in_data['time'] KeyError: 'time'

Error in File pyTSEB.py:193
self.G_form[1] = in_data['time']

Key Error by using TSEB_local_image_main trying to use G form 2 - all other G-forms are working.

Environment:

  • Windows 10
  • Conda
  • Python 3.7
  • TSEB 2.1

Thank you for your help

Can I use the ProcessLocalImage.ipynb to derive ET of urban scenes based on UAV images?

Dear colleagues,

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.

sensible heat flux
latent heat flux
soil heat flux
net radiation
test area

Thanks.

Doubts in the use of albedo (black/white sky) product

I was studying the Guzinski et al. (2013, p. 2815) and I found this description below indicating the use of the MODIS albedo products:

Also, I found another use of the same product (MCD43B3) in the Guzinski et al. (2014, p. 5024)

I checked the PyTSEB code and I didn't found any possible inputs for albedo, being a single value or an image. The main class (PyTSEB.PyTSEB) receives a dictionary as input parameters but none of them shows similarity with albedo. Also, I searched in the code and I found 2 points where the string "albedo" was found.

  1. The function calc_spectra_Cambpell: This function estimates the canopy spectral beam/diffuse albedo and transmittances using the Radiative Transfer Model from Campbell and Normam (1998) (equations 15.4 to 15.11). In this function, the values of albedo (beam or diffuse) are estimated using the LAI, SZA, leaf reflectance/transmittance, and soil reflectance. The reflectances and transmittances are constant values; the SZA could be estimated using geographic position and the LAI comes from satellite images (e. g. MCD15A3).

def calc_spectra_Cambpell(lai, sza, rho_leaf, tau_leaf, rho_soil, x_lad=1, lai_eff=None):

  1. The function pet_asce : According to documentation, this function is used to calculate the latent heat flux for well irrigated and cold pixel using ASCE potential ET from a tall crop. There is a hardcoded value of 0.23 assigned to the variable albedo, however, this function is never called in the PyTSEB code.

albedo = 0.23



My main doubt is if the PyTSEB needs the albedo inputs from satellite observations (like described in the papers) or if the estimation from the function calc_spectra_Cambpell is sufficient.


Note: The product MCD43B3 was discontinued, however, in February (2021), a General Accuracy Statement was available on the site NASA MODIS-Land suggesting the use of the product MCD43A3 (Available since the Collection V6). In the same way, this statement shows a recommendation to not use MODIS products prior to Collection V6, especially for research efforts, however, this is for new research, and for the old ones (that used Collection V5) there is no change.


Bibliography:
Guzinski, R., Anderson, M. C., Kustas, W. P., Nieto, H., & Sandholt, I. (2013). Using a thermal-based two source energy balance model with time-differencing to estimate surface energy fluxes with day-night MODIS observations. Hydrology and Earth System Sciences, 17(7), 2809–2825. https://doi.org/10.5194/hess-17-2809-2013

Guzinski, R., Nieto, H., Jensen, R., & Mendiguren, G. (2014). Remotely sensed land-surface energy fluxes at sub-field scale in heterogeneous agricultural landscape and coniferous plantation. Biogeosciences, 11(18), 5021–5046. https://doi.org/10.5194/bg-11-5021-2014

Campbell, G. S., & Norman, J. M. (1998). An Introduction to Environmental Biophysics. Springer New York. https://doi.org/10.1007/978-1-4612-1626-1

calc_resistances function in TSEB.py

Hello,
I downloaded the updated version of pyTSEB and I think that there is an issue in the function calc_resistances. However, I am not totally sure.

  1. in line 2514 the variable should be named u_S instead of u_d_zm. Otherwise an error is raised if the condition massman_profile[0] == 0 is not true.

  2. in general, I think massman_profile is missing in the docstring e.g. in TSEB_PT. It is thus difficult to say which values it could have exampt for the default.

  3. the if condition in line 2504 and 2551 have no effects (since in both cases the same function is called with the same arguments). Maybe this is only a placeholder by now.

Negative VZA values causing invalid values of clumping factor

I tested some MODIS Images using the layer Day_view_angle from the product MOD11A1.006. I added the offset of -65 following the product manual. On some days the VZA angle is negative at the position of the Eddy Covariance Flux Tower.

Considering equation 3 (image below) from Kustas and Norman (1999, p.15), and the theta angle (θs) is negative, the solution will produce a complex number due to math property when there is exponentiation of a negative number.
image

I tried to debug the code and I found the function calc_omega_Kustas. The NumPy array theta has float64 as type. When the code is calculating the omega values, NumPy shows a RuntimeWarning: invalid value encountered in power.
To avoid this RuntimeWarning the array theta needs to be a np.complex instead of np.float64, and if the type is not a np.complex the number will be transformed automatically to np.nan. I don't know what effect this can have on pytseb and the following functions if the theta is transformed to np.complex

My doubt is if the VZA angle could be in absolute values. If true, I can manipulate the MODIS image transforming negative values into positive ones, but if false, should I consider it as an invalid pixel value?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.