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

https://github.com/mdsumner/nchelper

NetCDF variables as R arrays
https://github.com/mdsumner/nchelper

Last synced: 4 months ago
JSON representation

NetCDF variables as R arrays

Awesome Lists containing this project

README

          

---
output: github_document
---

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

[![lifecycle](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)
[![Travis-CI Build Status](http://badges.herokuapp.com/travis/mdsumner/nchelper?branch=master&env=BUILD_NAME=trusty_release&label=linux)](https://travis-ci.org/mdsumner/nchelper)
[![Build Status](http://badges.herokuapp.com/travis/mdsumner/nchelper?branch=master&env=BUILD_NAME=osx_release&label=osx)](https://travis-ci.org/mdsumner/nchelper)
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/mdsumner/nchelper?branch=master&svg=true)](https://ci.appveyor.com/project/mdsumner/nchelper)

# nchelper

The goal of nchelper is to provide NetCDF variables as R arrays.

## Installation

You can install nchelper from GitHub with:

```{r gh-installation, eval = FALSE}
# install.packages("devtools")
devtools::install_github("mdsumner/nchelper")
```

## Example

This is an example that reads an inbuilt data set of sea surface temperature.

First, find the file and open the variable "sst" as object `a`.

```{r example}
library(nchelper)
f <- system.file("extdata", "avhrr-only-v2.20180126.nc", package = "nchelper")
a <- nchelper(f, "sst")
dim(a)
names(a)
```

(Even though we asked for the variable "sst", we could also
see other names if there were any available.)

Now use standard indexing idioms to extract data from this 4D array.

```{r four-d}
grcol <- grey(seq(0, 1, length.out = 12))
image(a[,,,], col = grcol)
image(a[400:800, 100:300,,], col = grcol)
plot(a[,360,,] * 0.01, ylim = c(20, 32), type = "l")
```

Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md).
By participating in this project you agree to abide by its terms.