Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitattributes

This file was deleted.

2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ docs
rscd.png
resourcecode_logo.png
logos
*.svg
inst/doc
/doc/
/Meta/
/tests/testthat/_snaps/
cran-comments.md
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Imports:
grid,
gridtext,
jsonlite,
latex2exp,
lubridate,
ncdf4,
patchwork,
Expand Down
4 changes: 2 additions & 2 deletions R/orbital_speed.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ compute_orbital_speeds <- function(
out <- array(NA, dim = c(dim(spectral_u_component), 2))
out[, , 1] <- spectral_u_component
out[, , 2] <- spectral_v_component
return(out)
out
} else {
u_rms <- sqrt(2 * resourcecode::fastTrapz(freq, spectral_u_component, 2))
v_rms <- sqrt(2 * resourcecode::fastTrapz(freq, spectral_v_component, 2))
return(cbind(u_rms, v_rms))
cbind(u_rms, v_rms)
}
}
54 changes: 35 additions & 19 deletions R/specta_data_ploting.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
#' theme_linedraw coord_polar scale_color_distiller scale_fill_distiller
#' labs expansion
plot_2d_specta <- function(
spec,
time = 1L,
normalize = TRUE,
trim = 0.01,
cut_off = 0.4,
...) {
spec,
time = 1L,
normalize = TRUE,
trim = 0.01,
cut_off = 0.4,
...
) {
if (is.character(time)) {
time <- as.POSIXct(time, tz = "UTC")
}
Expand Down Expand Up @@ -118,10 +119,11 @@ plot_2d_specta <- function(
#' theme_linedraw
#' labs expansion
plot_1d_specta <- function(
spec,
time = 1L,
print_sea_state = TRUE,
...) {
spec,
time = 1L,
print_sea_state = TRUE,
...
) {
if (is.character(time)) {
time <- as.POSIXct(time, tz = "UTC")
}
Expand All @@ -131,7 +133,9 @@ plot_1d_specta <- function(
}

if ("freq" %nin% names(spec)) {
warning("Frequency vector not provided: using the default Resourcecode frequency vector.")
warning(
"Frequency vector not provided: using the default Resourcecode frequency vector."
)
freq_plot <- rscd_freq
} else {
freq_plot <- spec$freq
Expand All @@ -154,7 +158,7 @@ plot_1d_specta <- function(
expand = FALSE
) +
scale_y_continuous(
name = latex2exp::TeX("Wave spectral density ($m^2s)"),
name = "Wave spectral density (m^2.s)",
expand = expansion(c(0, .01), c(0, .05))
) +
labs(
Expand All @@ -163,12 +167,24 @@ plot_1d_specta <- function(
caption = "Source: Resourcecode hindcast database\nresourcecode.ifremer.fr"
)
if (print_sea_state) {
text <- paste0("**Sea-state parameters:**\n
Hs=", round(spec$forcings$hs[time], 2), "m<br>
Tp=", round(1 / spec$forcings$fp[time], 2), "s<br>
Dir=", round(spec$forcings$dir[time], 2), "\u00b0<br>
Wspd=", round(spec$forcings$wnd[time], 2), "m/s<br>
Wdir=", round(spec$forcings$wnddir[time], 2), "\u00b0<br>")
text <- paste0(
"**Sea-state parameters:**\n
Hs=",
round(spec$forcings$hs[time], 2),
"m<br>
Tp=",
round(1 / spec$forcings$fp[time], 2),
"s<br>
Dir=",
round(spec$forcings$dir[time], 2),
"\u00b0<br>
Wspd=",
round(spec$forcings$wnd[time], 2),
"m/s<br>
Wdir=",
round(spec$forcings$wnddir[time], 2),
"\u00b0<br>"
)

out_plot <- out_plot +
patchwork::inset_element(
Expand All @@ -182,7 +198,7 @@ Wdir=", round(spec$forcings$wnddir[time], 2), "\u00b0<br>")
left = 0.7,
bottom = 0.77,
right = .95,
top = .99
top = .95
)
}
out_plot
Expand Down
4 changes: 2 additions & 2 deletions R/spectral_data_download.R
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ get_2d_spectrum <- function(point, start = "1994-01-01", end = "1994-02-28") {
out$forcings <- rbind(out$forcings, temp$forcings)
}

return(out)
out
}


Expand Down Expand Up @@ -388,5 +388,5 @@ get_1d_spectrum <- function(point, start = "1994-01-01", end = "1994-02-28") {
out$forcings <- rbind(out$forcings, temp$forcings)
}

return(out)
out
}
Loading
Loading