Skip to content

Commit

Permalink
remove utf and fallback for connection failure
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinSchobben committed Sep 12, 2022
1 parent 53cef04 commit 8208afc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
9 changes: 3 additions & 6 deletions data-raw/noaa-data.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
## code to prepare `NOAA_data` dataset

library(tibble)

NOAA_data <- tibble(
variable = c("temperature", "phosphate", "nitrate", "silicate", "oxygen",
"salinity", "density"),
unit = c(
"\u00b0 C",
rep("\u03bc mol kg-1", 4),
"",
"kg m-3"
),
unit = c("C", rep("micromol kg-1", 4), "", "kg m-3"),
citation = c(
vc_cite["temperature"],
rep(vc_cite["nutrients"], 3),
Expand All @@ -19,4 +15,5 @@ NOAA_data <- tibble(
)
)

#save(NOAA_data, file = "data/NOAA_data.rda", ascii = TRUE, version = 3)
usethis::use_data(NOAA_data, overwrite = TRUE)
Binary file modified data/NOAA_data.rda
Binary file not shown.
3 changes: 1 addition & 2 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ https
io
isbn
knitr
ncei
nd
noaa
pkgs
programmatically
quosure
Expand All @@ -119,6 +117,7 @@ testthat
tibble
tunnelled
tunnelling
unicode
utrecht
vdiffr
worldmap
Expand Down
16 changes: 8 additions & 8 deletions vignettes/oceanexplorer.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Imagine we are interested in phosphate concentrations in the month December from

First, we extract the data by proving the variable, grid resolution, and the averaging period. Make sure to have an internet connection in order to connect to the NOAA server.

```{r setup, eval = curl::has_internet() && interactive()}
```{r setup, eval = curl::has_internet()}
# load package
library(oceanexplorer)
# get data
Expand All @@ -129,37 +129,37 @@ This operation can take a while, but it can be sped-up during future calls by ca

Then we can plot the phosphate data from a depth of 1000 meter below sea level.

```{r plot1, fig.width=7, eval = curl::has_internet() && interactive()}
```{r plot1, fig.width=7, eval = exists("WOA")}
plot_NOAA(WOA, depth = 1000)
```

```{r save1, echo=FALSE, eval = curl::has_internet() && interactive()}
```{r save1, echo=FALSE, eval = FALSE}
ggplot2::ggsave("vignettes/NOAA_plot1.png", plot_NOAA(WOA, depth = 1000), width = 9)
```

```{r graph1, echo=FALSE, eval = !curl::has_internet() || !interactive(), out.width="100%"}
```{r graph1, echo=FALSE, eval = !exists("WOA"), out.width="100%"}
knitr::include_graphics("NOAA_plot1.png")
```

## Filter Agulhas Basin data point

Finally, we can filter a data point from, for example, the Agulhas Basin.

```{r filter, eval = curl::has_internet() && interactive()}
```{r filter, eval = exists("WOA")}
(pts <- filter_NOAA(WOA, depth = 1000, coord = list(lon = 20, lat = -46)))
```

We can then also project these extraction points on the world map for future reference.

```{r plot2, fig.width=7, eval = curl::has_internet() && interactive()}
```{r plot2, fig.width=7, eval = exists("WOA")}
plot_NOAA(WOA, depth = 1000, points = pts)
```

```{r save2, echo=FALSE, eval = curl::has_internet() && interactive()}
```{r save2, echo=FALSE, eval = FALSE}
ggplot2::ggsave("vignettes/NOAA_plot2.png", plot_NOAA(WOA, depth = 1000, points = pts), width = 9)
```

```{r graph2, echo=FALSE, eval = !curl::has_internet() || !interactive(), out.width="100%"}
```{r graph2, echo=FALSE, eval = !exists("WOA"), out.width="100%"}
knitr::include_graphics("NOAA_plot2.png")
```

Expand Down

0 comments on commit 8208afc

Please sign in to comment.