Skip to content
Snippets Groups Projects
Commit fd67281f authored by Blodgett, David L.'s avatar Blodgett, David L.
Browse files

check issues

parent 2fa8c544
No related branches found
No related tags found
No related merge requests found
Pipeline #27681 passed
......@@ -17,4 +17,4 @@ License: CC0
LazyData: TRUE
Encoding: UTF-8
VignetteBuilder: knitr
RoxygenNote: 6.1.1
RoxygenNote: 7.1.1
#'@title Read NetCDF-CF timeSeries featuretype
#'
#'@param nc_file character file path to the nc file to be read.
#'@param read_data logical whether to read metadata only or not.
#'
#'@return list containing the contents of the NetCDF file.
#'
......@@ -67,12 +68,12 @@ check_timeseries_atts <- function(nc_atts) {
}
# Check important global atts
check <- filter(nc_atts, variable == "NC_GLOBAL" & name == 'Conventions')$value
check <- filter(nc_atts, .data$variable == "NC_GLOBAL" & .data$name == 'Conventions')$value
if(length(check) == 0 || !grepl('CF', check)) {
warning('File does not advertise CF conventions, unexpected behavior may result.')
}
check <- filter(nc_atts, variable == "NC_GLOBAL" & name == "featureType")$value
check <- filter(nc_atts, .data$variable == "NC_GLOBAL" & .data$name == "featureType")$value
if(length(check) == 0 || !grepl('timeSeries', check)) {
warning('File does not advertise use of the CF timeseries featureType, unexpected behavior may result.')
}
......@@ -210,10 +211,10 @@ get_nc_list <- function(nc, dsg, nc_meta, read_data) {
get_timeseries_id <- function(nc_atts) {
# Look for variable with the timeseries_id in it.
timeseries_id <- filter(nc_atts, name == "standard_name" &
value == "station_id")$variable
timeseries_id <- filter(nc_atts, name == "cf_role" &
value == pkg.env$timeseries_id_cf_role)$variable
timeseries_id <- filter(nc_atts, .data$name == "standard_name" &
.data$value == "station_id")$variable
timeseries_id <- filter(nc_atts, .data$name == "cf_role" &
.data$value == pkg.env$timeseries_id_cf_role)$variable
if(length(timeseries_id) == 0) {
stop('A timeseries id variable was not found in the file.')
......@@ -236,6 +237,8 @@ get_coord_vars <- function(nc) {
coord_vars[!is.na(coord_vars)]
}
.data <- NULL
add_globals <- function(nc_list, nc_meta) {
nc_list$global_attributes$nc_summary <- filter(nc_meta$attribute, .data$variable == "NC_GLOBAL" &
.data$name == "summary")$value
......
......@@ -4,10 +4,12 @@
\alias{read_timeseries_dsg}
\title{Read NetCDF-CF timeSeries featuretype}
\usage{
read_timeseries_dsg(nc_file)
read_timeseries_dsg(nc_file, read_data = TRUE)
}
\arguments{
\item{nc_file}{character file path to the nc file to be read.}
\item{read_data}{logical whether to read metadata only or not.}
}
\value{
list containing the contents of the NetCDF file.
......
......@@ -4,8 +4,13 @@
\alias{write_attribute_data}
\title{Write attribute data to NetCDF-CF}
\usage{
write_attribute_data(nc_file, att_data, instance_dim_name = "instance",
units = rep("unknown", ncol(att_data)), overwrite = FALSE)
write_attribute_data(
nc_file,
att_data,
instance_dim_name = "instance",
units = rep("unknown", ncol(att_data)),
overwrite = FALSE
)
}
\arguments{
\item{nc_file}{\code{character} file path to the nc file to be created.
......@@ -35,7 +40,7 @@ example_file <-write_attribute_data(tempfile(), sample_data,
try({
ncdump <- system(paste("ncdump -h", example_file), intern = TRUE)
cat(ncdump ,sep = "\\n")
cat(ncdump ,sep = "\n")
}, silent = TRUE)
}
......@@ -4,8 +4,12 @@
\alias{write_geometry}
\title{Write geometries and attributes to NetCDF-CF}
\usage{
write_geometry(nc_file, geom_data, instance_dim_name = NULL,
variables = list())
write_geometry(
nc_file,
geom_data,
instance_dim_name = NULL,
variables = list()
)
}
\arguments{
\item{nc_file}{\code{character} file path to the nc file to be created.}
......@@ -35,7 +39,7 @@ hucPolygons_nc <- ncdfgeom::write_geometry(nc_file=tempfile(),
geom_data = hucPolygons)
try({
ncdump <- system(paste("ncdump -h", hucPolygons_nc), intern = TRUE)
cat(ncdump ,sep = "\\n")
cat(ncdump ,sep = "\n")
}, silent = TRUE)
}
......
......@@ -4,11 +4,22 @@
\alias{write_timeseries_dsg}
\title{Write time series to NetCDF-CF}
\usage{
write_timeseries_dsg(nc_file, instance_names, lats, lons, times, data,
alts = NA, data_unit = "", data_prec = "double",
write_timeseries_dsg(
nc_file,
instance_names,
lats,
lons,
times,
data,
alts = NA,
data_unit = "",
data_prec = "double",
data_metadata = list(name = "data", long_name = "unnamed data"),
time_units = "days since 1970-01-01 00:00:00", attributes = list(),
add_to_existing = FALSE, overwrite = FALSE)
time_units = "days since 1970-01-01 00:00:00",
attributes = list(),
add_to_existing = FALSE,
overwrite = FALSE
)
}
\arguments{
\item{nc_file}{\code{character} file path to the nc file to be created.}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment