Commit 5cdede80 authored by unknown's avatar unknown
Browse files

v1.0.5.0 the DataAltiExtrapolation_Valery() function run faster and the...

v1.0.5.0 the DataAltiExtrapolation_Valery() function run faster and the elevation gradients for daily temperature now contains the right values #4415
parent 629430dd
Package: airGR
Type: Package
Title: Suite of GR hydrological models for precipitation-runoff modelling
Version: 1.0.4.4
Version: 1.0.5.0
Date: 2017-01-18
Authors@R: c(
person("Laurent", "Coron", role = c("aut", "trl")),
......
......@@ -434,24 +434,21 @@ DataAltiExtrapolation_Valery <- function(DatesR,Precip,TempMean,TempMin=NULL,Tem
##Temperature_extrapolation____________________________________________________________________
##Initialisation
LayerTempMean <- list(); LayerTempMin <- list(); LayerTempMax <- list();
if(identical(ZInputs,HypsoData[51]) & NLayers==1){
if(identical(ZInputs,HypsoData[51]) & NLayers==1) {
LayerTempMean[[1]] <- as.double(TempMean);
if(!is.null(TempMin) & !is.null(TempMax)){ LayerTempMin[[1]] <- as.double(TempMin); LayerTempMax[[1]] <- as.double(TempMax); }
} else {
##Elevation_gradients_for_daily_mean_min_and_max_temperature
GradT <- GradT_Valery2010(); ### Day, Month, GradTmean, GradTmin and GradTmax for iCol=1,2,3,4,5, respectively
TabGradT <- matrix(NA,nrow=length(Precip),ncol=3);
for(iday in 1:366){
ind <- which(as.numeric(format(DatesR,format="%d"))==GradT[iday,1] & as.numeric(format(DatesR,format="%m"))==GradT[iday,2]);
TabGradT[ind,1:3] <- GradT[iday,3:5];
}
GradT <- as.data.frame(GradT_Valery2010())
iday <- match(format(DatesR,format="%d%m"), sprintf("%02i%02i", GradT[, "day"], GradT[, "month"]))
TabGradT <- GradT[iday, c("grad_Tmean", "grad_Tmin", "grad_Tmax")]
##Extrapolation
##On_each_elevation_layer...
for(iLayer in 1:NLayers){
LayerTempMean[[iLayer]] <- as.double(TempMean + (ZInputs-ZLayers[iLayer])*abs(TabGradT[,1])/100);
LayerTempMean[[iLayer]] <- as.double(TempMean + (ZInputs-ZLayers[iLayer])*abs(TabGradT[, "grad_Tmean"])/100);
if(!is.null(TempMin) & !is.null(TempMax)){
LayerTempMin[[iLayer]] <- as.double(TempMin + (ZInputs-ZLayers[iLayer])*abs(TabGradT[,2])/100);
LayerTempMax[[iLayer]] <- as.double(TempMax + (ZInputs-ZLayers[iLayer])*abs(TabGradT[,3])/100);
LayerTempMin[[iLayer]] <- as.double(TempMin + (ZInputs-ZLayers[iLayer])*abs(TabGradT[, "grad_Tmin"])/100);
LayerTempMax[[iLayer]] <- as.double(TempMax + (ZInputs-ZLayers[iLayer])*abs(TabGradT[, "grad_Tmax"])/100);
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment