Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
swatdoctr
Manage
Activity
Members
Labels
Plan
Issues
5
Issue boards
Milestones
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christoph Schürz
swatdoctr
Commits
238faaab
Commit
238faaab
authored
2 years ago
by
Christoph Schürz
Browse files
Options
Downloads
Patches
Plain Diff
Implement print mgt and plot hu functions
parent
03535f37
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
DESCRIPTION
+1
-1
1 addition, 1 deletion
DESCRIPTION
R/print_mgt.R
+64
-0
64 additions, 0 deletions
R/print_mgt.R
man/plot_phuplant_harvest.Rd
+20
-0
20 additions, 0 deletions
man/plot_phuplant_harvest.Rd
man/print_triggered_mgt.Rd
+28
-0
28 additions, 0 deletions
man/print_triggered_mgt.Rd
with
113 additions
and
1 deletion
DESCRIPTION
+
1
−
1
View file @
238faaab
Package: SWATdoctR
Type: Package
Title: Finding the right diagnoses and treatments for SWAT+ models
Version: 0.1.0.900
2
Version: 0.1.0.900
3
Author: c(person("Svajunas", "Plunge",
email = "svajunas_plunge@sggw.edu.pl",
role = c("aut")),
...
...
This diff is collapsed.
Click to expand it.
R/print_mgt.R
0 → 100644
+
64
−
0
View file @
238faaab
#' Print the triggered management operations from the mgt outputs for a certain HRU
#'
#' print_triggered_mgt extracts the triggered management operation which are written
#' into mgt_out.txt and reformats them to resemble the scheduled operations in
#' managment.sch to ease a comparison between them.
#'
#' @param sim_verify Simulation output of the function \code{run_swat_verification()}.
#' To print the management at least the output option \code{outputs = 'mgt'} must
#' be set in \code{run_swat_verification()}
#' @param hru_id id of the HRU for which the triggered management operations should
#' be printed
#' @param start_year Integer value to define the first year of printing.
#' @param end_year Integer value to define the last year of printing.
#'
#' @return Prints a tibble with triggered operations to the R console.
#'
#' @importFrom dplyr filter mutate rename select %>%
#' @export
#'
print_triggered_mgt
<-
function
(
sim_verify
,
hru_id
,
start_year
=
1900
,
end_year
=
2100
)
{
cat
(
'Triggered managament for\n'
,
' hru: '
,
hru_id
,
'\n'
,
' management:'
,
sim_verify
$
lum_mgt
$
mgt
[
sim_verify
$
lum_mgt
$
id
==
hru_id
],
'\n\n'
)
sim_verify
$
mgt_out
%>%
filter
(
hru
==
hru_id
)
%>%
filter
(
year
%in%
start_year
:
end_year
)
%>%
rename
(
op_data1
=
op_typ
,
op_data3
=
var1
)
%>%
mutate
(
op_data3
=
ifelse
(
operation
!=
'FERT'
,
0
,
op_data3
))
%>%
# mutate()
# mutate(date = ymd(paste(year, mon, day, sep = '-'))) %>%
select
(
.
,
year
,
mon
,
day
,
phuplant
,
operation
,
op_data1
,
op_data3
)
%>%
print
(
.
,
n
=
Inf
)
}
#' Boxplot of heat unit fractions for crops at harvest-kill operation
#'
#' plot_phuplant_harvest plots boxplots of the collected heat unit fractions
#' at harvest-kill of a crop separated for all identified crops.
#'
#' @param sim_verify Simulation output of the function \code{run_swat_verification()}.
#' To plot the heat units at least the output option \code{outputs = 'mgt'} must
#' be set in \code{run_swat_verification()}
#'
#' @return ggplot boxplot with crop heat unit fractions at harvest-kill.
#'
#' @importFrom dplyr filter group_by mutate rename select ungroup %>%
#' @importFrom ggplot2 aes ggplot geom_boxplot geom_hline labs theme_bw
#' @export
#'
plot_phuplant_harvest
<-
function
(
sim_verify
)
{
hu_harv
<-
sim_verify
$
mgt_out
%>%
filter
(
operation
%in%
c
(
'HARVEST'
,
'KILL'
))
%>%
group_by
(
hru
,
year
,
mon
,
day
)
%>%
mutate
(
n
=
n
())
%>%
ungroup
()
%>%
filter
(
n
==
2
,
operation
==
'HARVEST'
)
%>%
select
(
op_typ
,
phuplant
)
ggplot
(
data
=
hu_harv
)
+
geom_boxplot
(
aes
(
x
=
op_typ
,
y
=
phuplant
))
+
geom_hline
(
yintercept
=
1
,
lty
=
2
)
+
labs
(
x
=
'Crops'
,
y
=
'Crop HUs at harvest'
)
+
theme_bw
()
}
This diff is collapsed.
Click to expand it.
man/plot_phuplant_harvest.Rd
0 → 100644
+
20
−
0
View file @
238faaab
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/print_mgt.R
\name{plot_phuplant_harvest}
\alias{plot_phuplant_harvest}
\title{Boxplot of heat unit fractions for crops at harvest-kill operation}
\usage{
plot_phuplant_harvest(sim_verify)
}
\arguments{
\item{sim_verify}{Simulation output of the function \code{run_swat_verification()}.
To plot the heat units at least the output option \code{outputs = 'mgt'} must
be set in \code{run_swat_verification()}}
}
\value{
ggplot boxplot with crop heat unit fractions at harvest-kill.
}
\description{
plot_phuplant_harvest plots boxplots of the collected heat unit fractions
at harvest-kill of a crop separated for all identified crops.
}
This diff is collapsed.
Click to expand it.
man/print_triggered_mgt.Rd
0 → 100644
+
28
−
0
View file @
238faaab
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/print_mgt.R
\name{print_triggered_mgt}
\alias{print_triggered_mgt}
\title{Print the triggered management operations from the mgt outputs for a certain HRU}
\usage{
print_triggered_mgt(sim_verify, hru_id, start_year = 1900, end_year = 2100)
}
\arguments{
\item{sim_verify}{Simulation output of the function \code{run_swat_verification()}.
To print the management at least the output option \code{outputs = 'mgt'} must
be set in \code{run_swat_verification()}}
\item{hru_id}{id of the HRU for which the triggered management operations should
be printed}
\item{start_year}{Integer value to define the first year of printing.}
\item{end_year}{Integer value to define the last year of printing.}
}
\value{
Prints a tibble with triggered operations to the R console.
}
\description{
print_triggered_mgt extracts the triggered management operation which are written
into mgt_out.txt and reformats them to resemble the scheduled operations in
managment.sch to ease a comparison between them.
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment