Commit f2a0707b authored by Nicolau Manubens's avatar Nicolau Manubens
Browse files

Integrated ncdf4 required code.

parent 9a20f6b5
......@@ -3,7 +3,8 @@ Title: Tools to Easily Read/Write NetCDF Files into/from Multidimensional R Arra
Version: 0.0.2
Authors@R: c(
person("BSC-CNS", role = c("aut", "cph")),
person("Nicolau", "Manubens", , "nicolau.manubens@bsc.es", role = c("aut", "cre")))
person("Nicolau", "Manubens", , "nicolau.manubens@bsc.es", role = c("aut", "cre")),
person("David", "Pierce", , "david.pierce@ucsd.edu", role = c("ctb")))
Description: Set of wrappers for the 'ncdf4' package to simplify and extend its reading/writing capabilities into/from multidimensional R arrays.
Depends:
R (>= 2.14.1)
......@@ -15,3 +16,4 @@ URL: https://earth.bsc.es/gitlab/es/easyNCDF/wikis/home
BugReports: https://earth.bsc.es/gitlab/es/easyNCDF/issues
LazyData: true
SystemRequirements: netcdf development libraries
NeedsCompilation: yes
useDynLib(easyNCDF)
exportPattern("^[^\\.]")
import(ncdf4, abind)
importFrom("stats", "setNames")
......@@ -203,16 +203,16 @@ NcToArray <- function(file_to_read, dim_indices = NULL, vars_to_read = NULL,
(length(file_object[['var']][[var_name]][['dim']]) > 1)) {
start <- c(1, start)
count <- c(-1, count)
original_ncvar_get_inner <- ncdf4:::ncvar_get_inner
assignInNamespace('ncvar_get_inner', .ncvar_get_inner, 'ncdf4')
##original_ncvar_get_inner <- ncdf4:::ncvar_get_inner
##assignInNamespace('ncvar_get_inner', .ncvar_get_inner, 'ncdf4')
}
var_result <- do.call('[', c(list(ncvar_get(file_object, var_name, start, count, collapse_degen = FALSE)),
var_result <- do.call('[', c(list(.ncvar_get(file_object, var_name, start, count, collapse_degen = FALSE)),
lapply(indices_to_take, function(x) if (is_single_na(x)) TRUE else x - min(x) + 1), list(drop = FALSE)))
# Support for character strings
if ((file_object[['var']][[var_name]][['prec']] == 'char') &&
(length(file_object[['var']][[var_name]][['dim']]) > 1)) {
assignInNamespace('ncvar_get_inner', original_ncvar_get_inner, 'ncdf4')
}
### Support for character strings
##if ((file_object[['var']][[var_name]][['prec']] == 'char') &&
## (length(file_object[['var']][[var_name]][['dim']]) > 1)) {
## assignInNamespace('ncvar_get_inner', original_ncvar_get_inner, 'ncdf4')
##}
#metadata <- c(metadata, structure(list(file_object$var[[var_name]]), .Names = var_name))
names(dim(var_result)) <- names(indices_to_take)
# Drop extra dims
......
This diff is collapsed.
#! /bin/sh
rm -f config.* R/load.R src/Makevars
rm -rf autom4te.cache
This diff is collapsed.
##PKG_CPPFLAGS=-I/path/to/netcdf/header
##PKG_LIBS=-L/path/to/netcdf/lib -lnetcdf
PKG_LIBS=@NETCDF_LDFLAGS@
PKG_CPPFLAGS=@NETCDF_CPPFLAGS@
PKG_LIBS = -lnetcdf4 -L$(LIB_HDF5)/lib${R_ARCH} -lhdf5_hl -lhdf5 -lz
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment