Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Quinoa_Chileanfieldtrial
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
Container 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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CEPLAS
Quinoa_Chileanfieldtrial
Commits
ffd2feb1
Commit
ffd2feb1
authored
1 year ago
by
Kathryn Dumschott
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
4418b0e3
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
workflows/environment_Rscript.R
+268
-0
268 additions, 0 deletions
workflows/environment_Rscript.R
with
268 additions
and
0 deletions
workflows/environment_Rscript.R
0 → 100644
+
268
−
0
View file @
ffd2feb1
#Load libraries
library
(
dplyr
)
library
(
ggplot2
)
library
(
tidyverse
)
library
(
lubridate
)
library
(
ggpubr
)
#set working directory
setwd
(
"~/Documents/QuinoaDiveristy/FIELDTRIAL_publicationdata/FieldTrial_R/WeatherData"
)
#import Night data
Envdata_Night
<-
read.csv
(
file
=
"EnvironmentAll_night_values.csv"
,
head
=
TRUE
,
sep
=
' '
)
#Calculate mean temp per night
EnvdataNight_meantemp
<-
Envdata_Night
%>%
dplyr
::
group_by
(
das
)
%>%
summarise
(
mean
(
AT_DEGC
,
na.rm
=
TRUE
))
#import Day data
Envdata_Day
<-
read.csv
(
file
=
"EnvironmentAll_Day_values.csv"
,
head
=
TRUE
,
sep
=
' '
)
#Calculate parameters
#Daily Max temp
EnvdataDay_maxtemp
<-
Envdata_Day
%>%
dplyr
::
group_by
(
das
)
%>%
summarise
(
max
(
AT_DEGC
,
na.rm
=
TRUE
))
#Daily max VDP
EnvdataDay_maxVPD
<-
Envdata_Day
%>%
dplyr
::
group_by
(
das
)
%>%
summarise
(
max
(
VPD_kPa
,
na.rm
=
TRUE
))
#Daily sum Radiation
EnvdataDay_sumRAD
<-
Envdata_Day
%>%
dplyr
::
group_by
(
das
)
%>%
summarise
(
sum
(
RAD_maxWM2
,
na.rm
=
TRUE
))
#Rename columns
#Daily max temp
colnames
(
EnvdataDay_maxtemp
)
names
(
EnvdataDay_maxtemp
)[
names
(
EnvdataDay_maxtemp
)
==
"max(AT_DEGC, na.rm = TRUE)"
]
<-
"Daily_MaxTemp"
#Average night temp
colnames
(
EnvdataNight_meantemp
)
names
(
EnvdataNight_meantemp
)[
names
(
EnvdataNight_meantemp
)
==
"mean(AT_DEGC, na.rm = TRUE)"
]
<-
"Nightly_MeanTemp"
#Daily max VPD
colnames
(
EnvdataDay_maxVPD
)
names
(
EnvdataDay_maxVPD
)[
names
(
EnvdataDay_maxVPD
)
==
"max(VPD_kPa, na.rm = TRUE)"
]
<-
"Daily_MaxVPD"
#Daily sum RAD
colnames
(
EnvdataDay_sumRAD
)
names
(
EnvdataDay_sumRAD
)[
names
(
EnvdataDay_sumRAD
)
==
"sum(RAD_maxWM2, na.rm = TRUE)"
]
<-
"Daily_sumRAD"
#Day and Night Temperatures
Temps_all
<-
cbind
(
EnvdataDay_maxtemp
$
das
,
EnvdataDay_maxtemp
$
Daily_MaxTemp
,
EnvdataNight_meantemp
$
Nightly_MeanTemp
)
tempheadings
<-
c
(
"das"
,
"Daily_MaxTemp"
,
"Nightly_MeanTemp"
)
colnames
(
Temps_all
)
<-
tempheadings
Temps_DayNight
<-
as.data.frame
(
Temps_all
)
#Import SWC data
SWCData
<-
read.csv
(
file
=
"~/Documents/QuinoaDiveristy/FIELDTRIAL_publicationdata/FieldTrial_R/WeatherData/SoilVWC_averages.csv"
,
head
=
TRUE
,
sep
=
' '
)
SWCData_WWmeanSWC
<-
SWCData
%>%
dplyr
::
group_by
(
das
)
%>%
summarise
(
mean
(
soilVWC_WW
))
SWCData_WDmeanSWC
<-
SWCData
%>%
dplyr
::
group_by
(
das
)
%>%
summarise
(
mean
(
soilVWC_WD
))
#Soil Water Content data
SWCData_meanVWC
<-
cbind
(
SWCData_WWmeanSWC
$
das
,
SWCData_WWmeanSWC
$
`mean(soilVWC_WW)`
,
SWCData_WDmeanSWC
$
`mean(soilVWC_WD)`
)
headings
<-
c
(
"das"
,
"SWC_WW"
,
"SWC_WD"
)
colnames
(
SWCData_meanVWC
)
<-
headings
SWCData_VWC
<-
as.data.frame
(
SWCData_meanVWC
)
class
(
SWCData_VWC
[,
3
])
levels
(
SWCData_VWC
)
#reorder levels
#line graphs
#MaxTempLG <-EnvdataDay_maxtemp %>%
#ggplot(aes (x=das, y=Daily_MaxTemp)) +
# geom_line()+
#theme(panel.grid = element_blank())+
#labs(y= expression( Temperature~(degree*C)),
# title= "Daily Maximum Temperature")
#MeanTempNightLG <-EnvdataNight_meantemp %>%
# ggplot(aes (x=das, y=Nightly_MeanTemp)) +
# geom_line()+
# theme(panel.grid = element_blank())+
# labs(y= expression( Temperature~(degree*C)),
# title= "Nightly Average Temperature")
temperatures
<-
rep
(
c
(
"solid"
,
"dashed"
),
2
)
AllTempsLG
<-
Temps_DayNight
%>%
ggplot
(
aes
(
x
=
das
))
+
annotate
(
geom
=
"rect"
,
xmin
=
0
,
xmax
=
60
,
ymin
=-
Inf
,
ymax
=
Inf
,
fill
=
"palegreen2"
,
alpha
=
0.5
)
+
annotate
(
geom
=
"rect"
,
xmin
=
60
,
xmax
=
105
,
ymin
=-
Inf
,
ymax
=
Inf
,
fill
=
"paleturquoise2"
,
alpha
=
0.7
)
+
annotate
(
geom
=
"rect"
,
xmin
=
105
,
xmax
=
155
,
ymin
=-
Inf
,
ymax
=
Inf
,
fill
=
"gray80"
,
alpha
=
0.5
)
+
geom_line
(
aes
(
y
=
Daily_MaxTemp
,
linetype
=
"Daily Maximum Temperature"
))
+
geom_line
(
aes
(
y
=
Nightly_MeanTemp
,
linetype
=
"Nightly Mean Temperature"
))
+
labs
(
y
=
expression
(
Temperature
~
(
degree
*
C
)),
title
=
"Daily Maximum and Nightly Average Temperatures"
,
x
=
"Days after sowing"
)
+
theme
(
panel.grid
=
element_blank
(),
panel.background
=
element_rect
(
fill
=
"White"
),
panel.border
=
element_blank
(),
axis.line
=
element_line
(),
legend.title
=
element_blank
(),
legend.position
=
c
(
0.5
,
1.10
),
legend.direction
=
"horizontal"
,
legend.background
=
element_rect
(
fill
=
NA
),
legend.key
=
element_blank
())
+
scale_linetype_manual
(
values
=
temperatures
)
+
scale_x_continuous
(
expand
=
c
(
0
,
0
))
+
scale_fill_discrete
(
name
=
NULL
)
AllTempsLG
MaxVPDLG
<-
EnvdataDay_maxVPD
%>%
ggplot
(
aes
(
x
=
das
,
y
=
Daily_MaxVPD
))
+
annotate
(
geom
=
"rect"
,
xmin
=
0
,
xmax
=
60
,
ymin
=-
Inf
,
ymax
=
Inf
,
fill
=
"palegreen2"
,
alpha
=
0.5
)
+
annotate
(
geom
=
"rect"
,
xmin
=
60
,
xmax
=
105
,
ymin
=-
Inf
,
ymax
=
Inf
,
fill
=
"paleturquoise2"
,
alpha
=
0.7
)
+
annotate
(
geom
=
"rect"
,
xmin
=
105
,
xmax
=
155
,
ymin
=-
Inf
,
ymax
=
Inf
,
fill
=
"gray80"
,
alpha
=
0.5
)
+
theme
(
panel.grid
=
element_blank
())
+
geom_line
()
+
labs
(
y
=
expression
(
VPD
~
(
kPa
)
),
title
=
"Daily Maximum Vapor-Pressure Deficit"
,
x
=
"Days after sowing"
)
+
theme
(
panel.grid
=
element_blank
(),
panel.background
=
element_rect
(
fill
=
"White"
),
panel.border
=
element_blank
(),
axis.line
=
element_line
(),
legend.title
=
element_blank
())
+
scale_x_continuous
(
expand
=
c
(
0
,
0
))
+
scale_fill_discrete
(
name
=
NULL
)
MaxVPDLG
SumRADLG
<-
EnvdataDay_sumRAD
%>%
ggplot
(
aes
(
x
=
das
,
y
=
Daily_sumRAD
))
+
annotate
(
geom
=
"rect"
,
xmin
=
0
,
xmax
=
60
,
ymin
=-
Inf
,
ymax
=
Inf
,
fill
=
"palegreen2"
,
alpha
=
0.5
)
+
annotate
(
geom
=
"rect"
,
xmin
=
60
,
xmax
=
105
,
ymin
=-
Inf
,
ymax
=
Inf
,
fill
=
"paleturquoise2"
,
alpha
=
0.7
)
+
annotate
(
geom
=
"rect"
,
xmin
=
105
,
xmax
=
155
,
ymin
=-
Inf
,
ymax
=
Inf
,
fill
=
"gray80"
,
alpha
=
0.5
)
+
geom_line
()
+
theme
(
panel.grid
=
element_blank
())
+
labs
(
y
=
expression
(
Radiation
~
(
W
/
m
^
2
)),
title
=
"Daily Total Radiation"
,
x
=
"Days after sowing"
)
+
theme
(
panel.grid
=
element_blank
(),
panel.background
=
element_rect
(
fill
=
"White"
),
panel.border
=
element_blank
(),
axis.line
=
element_line
(),
legend.title
=
element_blank
())
+
scale_x_continuous
(
expand
=
c
(
0
,
0
))
+
scale_fill_discrete
(
name
=
NULL
)
treatment
<-
c
(
"solid"
,
"dashed"
)
SumSWCLG
<-
SWCData_VWC
%>%
ggplot
(
aes
(
x
=
das
))
+
annotate
(
geom
=
"rect"
,
xmin
=
0
,
xmax
=
60
,
ymin
=-
Inf
,
ymax
=
Inf
,
fill
=
"palegreen2"
,
alpha
=
0.5
)
+
annotate
(
geom
=
"rect"
,
xmin
=
60
,
xmax
=
105
,
ymin
=-
Inf
,
ymax
=
Inf
,
fill
=
"paleturquoise2"
,
alpha
=
0.7
)
+
annotate
(
geom
=
"rect"
,
xmin
=
105
,
xmax
=
155
,
ymin
=-
Inf
,
ymax
=
Inf
,
fill
=
"gray80"
,
alpha
=
0.5
)
+
geom_line
(
aes
(
y
=
SWC_WW
,
linetype
=
"Full Irrigation"
))
+
geom_line
(
aes
(
y
=
SWC_WD
,
linetype
=
"Reduced Irrigation"
))
+
labs
(
y
=
expression
(
VSWC
~
(
m
^
3
*
m
^
3
)),
title
=
"Daily Volumetric Soil Water Content"
,
x
=
"Days after sowing"
)
+
theme
(
panel.grid
=
element_blank
(),
panel.background
=
element_rect
(
fill
=
"White"
),
panel.border
=
element_blank
(),
axis.line
=
element_line
(),
legend.title
=
element_blank
(),
legend.position
=
c
(
0.5
,
1.10
),
legend.direction
=
"horizontal"
,
legend.background
=
element_rect
(
fill
=
NA
),
legend.key
=
element_blank
())
+
scale_linetype_manual
(
values
=
treatment
,
breaks
=
c
(
"Full Irrigation"
,
"Reduced Irrigation"
))
+
scale_x_continuous
(
expand
=
c
(
0
,
0
))
SumSWCLG
background
<-
SWCData_WDmeanSWC
%>%
ggplot
(
aes
(
x
=
das
,
y
=
"mean(soilVWC_WD)"
))
+
annotate
(
geom
=
"rect"
,
xmin
=
0
,
xmax
=
60
,
ymin
=-
Inf
,
ymax
=
Inf
,
fill
=
"palegreen2"
,
alpha
=
0.5
)
+
annotate
(
geom
=
"rect"
,
xmin
=
60
,
xmax
=
105
,
ymin
=-
Inf
,
ymax
=
Inf
,
fill
=
"paleturquoise2"
,
alpha
=
0.7
)
+
annotate
(
geom
=
"rect"
,
xmin
=
105
,
xmax
=
155
,
ymin
=-
Inf
,
ymax
=
Inf
,
fill
=
"gray80"
,
alpha
=
0.5
)
+
theme
(
panel.grid
=
element_blank
(),
panel.background
=
element_rect
(
fill
=
"White"
),
panel.border
=
element_blank
(),
axis.text.y
=
element_blank
(),
axis.ticks.y
=
element_blank
())
+
scale_x_continuous
(
expand
=
c
(
0
,
0
))
+
labs
(
y
=
" "
,
x
=
" "
)
+
geom_line
()
background
figure
<-
ggarrange
(
AllTempsLG
,
MaxVPDLG
,
SumRADLG
,
SumSWCLG
,
background
,
labels
=
c
(
"A"
,
"B"
,
"C"
,
"D"
,
" "
),
ncol
=
1
,
nrow
=
5
,
align
=
"v"
)
figure
colnames
(
SWCData_WDmeanSWC
)
#Graphs with different rectangle colors
MaxTempLG
<-
EnvdataDay_maxtemp
%>%
ggplot
(
aes
(
x
=
das
,
y
=
Daily_MaxTemp
))
+
geom_line
()
+
theme
(
panel.grid
=
element_blank
())
+
labs
(
y
=
expression
(
Temperature
~
(
degree
*
C
)),
title
=
"Daily Maximum Temperature"
)
+
geom_rect
(
aes
(
xmin
=
0
,
xmax
=
60
,
ymin
=-
Inf
,
ymax
=
Inf
),
fill
=
'gray100'
,
alpha
=
0.002
)
+
geom_rect
(
aes
(
xmin
=
60
,
xmax
=
105
,
ymin
=-
Inf
,
ymax
=
Inf
),
fill
=
'gray78'
,
alpha
=
0.002
)
+
geom_rect
(
aes
(
xmin
=
105
,
xmax
=
156
,
ymin
=-
Inf
,
ymax
=
Inf
),
fill
=
'gray61'
,
alpha
=
0.002
)
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