Skip to content

Commit

Permalink
[k] remove force through origin in control 2 + yapf
Browse files Browse the repository at this point in the history
  • Loading branch information
mcwimm committed Sep 21, 2022
1 parent 065edd5 commit 91dd930
Show file tree
Hide file tree
Showing 2 changed files with 206 additions and 142 deletions.
5 changes: 2 additions & 3 deletions R_scripts/functions/fun_graphics.R
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,6 @@ plot.kEst2 <- function(data.complete, data.adj, k,
xRange = c(ui.input$k1Plot.x.min, ui.input$k1Plot.x.max)
fullrange = ui.input$k1Plot.fullrange
fixedScales = ui.input$k1Plot_scales
force = ui.input$k1Plot.forceOrigin
kMethod = ui.input$kMethod

if (min(data.complete$dTsym.dTas, na.rm = T) < 0){
Expand All @@ -545,8 +544,6 @@ plot.kEst2 <- function(data.complete, data.adj, k,
xmin = -0.1
}

fit = ifelse(force, "y ~ x + 0", "y ~ x")

d = data.complete %>%
mutate("K+dTsa" = (dTsa + k)) %>%
gather(., temp, value, dTsa, dTas, dTSym, `K+dTsa`)
Expand All @@ -568,6 +565,8 @@ plot.kEst2 <- function(data.complete, data.adj, k,
col = labels["T"][[1]])

# # Add regression line to control plot
# force = ui.input$k1Plot.forceOrigin
# fit = ifelse(force, "y ~ x + 0", "y ~ x")
# if (kMethod == "regression"){
# newAdj = data.adj %>%
# mutate("K+dTsa" = (dTsa + k))%>%
Expand Down
343 changes: 204 additions & 139 deletions R_scripts/functions/fun_ui_k_value.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,149 +2,214 @@
### K-ESTIMATION ###
####################

kDescriptionOutput <- function(){
return(list(
fluidRow(
box(title = "K-value estimation",
collapsible = T,
status = "info",
includeMarkdown("./man/des_k_value.md")),
box(title = "K-diagrams",
collapsible = T,
status = "info",
includeMarkdown("./man/des_k_diagrams.md"),
img(src='Nadezhdina_2018_fig1.png', width = "80%"),
p(HTML('&nbsp;'),
a("Nadezhdina (2018)", href="https://iforest.sisef.org/abstract/?id=ifor2381-011", target="_blank")),
includeMarkdown("./man/des_k_diagrams2.md")
)
kDescriptionOutput <- function() {
return(list(fluidRow(
box(
title = "K-value estimation",
collapsible = T,
status = "info",
includeMarkdown("./man/des_k_value.md")
),
box(
title = "K-diagrams",
collapsible = T,
status = "info",
includeMarkdown("./man/des_k_diagrams.md"),
img(src = 'Nadezhdina_2018_fig1.png', width = "80%"),
p(
HTML('&nbsp;'),
a("Nadezhdina (2018)", href = "https://iforest.sisef.org/abstract/?id=ifor2381-011", target =
"_blank")
),
includeMarkdown("./man/des_k_diagrams2.md")
)
))
)))
}

kValueOutput <- function(){
return(list(
fluidRow(
box(title = "K-value estimation",
collapsible = T, #width = 8,
status = "warning",

uiOutput("kPositionSelect"),

tags$hr(),

selectInput("kMethod", "Method",
choices = c("regression" = "regression",
"no-flow" = "no.flow",
"manual" = "manual",
"csv" = "csv")),
conditionalPanel(
condition = "input.kMethod != `manual`",
verbatimTextOutput("kCurrent")
),
conditionalPanel(
condition = "input.kMethod == `manual`",
numericInput("kManual", "Enter k manually", value = 1.11)
),

p(strong("Regression: filter options")),

checkboxInput("kRegUseBoth", HTML("Use <i>dTas</i> and <i>dTs-a</i> for regression (instead of solely <i>dTas</i>)"), value = F),

checkboxInput("dTimeFilter", "Custom no-flow time (regression)", F),
conditionalPanel(
condition = "input.dTimeFilter == true",
fluidRow(
column(6, numericInput("kRegressionTime.start",
label = "Start (0-24 h)",
value = 22)),
column(6, numericInput("kRegressionTime.end",
label = "End (0-24 h)",
value = 6))
)
),
checkboxInput("kRegXFilter", HTML("Custom max. <i>dTsym dTas <sup>-1</sup></i> (regression)"), F),
conditionalPanel(
condition = "input.kRegXFilter == true",
fluidRow(
column(6, numericInput("kRegXFilter.max",
label = HTML("max. <i>dTsym dTas <sup>-1</sup></i>"),
value = 1.5))
)
),

actButton("setK", "Set k-value", "setValue"),

tabsetPanel(

tabPanel("Selected",
output.table("kSelected"),
actButton("save.kValues", "Save csv", "saveCsv")),
tabPanel("Regression",
output.table("kRegression"),
actButton("setKfromRegression", "Use k-values", "setValue")),
tabPanel("No-flow",
output.table("kZeroFlow"),
actButton("setKfromZeroFlow", "Use k-values", "setValue")),
tabPanel("Read csv", br(),
# Input: Select a file ----
fileInput("file2", "Choose CSV File",
multiple = F,
accept = c("text/csv",
"text/comma-separated-values,text/plain",
".csv")),
checkboxInput("moreOptions", "More upload options", F),
conditionalPanel(
condition = "input.moreOptions == 1",

fluidRow(
column(6, numericInput("skip2", "Skip:", min = 0,
max = 100, 0)),
column(6, checkboxInput("header2", "Header", TRUE))
),
radioButtons("sep2", "Separator", inline = T,
choices = c(Comma = ",",
Semicolon = ";",
Tab = "\t"),
selected = ",")),
output.table("uploadedKvalues"),
actButton("setKfromCsv", "Use k-values", "setValue")
)
)
kValueOutput <- function() {
return(list(fluidRow(
box(
title = "K-value estimation",
collapsible = T,
status = "warning",
box.k.estimation()
),
box(
title = "Control plots",
collapsible = T,
status = "success",
radioButtons("k1Plot_scales", "Scales",
c(
"free" = F, "fixed" = T
), inline = T),
box.k.figures()
)
)))
}

box.k.estimation = function() {
return(
list(
uiOutput("kPositionSelect"),

tags$hr(),

selectInput(
"kMethod",
"Method",
choices = c(
"regression" = "regression",
"no-flow" = "no.flow",
"manual" = "manual",
"csv" = "csv"
)
),
conditionalPanel(condition = "input.kMethod != `manual`",
verbatimTextOutput("kCurrent")),
conditionalPanel(
condition = "input.kMethod == `manual`",
numericInput("kManual", "Enter k manually", value = 1.11)
),
box(title = "Control plots",
collapsible = T,
status = "success",
radioButtons("k1Plot_scales", "Scales",
c("free" = F, "fixed" = T), inline=T),


uiOutput("xRangeSlider"),

tabsetPanel(
tabPanel("K-diagram", br(),
conditionalPanel(
condition = "input.kMethod == `regression`",
checkboxInput("k1Plot.fullrange", "Fullrange regression",
value = F)
),
output.figure("kvaluePlot1")),
tabPanel("Control-diagram 1", br(),
conditionalPanel(
condition = "input.kMethod == `regression`",
checkboxInput("k1Plot.forceOrigin",
"Force regression through origin",
value = F)
),
output.figure("kvaluePlot2")),
tabPanel("Control-diagram 2", br(),
output.figure("kvaluePlot3")),
tabPanel("Diurnal flow", br(),
output.figure("kDiurnalPlot"))
),

actButton("save.kPlots", "Save figures", "saveFigure")

p(strong("Regression: filter options")),

checkboxInput(
"kRegUseBoth",
HTML(
"Use <i>dTas</i> and <i>dTs-a</i> for regression (instead of solely <i>dTas</i>)"
),
value = F
),

checkboxInput("dTimeFilter", "Custom no-flow time (regression)", F),
conditionalPanel(condition = "input.dTimeFilter == true",
fluidRow(
column(
6,
numericInput(
"kRegressionTime.start",
label = "Start (0-24 h)",
value = 22
)
),
column(
6,
numericInput("kRegressionTime.end",
label = "End (0-24 h)",
value = 6)
)
)),
checkboxInput(
"kRegXFilter",
HTML("Custom max. <i>dTsym dTas <sup>-1</sup></i> (regression)"),
F
),
conditionalPanel(condition = "input.kRegXFilter == true",
fluidRow(column(
6, numericInput(
"kRegXFilter.max",
label = HTML("max. <i>dTsym dTas <sup>-1</sup></i>"),
value = 1.5
)
))),

actButton("setK", "Set k-value", "setValue"),

tabsetPanel(
tabPanel(
"Selected",
output.table("kSelected"),
actButton("save.kValues", "Save csv", "saveCsv")
),
tabPanel(
"Regression",
output.table("kRegression"),
actButton("setKfromRegression", "Use k-values", "setValue")
),
tabPanel(
"No-flow",
output.table("kZeroFlow"),
actButton("setKfromZeroFlow", "Use k-values", "setValue")
),
tabPanel(
"Read csv",
br(),
# Input: Select a file ----
fileInput(
"file2",
"Choose CSV File",
multiple = F,
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv"
)
),
checkboxInput("moreOptions", "More upload options", F),
conditionalPanel(
condition = "input.moreOptions == 1",

fluidRow(column(
6, numericInput("skip2", "Skip:", min = 0,
max = 100, 0)
),
column(
6, checkboxInput("header2", "Header", TRUE)
)),
radioButtons(
"sep2",
"Separator",
inline = T,
choices = c(
Comma = ",",
Semicolon = ";",
Tab = "\t"
),
selected = ","
)
),
output.table("uploadedKvalues"),
actButton("setKfromCsv", "Use k-values", "setValue")
)
)
)))
)
)
}

box.k.figures = function() {
return(list(
uiOutput("xRangeSlider"),

tabsetPanel(
tabPanel(
"K-diagram",
br(),
conditionalPanel(
condition = "input.kMethod == `regression`",
checkboxInput("k1Plot.fullrange", "Fullrange regression",
value = F)
),
output.figure("kvaluePlot1")
),
tabPanel(
"Control-diagram 1",
br(),
# conditionalPanel(
# condition = "input.kMethod == `regression`",
# checkboxInput(
# "k1Plot.forceOrigin",
# "Force regression through origin",
# value = F
# )
# ),
output.figure("kvaluePlot2")
),
tabPanel("Control-diagram 2", br(),
output.figure("kvaluePlot3")),
tabPanel("Diurnal flow", br(),
output.figure("kDiurnalPlot"))
),

actButton("save.kPlots", "Save figures", "saveFigure")
))
}

0 comments on commit 91dd930

Please sign in to comment.