hectornieto / pyTSEB

A python Two Source Energy Balance model for estimation of evapotranspiration with remote sensing data
GNU General Public License v3.0
137 stars 62 forks source link

Negative VZA values causing invalid values of clumping factor #44

Closed gabrielmini closed 3 years ago

gabrielmini commented 3 years ago

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?

hectornieto commented 3 years ago

Dear Gabriel, yes, you can/should use the absolute value of the VZA,

All the best,

On Thu, 10 Jun 2021 at 22:09, gabrielmini @.***> wrote:

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 https://lpdaac.usgs.gov/products/mod11a1v006/. 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: image] https://user-images.githubusercontent.com/12013961/121583911-41a75800-ca07-11eb-85fb-cd0e8ef980ea.png

I tried to debug the code and I found the function calc_omega_Kustas https://github.com/hectornieto/pyTSEB/blob/ccc0640b3ef0e69e618a7a2e50d92ae2205b81dc/pyTSEB/clumping_index.py#L94. 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?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/hectornieto/pyTSEB/issues/44, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXW5TRNKLH6DQCMLLZSJMDTSELX7ANCNFSM46PHWI5A .