Commit 74da7caa authored by Delaigue Olivier's avatar Delaigue Olivier
Browse files

v1.0.11.0 new argument in LatUnit PEdaily_Oudin to chose the unit of the...

v1.0.11.0 new argument in LatUnit PEdaily_Oudin to chose the unit of the latitude + LatRad --> Lat + code cleaned
Showing with 89 additions and 38 deletions
+89 -38
Package: airGR Package: airGR
Type: Package Type: Package
Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling Title: Suite of GR Hydrological Models for Precipitation-Runoff Modelling
Version: 1.0.10.11 Version: 1.0.11.0
Date: 2018-06-29 Date: 2018-07-18
Authors@R: c( Authors@R: c(
person("Laurent", "Coron", role = c("aut", "trl")), person("Laurent", "Coron", role = c("aut", "trl")),
person("Charles", "Perrin", role = c("aut", "ths")), person("Charles", "Perrin", role = c("aut", "ths")),
......
...@@ -14,19 +14,39 @@ output: ...@@ -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) ### 1.0.10.11 Release Notes (2018-06-29)
#### Bug fixes #### 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 #### 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. - The article reference is corrected.
...@@ -102,7 +122,7 @@ ________________________________________________________________________________ ...@@ -102,7 +122,7 @@ ________________________________________________________________________________
#### New features #### 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 #### Bug fixes
......
PEdaily_Oudin <- function(JD,Temp,LatRad){ PEdaily_Oudin <- function(JD, Temp, LatRad, Lat, LatUnit = c("rad", "deg")) {
PE_Oudin_D <- rep(NA,length(Temp)); if (!missing(LatRad)) {
for(k in 1:length(Temp)){ warning("Deprecated \"LatRad\" argument. Please, use \"Lat\" instead.")
if (missing(Lat)) {
FI <- LatRad ### latitude in rad Lat <- LatRad
### 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 }
} }
}
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)
} }
Supports Markdown
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