Skip to content

Commit c2d6605

Browse files
committed
Remove dependency on latex2exp
1 parent 9606c42 commit c2d6605

12 files changed

Lines changed: 117 additions & 34 deletions

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ logos
1313
inst/doc
1414
/doc/
1515
/Meta/
16-
/tests/testthat/_snaps/
1716
cran-comments.md

DESCRIPTION

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ Imports:
2727
grid,
2828
gridtext,
2929
jsonlite,
30-
latex2exp,
3130
lubridate,
3231
ncdf4,
3332
patchwork,

R/specta_data_ploting.R

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@
1616
#' theme_linedraw coord_polar scale_color_distiller scale_fill_distiller
1717
#' labs expansion
1818
plot_2d_specta <- function(
19-
spec,
20-
time = 1L,
21-
normalize = TRUE,
22-
trim = 0.01,
23-
cut_off = 0.4,
24-
...) {
19+
spec,
20+
time = 1L,
21+
normalize = TRUE,
22+
trim = 0.01,
23+
cut_off = 0.4,
24+
...
25+
) {
2526
if (is.character(time)) {
2627
time <- as.POSIXct(time, tz = "UTC")
2728
}
@@ -118,10 +119,11 @@ plot_2d_specta <- function(
118119
#' theme_linedraw
119120
#' labs expansion
120121
plot_1d_specta <- function(
121-
spec,
122-
time = 1L,
123-
print_sea_state = TRUE,
124-
...) {
122+
spec,
123+
time = 1L,
124+
print_sea_state = TRUE,
125+
...
126+
) {
125127
if (is.character(time)) {
126128
time <- as.POSIXct(time, tz = "UTC")
127129
}
@@ -131,7 +133,9 @@ plot_1d_specta <- function(
131133
}
132134

133135
if ("freq" %nin% names(spec)) {
134-
warning("Frequency vector not provided: using the default Resourcecode frequency vector.")
136+
warning(
137+
"Frequency vector not provided: using the default Resourcecode frequency vector."
138+
)
135139
freq_plot <- rscd_freq
136140
} else {
137141
freq_plot <- spec$freq
@@ -154,7 +158,7 @@ plot_1d_specta <- function(
154158
expand = FALSE
155159
) +
156160
scale_y_continuous(
157-
name = latex2exp::TeX("Wave spectral density ($m^2s)"),
161+
name = "Wave spectral density (m^2.s)",
158162
expand = expansion(c(0, .01), c(0, .05))
159163
) +
160164
labs(
@@ -163,12 +167,24 @@ plot_1d_specta <- function(
163167
caption = "Source: Resourcecode hindcast database\nresourcecode.ifremer.fr"
164168
)
165169
if (print_sea_state) {
166-
text <- paste0("**Sea-state parameters:**\n
167-
Hs=", round(spec$forcings$hs[time], 2), "m<br>
168-
Tp=", round(1 / spec$forcings$fp[time], 2), "s<br>
169-
Dir=", round(spec$forcings$dir[time], 2), "\u00b0<br>
170-
Wspd=", round(spec$forcings$wnd[time], 2), "m/s<br>
171-
Wdir=", round(spec$forcings$wnddir[time], 2), "\u00b0<br>")
170+
text <- paste0(
171+
"**Sea-state parameters:**\n
172+
Hs=",
173+
round(spec$forcings$hs[time], 2),
174+
"m<br>
175+
Tp=",
176+
round(1 / spec$forcings$fp[time], 2),
177+
"s<br>
178+
Dir=",
179+
round(spec$forcings$dir[time], 2),
180+
"\u00b0<br>
181+
Wspd=",
182+
round(spec$forcings$wnd[time], 2),
183+
"m/s<br>
184+
Wdir=",
185+
round(spec$forcings$wnddir[time], 2),
186+
"\u00b0<br>"
187+
)
172188

173189
out_plot <- out_plot +
174190
patchwork::inset_element(
@@ -182,7 +198,7 @@ Wdir=", round(spec$forcings$wnddir[time], 2), "\u00b0<br>")
182198
left = 0.7,
183199
bottom = 0.77,
184200
right = .95,
185-
top = .99
201+
top = .95
186202
)
187203
}
188204
out_plot

R/utils.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ closest_point_field <- function(x, lat = NULL, closest = 1L, ...) {
6262
}
6363
}
6464

65-
return(list(
65+
list(
6666
points = t(ind_min),
6767
distances = distance
68-
))
68+
)
6969
}
7070

7171
#' Find the closest point of the SPEC grid to the specified position
@@ -116,10 +116,10 @@ closest_point_spec <- function(x, lat = NULL, closest = 1L, ...) {
116116
}
117117
}
118118

119-
return(list(
119+
list(
120120
points = t(ind_min),
121121
distances = distance
122-
))
122+
)
123123
}
124124

125125
#' Convert u/v to meteorological wind speed and direction
@@ -149,7 +149,7 @@ zmcomp2metconv <- function(u, v = NULL, names = c("wspd", "wdir")) {
149149
direction <- (270 - atan2(u[, 2], u[, 1]) * 180 / pi) %% 360
150150
out <- data.frame(speed, direction)
151151
names(out) <- names
152-
return(out)
152+
out
153153
}
154154

155155
#' Convert meteorological wind speed and direction to u/v components
@@ -279,7 +279,7 @@ jonswap <- function(hs = 5, tp = 15, fmax = rscd_freq, df = NULL, gam = 3.3) {
279279
", gamma=",
280280
gam
281281
)
282-
return(tibble::as_tibble(sp))
282+
tibble::as_tibble(sp)
283283
}
284284

285285
#' Mean Direction
@@ -372,7 +372,7 @@ mean_direction <- function(directions, weights = NULL) {
372372
# Ensure result is in [0, 360) range using modulo
373373
mean_degrees <- mean_degrees %% 360
374374

375-
return(mean_degrees)
375+
mean_degrees
376376
}
377377

378378
#' Directional binning
@@ -482,7 +482,7 @@ cut_directions <- function(directions, n_bins = 8, labels = NULL) {
482482
right = FALSE
483483
)
484484

485-
return(result)
485+
result
486486
}
487487

488488

@@ -669,7 +669,7 @@ cut_seasons <- function(datetime,
669669
}
670670

671671
result <- factor(seasons, levels = level_order)
672-
return(result)
672+
result
673673
}
674674

675675
#' Compute Fractional Day of Year from POSIXct

tests/testthat/Rplots.pdf

163 Bytes
Binary file not shown.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# obital speed computation works
2+
3+
WAoAAAACAAQFAgACAwAAAAIOAAAAFD+xr3OOSFczP8Gvc45IVzM/yoctVWyCzD/Rr3OOSFcz
4+
P9YbUHHabQE/2octVWyCzD/e8wo4/piaP+Gvc45IVzM/4+ViABFiGj/mG1Bx2m0BAAAAAAAA
5+
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
6+
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQCAAAAAQAEAAkAAAADZGltAAAADQAAAAIAAAAKAAAA
7+
AgAAAP4=
8+
9+
---
10+
11+
WAoAAAACAAQFAgACAwAAAAIOAAAAFD+4Uow1NVzyP8hSjDU1XPI/0j3pJ+gFtz/YUow1NVzy
12+
P95nL0KCtC8/4j3pJ+gFtz/lSDqujrFUP+hSjDU1XPI/61zdu9wIkT/uZy9CgrQvP7Cyldo7
13+
IeM/wLKV2jsh4z/JC+DHWLLTP9Cyldo7IeM/1N87UMnqXD/ZC+DHWLLTP904hj3ne00/4LKV
14+
2jsh4z/iyOiVgoYgP+TfO1DJ6lwAAAQCAAAAAQAEAAkAAAADZGltAAAADQAAAAIAAAAKAAAA
15+
AgAAAP4=
16+
17+
---
18+
19+
WAoAAAACAAQFAgACAwAAAAIOAAAAFD/QZTIfzRl8P+BlMh/NGXw/6JfLL7OmOT/wZTIfzRl8
20+
P/R+fqfAX9s/+JfLL7OmOT/8sRe3puyaQABlMh/NGXxAAnHYY8a8rEAEfn6nwF/bP8+TZmkk
21+
sOM/35NmaSSw4z/nrozO24SqP++TZmkksOM/87wgAbbujj/3rozO24SqP/ug+ZwAGsc//5Nm
22+
aSSw40ABwumbJKN/QAO8IAG27o4AAAQCAAAAAQAEAAkAAAADZGltAAAADQAAAAIAAAAKAAAA
23+
AgAAAP4=
24+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# dispersion is computed correctly
2+
3+
WAoAAAACAAQFAgACAwAAAAAOAAAAMwAAAAAAAAAAP24Qby+WaIE/fj9Q46Htaj+G6yJSg1Vh
4+
P48BKq1niDY/k7/c6IPhjD+YRLaeo1JDP50jcSWTsQ4/oTn530xULz+kKQJHt4WcP6duZlw/
5+
LSo/qxqAZeqdAD+vPJ7YjSBXP7HwQ6Vimx8/tIYkbCKznT+3X9j3fDuBP7p68paEp0s/vdQI
6+
F6s/Uj/As++zL7ZvP8KaAQ7d9/k/xJtoiaxIeT/Gt6vk/dT8P8juiWoNbvE/yz/gc0QP5j/N
7+
q6HmWQM8P9AY45zz6Wc/0Wkm4xYakT/SxppDs/ngP9QxPZAL3pY/1akQuDw1CT/XLhO3LM4x
8+
P9jARotSMFc/2l+pNDro+j/cDDuxyCmVP93F/gPyBbg/34zwKraO9j/gsIkTCqmOP+GhMfsH
9+
HI4/4phyzVCd3j/jlkuJ5y0AP+SavDDKydc/5aXEwft0Yj/mt2U9eSybP+fPnaND8og/6O5t
10+
81vGJj/qE9YtwKd0P+s/1lJylnY/7HJuYXGTJj/tq55avZ2IP+7rZj5WtZo/8BjjBh5tsQ==
11+

0 commit comments

Comments
 (0)