Skip to content
Snippets Groups Projects
Commit f5f725ac authored by og's avatar og
Browse files

lintr formatting

parent c9f53b38
No related branches found
No related tags found
No related merge requests found
# SPDX-FileCopyrightText: 2025 Helmholtz-Zentrum hereon GmbH
# SPDX-License-Identifier: CC0-1.0
# SPDX-FileContributor Carsten Lemmen <carsten.lemmen@hereon.de>
name: Build and test
on: push
jobs:
......
......@@ -10,6 +10,6 @@ lint-r:
before_script:
- R -e 'install.packages("lintr", repos="http://cran.rstudio.com")'
script:
- Rscript -e 'lintr::lint("./testcases/light/model_comparison.R")'
- Rscript -e 'lintr::lint("./testcases/estuary/plot_output.R")'
- Rscript -e 'lintr::lint("./testcases/estuary/setup_data.R")'
- Rscript -e 'lintr::lint("./testcases/light/model_comparison.R", linters = with_defaults(object_usage_linter = NULL))'
- Rscript -e 'lintr::lint("./testcases/estuary/plot_output.R", linters = with_defaults(object_usage_linter = NULL))'
- Rscript -e 'lintr::lint("./testcases/estuary/setup_data.R", linters = with_defaults(object_usage_linter = NULL))'
......@@ -14,9 +14,18 @@ as.POSIXct = function(...) base::as.POSIXct(..., format = "%Y-%m-%d %H:%M:%S")
## loading observed values for temperature (temp) wind velocity (wind) and wind
## direction (dirw) to create forcing file
temp = read.delim("Cuxhaven_DWD!Lufttemperatur.txt", header = FALSE, comment.char = "#")
wind = read.delim("Cuxhaven_DWD!Windgeschwindigkeit.txt", header = FALSE, comment.char = "#")
dirw = read.delim("Cuxhaven_DWD!Windrichtung.txt", header = FALSE, comment.char = "#")
temp = read.delim("Cuxhaven_DWD!Lufttemperatur.txt",
header = FALSE,
comment.char = "#"
)
wind = read.delim("Cuxhaven_DWD!Windgeschwindigkeit.txt",
header = FALSE,
comment.char = "#"
)
dirw = read.delim("Cuxhaven_DWD!Windrichtung.txt",
header = FALSE,
comment.char = "#"
)
temp$V1 = as.POSIXct(temp$V1)
wind$V1 = as.POSIXct(wind$V1)
......@@ -34,22 +43,22 @@ temp$temp = temp$V2 + (h_model - h_station) * T_gradient + bias
## assuming logarithmic profile
h_station = 9
h_model = 10
w.exponent = 0.14
wind$V3 = wind$V2 * (h_model / h_station)^w.exponent
w_exponent = 0.14
wind$V3 = wind$V2 * (h_model / h_station)^w_exponent
## merging wind files
wind = merge(wind, dirw, by = "V1", suffixes = c(".vel", ".dir"))
## calculating wind components
wind$u10 = wind$V3 * cos(pi*wind$V2.dir / 180)
wind$v10 = wind$V3 * sin(pi*wind$V2.dir / 180)
wind$u10 = wind$V3 * cos(pi * wind$V2.dir / 180)
wind$v10 = wind$V3 * sin(pi * wind$V2.dir / 180)
## creating the meteofile
meteofile = merge(temp, wind)
meteofile = subset(meteofile,
get.year(V1) >= 2004 & !is.na(temp) & !is.na(v10) & !is.na(u10),
select=c(V1, temp, u10, v10)
)
)
meteofile$V1 = meteofile$V1 + 1 # adding 1 sec to avoid a bug with gotm config
colnames(meteofile) = paste0("#", colnames(meteofile))
......
......@@ -30,9 +30,16 @@ col_ref = "black"
N = length(rpar[1,])
png(filename = "./light_validation.png",
width = 600, height = 600)
width = 600,
height = 600
)
par(mfrow = c(3, 2),
mai = 2 * c(0.42, 0.42, 0.21, 0.21),
oma = 2 * c(1, 1, 0.5, 0.5),
las = 1
)
par(mfrow = c(3, 2), mai = 2 * c(0.42, 0.42, 0.21, 0.21), oma = 2 * c(1, 1, 0.5, 0.5), las = 1)
hist(100 * (bpar - rpar) / (rpar + bpar),
main = "difference in par relatiave to reference (%)",
xlim = c(-100, 100),
......@@ -40,52 +47,50 @@ hist(100 * (bpar - rpar) / (rpar + bpar),
freq = FALSE,
border = NA,
n = 50
)
hist(100 * (bphy - rphy) / (rphy + bphy),
xlim = c(-100, 100),
xlab = "",
main = "difference in ALG1 relatiave to reference (%)",
freq = FALSE,
border = NA,
n = 50
)
plot(rpar, bpar,
col = "lightgray",
pch = 20,
xlab = "reference ALG1",
ylab = "dobgc_light ALG1"
)
abline(a = 0, b = 1)
plot(rphy, bphy,
col = "lightgray",
pch = 20,
xlab = "reference ALG1",
ylab = "dobgc_light ALG1"
)
abline(a = 0, b = 1)
plot(rowMeans(rpar[,1:(N / 2 + 1)]),
type = "l",
col = col_ref,
main = "par in the surface",
xlab = "",
ylab = "W m-2"
)
lines(rowMeans(bpar[,1:(N / 2 + 1)]), type = "l", col = col_sim)
plot(rowMeans(rphy[,1:(N / 2 + 1)]),
type = "l",
col = col_ref,
main = "ALG1 in the surface",
xlab = "",
ylab = "mmol-C m-3"
)
lines(rowMeans(bphy[,1:(N / 2 + 1)]),type = "l",col = col_sim)
)
hist(100 * (bphy - rphy) / (rphy + bphy),
xlim = c(-100, 100),
xlab = "",
main = "difference in ALG1 relatiave to reference (%)",
freq = FALSE,
border = NA,
n = 50
)
plot(rpar, bpar,
col = "lightgray",
pch = 20,
xlab = "reference ALG1",
ylab = "dobgc_light ALG1"
)
abline(a = 0, b = 1)
plot(rphy, bphy,
col = "lightgray",
pch = 20,
xlab = "reference ALG1",
ylab = "dobgc_light ALG1"
)
abline(a = 0, b = 1)
plot(rowMeans(rpar[, 1:(N / 2 + 1)]),
type = "l",
col = col_ref,
main = "par in the surface",
xlab = "",
ylab = "W m-2"
)
lines(rowMeans(bpar[, 1:(N / 2 + 1)]), type = "l", col = col_sim)
plot(rowMeans(rphy[, 1:(N / 2 + 1)]),
type = "l",
col = col_ref,
main = "ALG1 in the surface",
xlab = "",
ylab = "mmol-C m-3"
)
lines(rowMeans(bphy[, 1:(N / 2 + 1)]),type = "l",col = col_sim)
dev.off()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment