Skip to content
Open
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: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
Config/testthat/edition: 3
VignetteBuilder: knitr
11 changes: 0 additions & 11 deletions tests/testthat/GlanceNetCDF

This file was deleted.

19 changes: 19 additions & 0 deletions tests/testthat/_snaps/GetTopography.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# GetTopography gets topography

Code
topo
Output
lon lat h
<num> <num> <int>
1: 280.25 -0.25 263
2: 280.75 -0.25 289
3: 281.25 -0.25 1532
4: 281.75 -0.25 2830
5: 282.25 -0.25 2375
---
11996: 327.75 -59.75 -3094
11997: 328.25 -59.75 -3413
11998: 328.75 -59.75 -2282
11999: 329.25 -59.75 -2966
12000: 329.75 -59.75 -2752

36 changes: 36 additions & 0 deletions tests/testthat/_snaps/ReadNetCDF.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# GlanceNetCDF prints nicely

Code
print(GlanceNetCDF(file))
Output
----- Variables -----
air:
mean Daily Air temperature in degK
Dimensions: lon by lat by level by time


----- Dimensions -----
time: 1 values from 2010-07-09 to 2010-07-09
level: 17 values from 10 to 1000 millibar
lat: 73 values from -90 to 90 degrees_north
lon: 144 values from 0 to 357.5 degrees_east

# subsetting works

Code
ReadNetCDF(file, subset = s)
Output
time level lat lon air
<POSc> <num> <num> <num> <num>
1: 2010-07-09 1000 -70 0.0 249.07
2: 2010-07-09 1000 -70 2.5 249.82
3: 2010-07-09 1000 -70 5.0 250.32
4: 2010-07-09 1000 -70 7.5 250.62
5: 2010-07-09 1000 -70 10.0 250.77
---
7493: 2010-07-09 10 70 347.5 242.17
7494: 2010-07-09 10 70 350.0 242.05
7495: 2010-07-09 10 70 352.5 241.95
7496: 2010-07-09 10 70 355.0 241.85
7497: 2010-07-09 10 70 357.5 241.70

13 changes: 13 additions & 0 deletions tests/testthat/_snaps/eof.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# eof methods

Code
summary(eof)
Output
Importance of components:
Component Explained variance Cumulative variance
1 100% 100%
2 0% 100%
3 0% 100%
4 0% 100%
5 0% 100%

183 changes: 183 additions & 0 deletions tests/testthat/_snaps/interpolate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
# interpolate works

Code
geopotential[, Interpolate(gh ~ lon + lat, x.out, y.out)]
Output
lon lat gh
<num> <num> <num>
1: 0 -90 2715.936
2: 10 -90 2715.936
3: 20 -90 2715.936
4: 30 -90 2715.936
5: 40 -90 2715.936
---
366: 320 0 NA
367: 330 0 NA
368: 340 0 NA
369: 350 0 NA
370: 360 0 NA

---

Code
geopotential[, Interpolate(gh ~ lon + lat, x.out, y.out, grid = FALSE)]
Output
lon lat gh
<num> <num> <num>
1: 0 -90 2715.936
2: 40 -80 2776.129
3: 80 -70 2722.968
4: 120 -60 2708.710
5: 160 -50 2928.774
6: 200 -40 3095.548
7: 240 -30 3170.258
8: 280 -20 NA
9: 320 -10 NA
10: 360 0 NA

---

Code
geopotential[, Interpolate(gh ~ lon + lat, x.out, y.out, grid = FALSE)]
Output
lon lat gh
<num> <num> <num>
1: 0 -90 2715.936
2: 40 -80 2776.129
3: 80 -70 2722.968
4: 120 -60 2708.710
5: 160 -50 2928.774
6: 200 -40 3095.548
7: 240 -30 3170.258
8: 280 -20 NA
9: 320 -10 NA
10: 360 0 NA

---

Code
geopotential[, Interpolate(u | v ~ lon + lat, x.out, y.out)]
Output
lon lat u v
<num> <num> <num> <num>
1: 0 -90 NA 0.00000000
2: 40 -90 NA 0.00000000
3: 80 -90 NA 0.00000000
4: 120 -90 NA 0.00000000
5: 160 -90 NA 0.00000000
6: 200 -90 NA 0.00000000
7: 240 -90 NA 0.00000000
8: 280 -90 NA 0.00000000
9: 320 -90 NA 0.00000000
10: 360 -90 NA NA
11: 0 -80 0.2060515 -5.40863143
12: 40 -80 -0.1545536 -0.59330168
13: 80 -80 -0.8718648 3.17222089
14: 120 -80 0.8639167 3.24061898
15: 160 -80 -1.1096189 1.32374501
16: 200 -80 0.4676200 1.11820527
17: 240 -80 3.7568859 -2.37337946
18: 280 -80 2.9325899 2.94388178
19: 320 -80 -0.1624718 -4.70116019
20: 360 -80 NA NA
21: 0 -70 -4.2985774 1.84579405
22: 40 -70 -6.8237095 -5.57368410
23: 80 -70 -5.1208940 -2.82934752
24: 120 -70 -4.0576755 0.08501093
25: 160 -70 -0.2035282 -0.59507650
26: 200 -70 2.6331356 -0.13353609
27: 240 -70 1.7775944 -0.29142665
28: 280 -70 -1.1338483 -5.52515894
29: 320 -70 3.8085068 -0.64360166
30: 360 -70 NA NA
31: 0 -60 3.5781696 3.53304644
32: 40 -60 8.8687692 -1.91979880
33: 80 -60 7.1743135 2.46953084
34: 120 -60 3.4114219 -1.33391364
35: 160 -60 10.9507454 0.25238969
36: 200 -60 7.9404185 -1.35199020
37: 240 -60 9.8511790 -0.21630479
38: 280 -60 7.2103984 0.26139387
39: 320 -60 1.4240577 2.06393378
40: 360 -60 NA NA
41: 0 -50 18.3000222 0.23778405
42: 40 -50 17.6937333 -3.40017988
43: 80 -50 19.0234508 3.13072329
44: 120 -50 16.0023015 -2.11618203
45: 160 -50 16.2825038 -1.28399785
46: 200 -50 15.3450773 0.41216301
47: 240 -50 15.9972504 -1.77540222
48: 280 -50 15.1667842 1.15718769
49: 320 -50 15.2330272 2.71064214
50: 360 -50 NA NA
51: 0 -40 19.2893933 -0.75294282
52: 40 -40 13.6974663 -1.91804865
53: 80 -40 13.5213788 2.51244878
54: 120 -40 14.3107397 -1.69616087
55: 160 -40 8.6701957 -0.80842976
56: 200 -40 12.1735190 0.97489059
57: 240 -40 8.7430294 -0.28529287
58: 280 -40 10.4491757 3.08315448
59: 320 -40 14.2196172 0.32494354
60: 360 -40 NA NA
61: 0 -30 2.5367799 1.84769720
62: 40 -30 -0.2653629 0.38758871
63: 80 -30 0.4136992 0.12619485
64: 120 -30 6.8063350 -3.82145282
65: 160 -30 0.7570996 0.80212173
66: 200 -30 1.1474053 0.41460123
67: 240 -30 -0.5697742 0.76610504
68: 280 -30 1.3503855 2.76694139
69: 320 -30 6.8688359 -4.11893159
70: 360 -30 NA NA
71: 0 -20 NA NA
72: 40 -20 NA NA
73: 80 -20 NA NA
74: 120 -20 NA NA
75: 160 -20 NA NA
76: 200 -20 NA NA
77: 240 -20 NA NA
78: 280 -20 NA NA
79: 320 -20 NA NA
80: 360 -20 NA NA
81: 0 -10 NA NA
82: 40 -10 NA NA
83: 80 -10 NA NA
84: 120 -10 NA NA
85: 160 -10 NA NA
86: 200 -10 NA NA
87: 240 -10 NA NA
88: 280 -10 NA NA
89: 320 -10 NA NA
90: 360 -10 NA NA
91: 0 0 NA NA
92: 40 0 NA NA
93: 80 0 NA NA
94: 120 0 NA NA
95: 160 0 NA NA
96: 200 0 NA NA
97: 240 0 NA NA
98: 280 0 NA NA
99: 320 0 NA NA
100: 360 0 NA NA
lon lat u v

---

Code
geopotential[, Interpolate(gh ~ lon + lat, as.path(lons, lats))]
Output
lon lat .order gh
<num> <num> <int> <num>
1: 302.0000 -34.00000 1 3120.352
2: 299.3333 -38.44444 2 3087.826
3: 296.6667 -42.88889 3 3026.312
4: 294.0000 -47.33333 4 2956.951
5: 291.3333 -51.77778 5 2882.163
6: 290.0000 -54.00000 6 2841.716
7: 277.7778 -51.33333 7 2898.452
8: 253.3333 -46.00000 8 3051.176
9: 228.8889 -40.66667 9 3108.243
10: 204.4444 -35.33333 10 3136.094
11: 180.0000 -30.00000 11 3144.161

14 changes: 14 additions & 0 deletions tests/testthat/_snaps/trajectory.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# trajectory works

Code
Trajectory(dlon + dlat ~ lon + lat + date, x0 = 180, y0 = -60, data = na.omit(
geopotential), res = 3, cyclical = c(TRUE, FALSE))
Output
lon lat id piece date dlon dlat
<num> <num> <int> <num> <num> <num> <num>
1: 180.00000 -60.00000 1 1 631152000 1.527505e-04 -1.373291e-05
2: 316.37564 -72.26074 1 1 632044800 1.258644e-04 -4.088801e-06
3: 71.24737 -75.91122 1 2 632937600 -1.124835e-04 1.634286e-06
4: 328.32208 -74.45213 1 3 633830400 9.383545e-05 -1.294094e-05
5: 54.59837 -86.00580 1 4 634723200 6.627506e-04 -6.734548e-06

19 changes: 19 additions & 0 deletions tests/testthat/_snaps/waveflux.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# waveflux returns w.x and w.y

Code
return
Output
w.x w.y
<num> <num>
1: NA NA
2: NA NA
3: NA NA
4: NA NA
5: NA NA
---
4028: NA NA
4029: NA NA
4030: NA NA
4031: NA NA
4032: NA NA

38 changes: 0 additions & 38 deletions tests/testthat/eof_print

This file was deleted.

7 changes: 0 additions & 7 deletions tests/testthat/eof_summary

This file was deleted.

Binary file removed tests/testthat/interpolate1
Binary file not shown.
Binary file removed tests/testthat/interpolate2
Binary file not shown.
Binary file removed tests/testthat/interpolate3
Binary file not shown.
Binary file removed tests/testthat/interpolate4
Binary file not shown.
Binary file removed tests/testthat/readnetcdf_unnamed_subset
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/testthat/test-GetTopography.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ test_that("GetTopography gets topography", {
expect_s3_class(GetTopography(280, 330, 0, -60, resolution = 0.5,
file.dir = "~"), "data.frame")
topo <- GetTopography(280, 330, 0, -60, resolution = 0.5)
expect_known_value(topo, "topography")
expect_snapshot(topo)
expect_message(GetTopography(280, 330, 0, -60, resolution = 0.5, verbose = TRUE),
"Fetching cached field.")
})
Expand Down
10 changes: 4 additions & 6 deletions tests/testthat/test-ReadNetCDF.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@

context("ReadNetCDF")
skip_if_not_installed(c("ncdf4", "CFtime"))
file <- system.file("extdata", "temperature.nc", package = "metR")
test_that("returns a data.table", {
Expand All @@ -8,7 +6,7 @@ test_that("returns a data.table", {
})

test_that("GlanceNetCDF prints nicely", {
expect_known_output(print(GlanceNetCDF(file)), "GlanceNetCDF")
expect_snapshot(print(GlanceNetCDF(file)))

})

Expand All @@ -23,7 +21,7 @@ test_that("subsetting works", {
list(lat = -90:-70, lon = 0:60),
list(lat = 70:90, lon = 300:360)
)
expect_known_value(ReadNetCDF(file, subset = s), "readnetcdf_unnamed_subset")
expect_snapshot(ReadNetCDF(file, subset = s))

})

Expand All @@ -37,8 +35,8 @@ test_that("naming works", {
test_that("different outs work", {
expect_s3_class(ReadNetCDF(file),
"data.table")
expect_is(ReadNetCDF(file, out = "array")[[1]], "array")
expect_is(ReadNetCDF(file, out = "vector")[[1]], "numeric")
expect_equal(class(ReadNetCDF(file, out = "array")[[1]]), "array")
expect_type(ReadNetCDF(file, out = "vector")[[1]], "double")
})


Expand Down
Loading
Loading