Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
Impact démographique des collisions aviaires avec les éoliennes
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
CEFE
Interactions Humains-Animaux
Impact démographique des collisions aviaires avec les éoliennes
Commits
4cc28784
Commit
4cc28784
authored
3 years ago
by
thierrychambert
Browse files
Options
Downloads
Patches
Plain Diff
Added sel_sc argument to plot_traj function
parent
cc09fd25
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
R/plot_traj.R
+19
-7
19 additions, 7 deletions
R/plot_traj.R
man/plot_traj.Rd
+3
-0
3 additions, 0 deletions
man/plot_traj.Rd
run_analysis.R
+7
-0
7 additions, 0 deletions
run_analysis.R
with
29 additions
and
7 deletions
R/plot_traj.R
+
19
−
7
View file @
4cc28784
...
...
@@ -10,6 +10,7 @@
#' if age_class_use = "pairs", to determine which age classes are mature (thus contribute to the number of pairs).
#' @param onset_year a vector containing the years of each wind farm start being active
#' (thus, the year at whihc each fatality value starts kicking in)
#' @param sel_sc scenario to display on the plot. Either "all" or the ID number of a given scenario.
#' @param xlab a character string. Label for the x axis.
#' @param ylab a character string. Label for the y axis.
#' @param Legend a vector of character strings. The legend to show on the side of the plot.
...
...
@@ -25,9 +26,13 @@
#'
#'
#'
plot_traj
<-
function
(
N
,
age_class_use
=
"NotJuv0"
,
fecundities
=
NULL
,
onset_year
=
NULL
,
plot_traj
<-
function
(
N
,
age_class_use
=
"NotJuv0"
,
fecundities
=
NULL
,
onset_year
=
NULL
,
sel_sc
=
"all"
,
xlab
=
"Year"
,
ylab
=
"Population size"
,
Legend
=
NULL
,
ylim
=
NULL
,
...
){
# select subset of legends, if needed
if
(
sel_sc
!=
"all"
)
sel_sc
=
as.numeric
(
sel_sc
)
if
(
sel_sc
!=
"all"
)
Legend
=
Legend
[
c
(
1
,
sel_sc
+1
)]
# Get metrics and dimensions
TH
<-
dim
(
N
)[
2
]
nsc
<-
dim
(
N
)[
3
]
...
...
@@ -45,7 +50,7 @@ plot_traj <- function(N, age_class_use = "NotJuv0", fecundities = NULL, onset_ye
N
<-
N
[
mature
,,,]
/
2
}
}
dim
(
N
)
if
(
is.null
(
onset_year
))
onset_year
<-
1
years
<-
min
(
onset_year
)
+
(
1
:
TH
)
-
1
...
...
@@ -57,14 +62,20 @@ plot_traj <- function(N, age_class_use = "NotJuv0", fecundities = NULL, onset_ye
}
else
{
out
<-
colSums
(
N
)
}
dim
(
out
)
N_avg
<-
apply
(
out
,
c
(
1
,
2
),
median
)
N_lci
<-
apply
(
out
,
c
(
1
,
2
),
quantile
,
prob
=
pnorm
(
0.5
))
N_uci
<-
apply
(
out
,
c
(
1
,
2
),
quantile
,
prob
=
pnorm
(
-0.5
))
# Build dataframe
df
<-
as.data.frame
(
cbind
(
year
=
years
,
N_avg
=
N_avg
[,
1
],
N_lci
=
N_lci
[,
1
],
N_uci
=
N_uci
[,
1
],
scenario
=
1
))
for
(
j
in
2
:
nsc
)
df
<-
rbind
(
df
,
cbind
(
year
=
years
,
N_avg
=
N_avg
[,
j
],
N_lci
=
N_lci
[,
j
],
N_uci
=
N_uci
[,
j
],
scenario
=
j
))
if
(
sel_sc
==
"all"
){
df
<-
as.data.frame
(
cbind
(
year
=
years
,
N_avg
=
N_avg
[,
1
],
N_lci
=
N_lci
[,
1
],
N_uci
=
N_uci
[,
1
],
scenario
=
1
))
for
(
j
in
2
:
nsc
)
df
<-
rbind
(
df
,
cbind
(
year
=
years
,
N_avg
=
N_avg
[,
j
],
N_lci
=
N_lci
[,
j
],
N_uci
=
N_uci
[,
j
],
scenario
=
j
))
}
else
{
df
<-
as.data.frame
(
cbind
(
year
=
years
,
N_avg
=
N_avg
[,
1
],
N_lci
=
N_lci
[,
1
],
N_uci
=
N_uci
[,
1
],
scenario
=
1
))
df
<-
rbind
(
df
,
cbind
(
year
=
years
,
N_avg
=
N_avg
[,
sel_sc
+1
],
N_lci
=
N_lci
[,
sel_sc
+1
],
N_uci
=
N_uci
[,
sel_sc
+1
],
scenario
=
sel_sc
+1
))
}
## Define Graphic Parameters
size
=
1.5
...
...
@@ -79,9 +90,10 @@ plot_traj <- function(N, age_class_use = "NotJuv0", fecundities = NULL, onset_ye
# geom_ribbon(data = dplyr::filter(df, .data$scenario > 1), aes(ymin = .data$N_lci, ymax = .data$N_uci, fill = factor(.data$scenario)), linetype = 0, alpha = 0.100)
# change color palette (we want sc0 in black)
if
(
sel_sc
==
"all"
)
ColoR
<-
custom_palette_c25
()[
1
:
nsc
]
else
ColoR
<-
custom_palette_c25
()[
c
(
1
,
sel_sc
+
1
)]
p
<-
p
+
scale_color_manual
(
breaks
=
1
:
nsc
,
values
=
custom_palette_c25
()[
1
:
nsc
],
scale_color_manual
(
values
=
ColoR
,
labels
=
Legend
,
aesthetics
=
c
(
"colour"
,
"fill"
))
...
...
This diff is collapsed.
Click to expand it.
man/plot_traj.Rd
+
3
−
0
View file @
4cc28784
...
...
@@ -9,6 +9,7 @@ plot_traj(
age_class_use = "NotJuv0",
fecundities = NULL,
onset_year = NULL,
sel_sc = "all",
xlab = "Year",
ylab = "Population size",
Legend = NULL,
...
...
@@ -28,6 +29,8 @@ if age_class_use = "pairs", to determine which age classes are mature (thus cont
\item{onset_year}{a vector containing the years of each wind farm start being active
(thus, the year at whihc each fatality value starts kicking in)}
\item{sel_sc}{scenario to display on the plot. Either "all" or the ID number of a given scenario.}
\item{xlab}{a character string. Label for the x axis.}
\item{ylab}{a character string. Label for the y axis.}
...
...
This diff is collapsed.
Click to expand it.
run_analysis.R
+
7
−
0
View file @
4cc28784
...
...
@@ -157,6 +157,13 @@ get_metrics(N = out$run$N)$scenario$impact[time_horizon, ,-1] %>% round(.,2)
res
=
get_metrics
(
N
=
out
$
run
$
N
,
cumulated_impacts
=
cumulated_impacts
)
names
(
res
)
N_0
=
N
N
=
N_0
plot_impact
(
N
,
sel_sc
=
"3"
,
show_CI
=
0.999
,
Legend
=
paste
(
"sc"
,
(
1
:
length
(
fatalities_mean
))
-1
))
...
...
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