An open API service indexing awesome lists of open source software.

https://github.com/eliocamp/rcmip6


https://github.com/eliocamp/rcmip6

Last synced: over 1 year ago
JSON representation

Awesome Lists containing this project

README

          

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# rcmip6

[![Codecov test coverage](https://codecov.io/gh/eliocamp/rcmip6/branch/main/graph/badge.svg)](https://app.codecov.io/gh/eliocamp/rcmip6?branch=main)
[![R-CMD-check](https://github.com/eliocamp/rcmip6/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/eliocamp/rcmip6/actions/workflows/R-CMD-check.yaml)

The goal of rcmip6 is to search and download data from the CMIP6 project.

## Installation

You can install the development version of rcmip6 like so:

``` r
remotes::install_github("eliocamp/rcmip6")
```

## Example

Search models, variables, etc... using `cmip_search()`

```{r example}
library(rcmip6)

query <- list(
type = "Dataset",
replica = "false",
latest = "true",
variable_id = "tas",
project = "CMIP6",
frequency = "mon",
table_id = "Amon",
experiment_id = "historical",
source_id = "CanESM5"
)

results <- cmip_search(query)
cmip_info(results)
```

Sumary of results:

```{r}
results |>
cmip_simplify() |> # To keep only the most informative columns
subset(, select = -full_info) |>
head(10) |>
knitr::kable()
```

The, download the data.
Just as a demonstration, download only the first result

```{r include=FALSE}
sink <- unlink("readme_example", recursive = TRUE)
```

```{r}
cmip_root_set("readme_example") # Set the root folder where to save files
dir.create(cmip_root_get())
files <- cmip_download(results[1])
```

The files are saved mirroring the source file structure to ensure that each file is unique.

```{r}
fs::dir_tree(cmip_root_get())
```

This structure can be parsed with `cmip_available()`

```{r}
cmip_available()
```

We can obtain the urls that *would* be downloaded.

Note that these are the *file server* URLs, in at lease some cases we can substitute "/fileServer/" with "/dodsC/" for the OpenDAP server URLs, which will work remotely with the NetCDF API.

```{r urls}
urls <- cmip_urls(results)
urls[[1]]
basename(unlist(urls[1:3]))
```