Skip to content

Commit

Permalink
release
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsumner committed Mar 25, 2024
1 parent 6eb3f9a commit 8046ed8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 39 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ncmeta
Title: Straightforward 'NetCDF' Metadata
Version: 0.3.6
Version: 0.4.0
Authors@R: c(person("Michael", "Sumner", email = "[email protected]", role = c("aut", "cre")),
person("Tomas", "Remenyi", role = "ctb"),
person("Ben", "Raymond", role = "ctb"),
Expand All @@ -15,7 +15,7 @@ Description: Extract metadata from 'NetCDF' data sources, these can be files, fi
Depends: R (>= 3.3.0)
License: GPL-3
Encoding: UTF-8
RoxygenNote: 7.2.3
RoxygenNote: 7.3.0
Imports:
dplyr,
rlang,
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# ncmeta 0.4.0

* New function `nc_extended()` to enerate a table of extended dimension attributes, supporting 'time' currently (contributed by Patrick Van Laake).

# ncmeta 0.3.6

* Fixed namespace doc thanks to CRAN.
Expand Down
32 changes: 3 additions & 29 deletions R/nc_extended.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ nc_extended <- function(x, ...) {
#' @export
nc_extended.character <- function(x, ...) {
if (nchar(x) < 1) stop("NetCDF source cannot be empty string")

if (file.exists(x)) x <- normalizePath(x)
nc <- RNetCDF::open.nc(x)
on.exit(RNetCDF::close.nc(nc), add = TRUE)
nc_extended(nc)
Expand Down Expand Up @@ -55,33 +55,7 @@ nc_extended.NetCDF <- function(x, ...) {
#' @name nc_extended
#' @export
nc_extended.ncdf4 <- function(x, ...) {
if (x$ndims == 0) return(tibble::tibble())

## Add time information for any "time" dimension. Since not all files have a
## "calendar" attribute or "axis == "T"", just try to create a CFtime
## instance for any dimension variable with a "units" attribute and a
## "calendar", if present.
cftime <- lapply(x$dim, function(d) {
units <- d$units
if (!is.null(units) && nchar(units) >= 8) {
try({
# Create cheap bare-bones instance, to see if units represent time
cf <- CFtime::CFtime(units, d$calendar)

# If we get here we have a CFtime instance, so now add offsets.
# NetCDF file may have been opened with suppress_dimvals = T or
# readunlim = F so test if we have vals as dim element.
if (!is.null(d$vals)) off <- d$vals
else off <- ncvar_get(x, d$name)
return(cf + as.vector(off))
}, silent = TRUE)
}
return (NA)
})

## Any other extended attributes to be added here

## Output
tibble::tibble(dimension = sapply(x$dim, function(d) d$id), name = sapply(x$dim, function(d) d$name), time = cftime)
## we don't support ncdf4 so pass to RNetCDF
nc_extended(RNetCDF::open.nc(x$filename))
}

11 changes: 3 additions & 8 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Release 0.3.5 of ncmeta
# Release 0.4.0 of ncmeta

Fix downstream problems tidync and other revdeps where extra metadata was not handled by dataframe structure.
New function `nc_extended()`.

## Test environments

* local ubuntu
* win-builder (devel and release)
* mac-builder (release)

## R CMD check results

Expand All @@ -16,9 +17,3 @@ Fix downstream problems tidync and other revdeps where extra metadata was not ha

The reverse dependencies pass check with this version.

* ncdfgeom
* oceanexplorer
* tidync
* sftime
* stars

1 change: 1 addition & 0 deletions man/ncmeta-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8046ed8

Please sign in to comment.