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
085be7fa
Commit
085be7fa
authored
1 year ago
by
Svajunas Plunge
Browse files
Options
Downloads
Plain Diff
Merge branch 'main' of
https://git.ufz.de/schuerz/swatdoctr
parents
c2481184
7cc4a1a5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
DESCRIPTION
+1
-1
1 addition, 1 deletion
DESCRIPTION
R/plot_mgt_harv.R
+2
-3
2 additions, 3 deletions
R/plot_mgt_harv.R
R/update_landuse_labels.R
+16
-8
16 additions, 8 deletions
R/update_landuse_labels.R
with
19 additions
and
12 deletions
DESCRIPTION
+
1
−
1
View file @
085be7fa
Package: SWATdoctR
Type: Package
Title: Finding the right diagnoses and treatments for SWAT+ models
Version: 0.1.1
7
Version: 0.1.1
8
Author: c(person("Christoph", "Schürz",
email = "christoph.schuerz@ufz.de",
role = c("aut", "cre")),
...
...
This diff is collapsed.
Click to expand it.
R/plot_mgt_harv.R
+
2
−
3
View file @
085be7fa
...
...
@@ -349,12 +349,11 @@ prepare_stress <- function(mgt_out, years) {
stress
<-
bind_rows
(
stress_mono
,
stress_rota
)
%>%
set_names
(
c
(
'crop'
,
'water'
,
'aeration'
,
'temperature'
,
'
nitrogen'
,
'phosphorus
'
))
%>%
'temperature'
,
'
phosphorus'
,
'nitrogen
'
))
%>%
pivot_longer
(
.
,
cols
=
-
crop
,
names_to
=
'stress'
,
values_to
=
'var'
)
%>%
mutate
(
.
,
stress
=
factor
(
stress
,
levels
=
c
(
'water'
,
'aeration'
,
'temperature'
,
'nitrogen'
,
'phosphorus'
)))
'phosphorus'
,
'nitrogen'
)))
return
(
stress
)
}
...
...
This diff is collapsed.
Click to expand it.
R/update_landuse_labels.R
+
16
−
8
View file @
085be7fa
...
...
@@ -10,11 +10,11 @@
#' @return Rewrites the input files hru-data.hru, landuse.lum, management.sch,
#' and plant.ini with shorter labels.
#'
#' @importFrom dplyr distinct left_join group_by group_split mutate select %>%
#' @importFrom dplyr
bind_rows
distinct left_join group_by group_split mutate select %>%
#' @importFrom purrr list_c list_rbind map map_lgl map2 map2_df
#' @importFrom readr read_lines write_lines
#' @importFrom stringr str_detect str_remove str_remove_all str_replace
#' @importFrom tibble tibble
#' @importFrom tibble tibble
add_row
#'
#' @export
#'
...
...
@@ -60,12 +60,18 @@ update_landuse_labels <- function(project_path) {
mgt_lbl
<-
lu_lbl
%>%
mutate
(
schedule
=
str_replace
(
lu_mgt
,
'lum'
,
'mgt'
),
schedule_upd
=
str_replace
(
lu_mgt_upd
,
'lum'
,
'mgt'
))
%>%
select
(
schedule
,
schedule_upd
)
select
(
schedule
,
schedule_upd
)
%>%
add_row
(
schedule
=
'null'
,
schedule_upd
=
'null'
)
pcm_lbl
<-
lu_lbl
%>%
mutate
(
plnt_com
=
str_replace
(
lu_mgt
,
'lum'
,
'comm'
),
plnt_com_upd
=
str_replace
(
lu_mgt_upd
,
'lum'
,
'com'
))
%>%
select
(
plnt_com
,
plnt_com_upd
)
select
(
plnt_com
,
plnt_com_upd
)
%>%
add_row
(
plnt_com
=
'null'
,
plnt_com_upd
=
'null'
)
# Added to account for both variants 'comm' and 'com'
pcm_lbl
<-
mutate
(
pcm_lbl
,
plnt_com
=
str_replace
(
plnt_com
,
'comm'
,
'com'
))
%>%
bind_rows
(
pcm_lbl
)
hru_data
<-
hru_data
%>%
left_join
(
.
,
lu_lbl
,
by
=
'lu_mgt'
)
%>%
...
...
@@ -77,14 +83,16 @@ update_landuse_labels <- function(project_path) {
c
(
'%8d'
,
'%-16s'
,
rep
(
'%16s'
,
8
)),
paste0
(
project_path
,
'/hru-data.hru'
))
landuse_lum
<-
landuse_lum
%>%
left_join
(
.
,
lu_lbl
,
by
=
c
(
'name'
=
'lu_mgt'
))
%>%
mutate
(
name
=
lu_mgt_upd
)
%>%
select
(
-
lu_mgt_upd
)
%>%
mutate
(
plnt_com
=
str_replace
(
name
,
'lum'
,
'com'
),
mgt
=
str_replace
(
name
,
'lum'
,
'mgt'
))
left_join
(
.
,
pcm_lbl
,
by
=
'plnt_com'
)
%>%
mutate
(
plnt_com
=
plnt_com_upd
)
%>%
select
(
-
plnt_com_upd
)
%>%
left_join
(
.
,
mgt_lbl
,
by
=
c
(
'mgt'
=
'schedule'
))
%>%
mutate
(
mgt
=
schedule_upd
)
%>%
select
(
-
schedule_upd
)
write_tbl_file
(
landuse_lum
,
landuse_lum_head
,
...
...
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