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
865d1cc6
Commit
865d1cc6
authored
2 years ago
by
Christoph Schürz
Browse files
Options
Downloads
Patches
Plain Diff
Add function filter_hru_at_harvkill
parent
28205e35
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
NAMESPACE
+1
-0
1 addition, 0 deletions
NAMESPACE
R/plot_mgt_harv.R
+40
-0
40 additions, 0 deletions
R/plot_mgt_harv.R
man/filter_hru_at_harvkill.Rd
+33
-0
33 additions, 0 deletions
man/filter_hru_at_harvkill.Rd
with
75 additions
and
1 deletion
DESCRIPTION
+
1
−
1
View file @
865d1cc6
Package: SWATdoctR
Type: Package
Title: Finding the right diagnoses and treatments for SWAT+ models
Version: 0.1.1
3
Version: 0.1.1
4
Author: c(person("Svajunas", "Plunge",
email = "svajunas_plunge@sggw.edu.pl",
role = c("aut")),
...
...
This diff is collapsed.
Click to expand it.
NAMESPACE
+
1
−
0
View file @
865d1cc6
...
...
@@ -2,6 +2,7 @@
export(add_kill_op)
export(check_hru_waterbalance)
export(filter_hru_at_harvkill)
export(get_hru_id_by_attribute)
export(plot_basin_var)
export(plot_climate_annual)
...
...
This diff is collapsed.
Click to expand it.
R/plot_mgt_harv.R
+
40
−
0
View file @
865d1cc6
...
...
@@ -147,3 +147,43 @@ var_at_harv <- function(mgt_out, years){
}
return
(
tbl_harv
)
}
#' Filter HRUs by their variable values at harvest/kill
#'
#' The function can be complementary to \code{plot_variable_at_harvkill()} plots.
#' If any issues are identified in the boxplots, the results can be filtered for
#' further analysis with \code{filter_hru_at_harvkill()}.
#'
#' @param sim_verify Simulation output of the function \code{run_swat_verification()}
#' as a single object or as a list of objects (representing \code{run_swat_verification()}
#' function runs with different settings).
#' To plot the heat units at least the output option \code{outputs = 'mgt'}
#' must be set in \code{run_swat_verification()}.
#' @param ... Boolean operations to be applied in the filter operation of the
#' management simulation outputs. Possible variables are \code{crop, phu, plant_bioms,
#' yield, water_stress, aero_stress, temp_stress, n_stress} and \code{p_stress}.
#'
#' @importFrom dplyr filter mutate select %>%
#' @importFrom lubridate ymd
#' @importFrom purrr set_names
#'
#' @export
#' @examples
#' \dontrun{
#' # Filter all HRUs with unusually high PHU values at harvest kill
#' filter_hru_at_harvkill(sim_verify, phu > 5)
#'
#' # Filter all HRUs with crop 'wbar' or 'wira' planted but no yield
#' filter_hru_at_harvkill(sim_verify, crop %in% c('wbar', 'wira'), yield == 0)
#' }
filter_hru_at_harvkill
<-
function
(
sim_verify
,
...
)
{
sim_verify
$
mgt_out
%>%
mutate
(
date
=
ymd
(
paste
(
year
,
mon
,
day
,
sep
=
'-'
)))
%>%
filter
(
operation
==
'HARVEST'
)
%>%
select
(
hru
,
date
,
op_typ
,
phuplant
,
plant_bioms
,
op_var
,
var4
,
var5
,
var3
,
var1
,
var2
)
%>%
set_names
(
c
(
'hru'
,
'date'
,
'crop'
,
'phu'
,
'plant_bioms'
,
'yield'
,
'water_stress'
,
'aero_stress'
,
'temp_stress'
,
'n_stress'
,
'p_stress'
))
%>%
filter
(
.
,
...
)
}
This diff is collapsed.
Click to expand it.
man/filter_hru_at_harvkill.Rd
0 → 100644
+
33
−
0
View file @
865d1cc6
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot_mgt_harv.R
\name{filter_hru_at_harvkill}
\alias{filter_hru_at_harvkill}
\title{Filter HRUs by their variable values at harvest/kill}
\usage{
filter_hru_at_harvkill(sim_verify, ...)
}
\arguments{
\item{sim_verify}{Simulation output of the function \code{run_swat_verification()}
as a single object or as a list of objects (representing \code{run_swat_verification()}
function runs with different settings).
To plot the heat units at least the output option \code{outputs = 'mgt'}
must be set in \code{run_swat_verification()}.}
\item{...}{Boolean operations to be applied in the filter operation of the
management simulation outputs. Possible variables are \code{crop, phu, plant_bioms,
yield, water_stress, aero_stress, temp_stress, n_stress} and \code{p_stress}.}
}
\description{
The function can be complementary to \code{plot_variable_at_harvkill()} plots.
If any issues are identified in the boxplots, the results can be filtered for
further analysis with \code{filter_hru_at_harvkill()}.
}
\examples{
\dontrun{
# Filter all HRUs with unusually high PHU values at harvest kill
filter_hru_at_harvkill(sim_verify, phu > 5)
# Filter all HRUs with crop 'wbar' or 'wira' planted but no yield
filter_hru_at_harvkill(sim_verify, crop \%in\% c('wbar', 'wira'), yield == 0)
}
}
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