midraed / water

R package to calculate surface energy balance models
24 stars 20 forks source link

Issue with METRIC.EB function #15

Closed pascaloettli closed 8 years ago

pascaloettli commented 8 years ago

While running the example from the simple procedure vignette, the METRIC.EB function gives incorrect values for the sensible and latent heat, for some pixels.

Here is the call to the function as well as the warning message:

Energy.Balance <- METRIC.EB(image.DN = image.DN, plain=TRUE, 
                              WeatherStation = WeatherStation, 
                              ETp.coef = 1.2, MTL=MTLfile, 
                              sat="L7", thermalband=B6)
# Warning in setValues(r, log(values(x), base = base)) : NaNs produced
#    pixel      X        Y       Ts  LAI type
#1  43077 280560 -3917040 325.4446 0.13  hot
#2 118655 277020 -3921600 311.2627 3.32 cold
# Warning in calcH(anchors = hot.and.cold, Ts = Ts, Z.om = Z.om, WeatherStation = WeatherStation,  :
#   u200 less than threshold value = 0.2942m/s. using u200 = 4m/s

plot(subset(Energy.Balance, c(3,4)))

rplot

Here is a zoom on problematic pixels:

out <- crop(Energy.Balance, extent(278000, 280000, -3923000, -3921000))
plot(subset(out, c(3,4)))

rplot01


Some information:

R version 3.2.3 Patched (2015-12-24 r69814)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.3 LTS

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
1] water_0.3    rgdal_1.1-3  raster_2.5-2 sp_1.2-1     sos_1.3-8   
[6] brew_1.0-6  

loaded via a namespace (and not attached):
[1] Rcpp_0.12.2     grid_3.2.3      lattice_0.20-33
midraed commented 8 years ago

Thank you @pascaloettli for the issue. METRIC uses a lot of empiric equations, and some times the real data it's outside from the model limits. I think we get some NA's when trying to evaluate non-vegetated (buildings for example) pixels.

We should study this deeply.