Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
HYCAR-Hydro
airGRteaching
Commits
db863746
Commit
db863746
authored
Jan 31, 2018
by
unknown
Browse files
v0.1.11.14 update and homogenization of the unit of time abbreviation in .TypeModelGR and ShinyGR
parent
32f962c2
Changes
3
Hide whitespace changes
Inline
Side-by-side
DESCRIPTION
View file @
db863746
Package: airGRteaching
Type: Package
Title: Tools to Simplify the Use of the airGR Hydrological Package for Education (Including a Shiny Interface)
Version: 0.1.11.1
3
Version: 0.1.11.1
4
Date: 2018-01-31
Authors@R: c(person("Olivier", "Delaigue", role = c("aut", "cre"), email = "airGR@irstea.fr"), person("Laurent", "Coron", role = c("aut")), person("Pierre", "Brigode", role = c("aut")), person("Guillaume", "Thirel", role = c("ctb")))
Depends: airGR (>= 1.0.9.43)
...
...
R/Utils.R
View file @
db863746
...
...
@@ -41,8 +41,10 @@ if (getRversion() >= "2.15.1") {
StrName
<-
"(.*)(GR)(\\d{1})(\\D{1})"
NameModel
<-
gsub
(
StrName
,
"\\2\\3\\4"
,
x
)
TimeUnitFR
<-
gsub
(
StrName
,
"\\4"
,
x
)
TimeUnit
<-
switch
(
TimeUnitFR
,
H
=
"hour"
,
J
=
"day"
,
M
=
"month"
,
A
=
"year"
)
TimeLag
<-
switch
(
TimeUnit
,
"hour"
=
3600
,
"day"
=
3600
*
24
,
"month"
=
3600
*
24
*
31
,
"year"
=
366
)
# TimeUnit <- switch(TimeUnitFR, H = "hour", J = "day", M = "month", A = "year")
# TimeLag <- switch(TimeUnit, "hour" = 3600, "day" = 3600*24, "month" = 3600*24*31, "year" = 366)
TimeUnit
<-
switch
(
TimeUnitFR
,
H
=
"h"
,
J
=
"d"
,
M
=
"month"
,
A
=
"y"
)
TimeLag
<-
switch
(
TimeUnit
,
"h"
=
3600
,
"d"
=
3600
*
24
,
"month"
=
3600
*
24
*
31
,
"y"
=
366
)
NbParam
<-
gsub
(
StrName
,
"\\3"
,
x
)
isCN
<-
grepl
(
"CemaNeige"
,
x
)
...
...
inst/ShinyGR/server.R
View file @
db863746
...
...
@@ -532,7 +532,7 @@ shinyServer(function(input, output, session) {
}
op
<-
getPlotPar
()
$
par
dg3
<-
dygraphs
::
dygraph
(
data.xts
,
group
=
"state_var"
,
ylab
=
"flow [mm/
d
]"
,
main
=
" "
)
dg3
<-
dygraphs
::
dygraph
(
data.xts
,
group
=
"state_var"
,
ylab
=
paste0
(
"flow [mm/
"
,
getPrep
()
$
TMGR
$
TimeUnit
,
"
]"
)
,
main
=
" "
)
dg3
<-
dygraphs
::
dyOptions
(
dg3
,
fillAlpha
=
1.0
,
axisLineColor
=
op
$
fg
,
axisLabelColor
=
op
$
fg
,
titleHeight
=
10
,
retainDateWindow
=
FALSE
)
...
...
@@ -558,7 +558,7 @@ shinyServer(function(input, output, session) {
# data <- getData()$Tab[, c("DatesR", "precip.")]
data.xts
<-
xts
::
xts
(
data
[,
-1L
,
drop
=
FALSE
],
order.by
=
data
$
DatesR
)
dg4
<-
dygraphs
::
dygraph
(
data.xts
,
group
=
"mod_diag"
,
ylab
=
"precip. [mm/
d
]"
)
dg4
<-
dygraphs
::
dygraph
(
data.xts
,
group
=
"mod_diag"
,
ylab
=
paste0
(
"precip. [mm/
"
,
getPrep
()
$
TMGR
$
TimeUnit
,
"
]"
)
)
dg4
<-
dygraphs
::
dyOptions
(
dg4
,
colors
=
"#428BCA"
,
drawXAxis
=
FALSE
,
retainDateWindow
=
FALSE
)
dg4
<-
dygraphs
::
dyBarSeries
(
dg4
,
name
=
"precip."
)
dg4
<-
dygraphs
::
dyAxis
(
dg4
,
name
=
"y"
,
valueRange
=
c
(
max
(
data.xts
[,
"precip."
],
na.rm
=
TRUE
),
-1e-3
))
...
...
@@ -579,7 +579,7 @@ shinyServer(function(input, output, session) {
data.xts
<-
xts
::
xts
(
data
[,
-1L
,
drop
=
FALSE
],
order.by
=
data
$
DatesR
)
op
<-
getPlotPar
()
$
par
dg5
<-
dygraphs
::
dygraph
(
data.xts
,
group
=
"mod_diag"
,
ylab
=
"PET [mm/
d
]"
,
main
=
" "
)
dg5
<-
dygraphs
::
dygraph
(
data.xts
,
group
=
"mod_diag"
,
ylab
=
paste0
(
"PET [mm/
"
,
getPrep
()
$
TMGR
$
TimeUnit
,
"
]"
)
,
main
=
" "
)
dg5
<-
dygraphs
::
dyOptions
(
dg5
,
colors
=
"#A4C400"
,
drawPoints
=
TRUE
,
strokeWidth
=
0
,
pointSize
=
2
,
drawXAxis
=
FALSE
,
axisLineColor
=
op
$
fg
,
axisLabelColor
=
op
$
fg
,
...
...
@@ -617,7 +617,7 @@ shinyServer(function(input, output, session) {
data.xts
<-
xts
::
xts
(
data
[,
-1L
,
drop
=
FALSE
],
order.by
=
data
$
DatesR
)
op
<-
getPlotPar
()
$
par
dg6
<-
dygraphs
::
dygraph
(
data.xts
,
group
=
"mod_diag"
,
ylab
=
"flow [mm/
d
]"
,
main
=
" "
)
dg6
<-
dygraphs
::
dygraph
(
data.xts
,
group
=
"mod_diag"
,
ylab
=
paste0
(
"flow [mm/
"
,
getPrep
()
$
TMGR
$
TimeUnit
,
"
]"
)
,
main
=
" "
)
dg6
<-
dygraphs
::
dyOptions
(
dg6
,
colors
=
c
(
op
$
fg
,
"orangered"
,
"grey"
),
drawPoints
=
TRUE
,
axisLineColor
=
op
$
fg
,
axisLabelColor
=
op
$
fg
,
titleHeight
=
10
,
retainDateWindow
=
FALSE
)
...
...
@@ -724,9 +724,9 @@ shinyServer(function(input, output, session) {
TempMeanSim_CemaNeige
=
TempMean
,
Qobs
=
SIM
$
OptionsCrit
$
Qobs
,
Qsim
=
SIM
$
OutputsModel
$
Qsim
)
colnames
(
TabSim
)
<-
sprintf
(
"%s [%s]"
,
colnames
(
TabSim
),
c
(
"-"
,
rep
(
"mm"
,
3
),
"-"
,
"°C"
,
rep
(
"mm"
,
2
)))
colnames
(
TabSim
)
<-
sprintf
(
"%s [%s]"
,
colnames
(
TabSim
),
c
(
"-"
,
rep
(
"mm"
,
3
),
"-"
,
"°C"
,
rep
(
"mm"
,
2
)))
colnames
(
TabSim
)
<-
ifelse
(
grepl
(
"mm"
,
colnames
(
TabSim
)),
gsub
(
"mm"
,
paste0
(
"mm/"
,
.TypeModelGR
(
PREP
)
$
TimeUnit
),
colnames
(
TabSim
)),
gsub
(
"mm"
,
paste0
(
"mm/"
,
.TypeModelGR
(
PREP
)
$
TimeUnit
),
colnames
(
TabSim
)),
colnames
(
TabSim
))
write.table
(
TabSim
,
file
=
file
,
row.names
=
FALSE
,
sep
=
";"
)
}
...
...
@@ -752,6 +752,7 @@ shinyServer(function(input, output, session) {
ParamUnits
<-
c
(
ParamUnits
,
""
,
"mm/°C/%s"
)
}
ParamTitle
<-
paste
(
ParamTitle
,
paste
(
getSim
()
$
PARAM
,
sprintf
(
ParamUnits
,
getPrep
()
$
TMGR
$
TimeUnit
)),
sep
=
" = "
,
collapse
=
", "
)
ParamTitle
<-
gsub
(
" ,"
,
","
,
ParamTitle
)
PngTitle
<-
sprintf
(
"%s - %s/%s\n%s\n%s"
,
input
$
Dataset
,
input
$
HydroModel
,
ifelse
(
input
$
SnowModel
==
"CemaNeige"
,
"CemaNeige"
,
"No snow model"
),
paste0
(
input
$
Period
,
collapse
=
" - "
),
...
...
@@ -819,7 +820,7 @@ shinyServer(function(input, output, session) {
pch
=
22
)
}
par
(
mar
=
c
(
0.0
,
4.0
,
0.6
,
2.0
),
xaxt
=
"s"
)
plot
(
data
$
DatesR
,
data
$
Qobs
,
type
=
"n"
,
xlab
=
""
,
ylab
=
"flow [mm/
d
]"
)
plot
(
data
$
DatesR
,
data
$
Qobs
,
type
=
"n"
,
xlab
=
""
,
ylab
=
paste0
(
"flow [mm/
"
,
getPrep
()
$
TMGR
$
TimeUnit
,
"
]"
)
)
if
(
input
$
HydroModel
!=
"GR6J"
)
{
polygon
(
c
(
data
$
Dates
,
rev
(
range
(
data
$
Dates
))),
c
(
data
$
Qr
+
data
$
Qd
,
rep
(
0
,
2
)),
col
=
"#FFD700"
,
border
=
NA
)
polygon
(
c
(
data
$
Dates
,
rev
(
range
(
data
$
Dates
))),
c
(
data
$
Qr
,
rep
(
0
,
2
)),
col
=
"#EE6300"
,
border
=
NA
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment