diff --git a/DESCRIPTION b/DESCRIPTION index ef8705bda5d2cf6233f9d0259bd2d3530bc06a8e..e10e064f7f5e1db420d3e8de431d031b601956ac 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: airGR Type: Package Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling -Version: 1.0.10.11 -Date: 2018-06-29 +Version: 1.0.11.0 +Date: 2018-07-18 Authors@R: c( person("Laurent", "Coron", role = c("aut", "trl")), person("Charles", "Perrin", role = c("aut", "ths")), diff --git a/NEWS.rmd b/NEWS.rmd index fda8b9fc146fb24bd7869f15b574dcef68047a7d..a984602f8683eb929adaaa23bcfa5f58a9827143 100644 --- a/NEWS.rmd +++ b/NEWS.rmd @@ -14,19 +14,39 @@ output: +### 1.0.11.0 Release Notes (2018-07-18) + + +#### Deprectated and defunct + +- The <code>LatRad</code> argument is now deprecated in <code>PEdaily_Oudin()</code> and replaced by the <code>Lat</code> argument. + + +#### Major user-visible changes + +- <code>PEdaily_Oudin()</code> now presents a <code>LatUnit</code> argument which allows to chose the unit of the latitude between radians and degrees. + + +#### Minor user-visible changes + +- Several functions of the package were cleant or slightly modified, with no effect on their outputs. + +____________________________________________________________________________________ + + ### 1.0.10.11 Release Notes (2018-06-29) #### Bug fixes -- Fixed bug in <code>RunModel_GR2M</code>. The function now returns the total precipitation (P) instead of the net rainfall (P1). +- Fixed bug in <code>RunModel_GR2M()</code>. The function now returns the total precipitation (P) instead of the net rainfall (P1). #### Major user-visible changes -- <code>RunModel_GR2M</code> now returns more explicit precipitation outputs names. +- <code>RunModel_GR2M()</code> now returns more explicit precipitation outputs names. -- <code>CreateInputsCrit</code> now returns a warning message when the KGE (or KGE') is used with a log transformation on flows. +- <code>CreateInputsCrit()</code> now returns a warning message when the KGE (or KGE') is used with a log transformation on flows. - The article reference is corrected. @@ -102,7 +122,7 @@ ________________________________________________________________________________ #### New features -- <code>DataAltiExtrapolation_Valery()</code> and <code>CreateInputsModel()</code> now present a PrecipScale argument which allows rescaling precipitation when it is interpolated on the elevation layers when CemaNeige is used. +- <code>DataAltiExtrapolation_Valery()</code> and <code>CreateInputsModel()</code> now present a <code>PrecipScale</code> argument which allows rescaling precipitation when it is interpolated on the elevation layers when CemaNeige is used. #### Bug fixes diff --git a/R/PEdaily_Oudin.R b/R/PEdaily_Oudin.R index 108616858fd75f9a13dd708069a623639a1d506f..a896a0f79d1783078dc0bb66ee5670063ee7409a 100644 --- a/R/PEdaily_Oudin.R +++ b/R/PEdaily_Oudin.R @@ -1,35 +1,66 @@ -PEdaily_Oudin <- function(JD,Temp,LatRad){ - - PE_Oudin_D <- rep(NA,length(Temp)); - for(k in 1:length(Temp)){ - - FI <- LatRad ### latitude in rad - ### FI <- LatDeg/(180/pi) ### conversion from deg to rad - COSFI <- cos(FI) - AFI <- abs(LatRad/42.) - - TETA <- 0.4093*sin(JD[k]/58.1-1.405) - COSTETA <- cos(TETA) - COSGZ <- max(0.001,cos(FI-TETA)) - GZ <- acos(COSGZ) - COSGZ2 <- COSGZ*COSGZ - if(COSGZ2 >= 1){ SINGZ <- 0. } else { SINGZ <- sqrt(1.-COSGZ2) } - COSOM <- 1.-COSGZ/COSFI/COSTETA - if(COSOM < -1.){ COSOM <- -1. } - if(COSOM > 1.){ COSOM <- 1. } - COSOM2 <- COSOM*COSOM - if(COSOM2 >= 1.){ SINOM <- 0. } else { SINOM <- sqrt(1.-COSOM2) } - OM <- acos(COSOM) - COSPZ <- COSGZ+COSFI*COSTETA*(SINOM/OM-1.) - if(COSPZ < 0.001){ COSPZ <- 0.001 } - ETA <- 1.+cos(JD[k]/58.1)/30. - GE <- 446.*OM*COSPZ*ETA - - if(Temp[k] >= -5.0) { PE_Oudin_D[k] <- GE*(Temp[k]+5.)/100./28.5 } else { PE_Oudin_D[k] <- 0 } - +PEdaily_Oudin <- function(JD, Temp, LatRad, Lat, LatUnit = c("rad", "deg")) { + + if (!missing(LatRad)) { + warning("Deprecated \"LatRad\" argument. Please, use \"Lat\" instead.") + if (missing(Lat)) { + Lat <- LatRad } - - return(PE_Oudin_D); - + } + + PE_Oudin_D <- rep(NA, length(Temp)) + + if (LatUnit[1L] == "rad") { + FI <- Lat + } + if (LatUnit[1L] == "deg") { + FI <- Lat / (180 / pi) + } + + COSFI <- cos(FI) + AFI <- abs(FI / 42) + + for (k in seq_along(Temp)) { + + TETA <- 0.4093 * sin(JD[k] / 58.1 - 1.405) + COSTETA <- cos(TETA) + COSGZ <- max(0.001, cos(FI - TETA)) + GZ <- acos(COSGZ) + COSOM <- 1 - COSGZ / COSFI / COSTETA + + if (COSOM < -1) { + COSOM <- -1 + } + if (COSOM > 1) { + COSOM <- 1 + } + + COSOM2 <- COSOM * COSOM + + if (COSOM2 >= 1) { + SINOM <- 0 + } else { + SINOM <- sqrt(1 - COSOM2) + } + + OM <- acos(COSOM) + COSPZ <- COSGZ + COSFI * COSTETA * (SINOM/OM - 1) + + if (COSPZ < 0.001) { + COSPZ <- 0.001 + } + + ETA <- 1 + cos(JD[k] / 58.1) / 30 + GE <- 446 * OM * COSPZ * ETA + + if (Temp[k] >= -5.0) { + PE_Oudin_D[k] <- GE * (Temp[k] + 5) / 100 / 28.5 + } else { + PE_Oudin_D[k] <- 0 + } + + } + + return(PE_Oudin_D) + }