Commit 6a898d91 authored by Franssen, Wietse's avatar Franssen, Wietse
Browse files

Some small improvements

parent 6428476b
#' @keywords internal
.PRINT_INFO<-TRUE
#' blabla a test primt message
#'
#' @param none (yet)
......@@ -20,10 +23,10 @@ plotje <-function(data, title = " ") {
#' @author Wietse Franssen \email{wietse.franssen@wur.nl}
#' @export
#' @keywords internal
ncPlot <-function(file) {
data<-ncLoad(file)
ncPlot <-function(file, varName = "pr") {
data<-ncLoad(file, varName)
plotje(data, title = paste0(data$Variable$varName, " (" ,data$Dates$start[1], ")"))
return(data)
#return(data)
}
#' Shows a test primt message
......@@ -45,15 +48,58 @@ rDataStructure <-function() {
return(rData)
}
ncCheck <-function(ncFile, variable) {
result<-NULL
result$xFlip<-FALSE
result$yFlip<-FALSE
result$dims<-FALSE
result$dimids<-FALSE
result$tArray<-FALSE
lons <-ncFile$dim$lon$vals
lats <-ncFile$dim$lat$vals
times <-ncFile$dim$time$vals
# what is the order of the variable dimensions:
for (i in 1:length(ncFile$var[[variable]]$dimids)) {
result$dims[i]<-ncFile$dim[[i]]$name
result$dimids[i]<-ncFile$dim[[i]]$id
}
if (length(times) > 1) { result$tArray<-TRUE }
if ((lons[2]-lons[1]) < 0) { result$xFlip<-TRUE }
if ((lats[2]-lats[1]) < 0) { result$yFlip<-TRUE }
return(result)
}
#' blabla a test primt message
#'
#' @param none (yet)
#' @details The function
#' @return blabla
#' @author Wietse Franssen \email{wietse.franssen@@wur.nl}
#' @export
#' @argument title
#' @keywords internal
ncLoad <-function(file, varName = "pr") {
#dat<-ncLoad(file = "~/Desktop/gg/wfd_pr_1974.nc" )
#data<-ncLoad(file = "~/Desktop/gg/wfd_pr_1974.nc" )
data<-rDataStructure()
ncFile <- nc_open( file )
ncCheckResult<-ncCheck(ncFile = ncFile, variable = varName)
data$xyCoords$x <- ncFile$dim$lon$vals
data$xyCoords$y <- ncFile$dim$lat$vals
if (.PRINT_INFO == TRUE) {
cat("Variables:\n")
print(names(ncFile$var))
cat("yeah!\n")
print(ncCheckResult)
#print(ncFile)
}
NCtime <- ncvar_get( ncFile, "time" )
NCtimeAtt <- ncatt_get( ncFile, "time", "units" )$value
......
Supports Markdown
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