https://github.com/eliocamp/rcmip6
https://github.com/eliocamp/rcmip6
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/eliocamp/rcmip6
- Owner: eliocamp
- Created: 2021-12-03T14:16:12.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-02-06T01:22:34.000Z (over 1 year ago)
- Last Synced: 2025-02-28T22:13:19.056Z (over 1 year ago)
- Language: R
- Size: 136 KB
- Stars: 22
- Watchers: 4
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
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
[](https://app.codecov.io/gh/eliocamp/rcmip6?branch=main)
[](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]))
```