Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
jbedia committed Apr 18, 2017
2 parents cea058e + 27e8076 commit 5c554ac
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Suggests:
downscaleR
Type: Package
Title: R Package for Climate Data Loading and Manipulation
Version: 1.0.8
Date: 2017-04-11
Version: 1.0.9
Date: 2017-04-18
Authors@R: as.person(c(
"Santander Meteorology Group <http://meteo.unican.es> [aut]",
"Joaquin Bedia <[email protected]> [ctb,cre]",
Expand Down
4 changes: 2 additions & 2 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
loadeR
======

* Bug fix in dictionary parsing for single nc file datasets
* Removed RCurl dependency
* Bug fix in `loadStationData`
* Bug fix in stations data inventory
* Other minor enhancements and documentation updates

9 changes: 6 additions & 3 deletions R/dataInventory.R
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,17 @@ dataInventory.ASCII <- function(dataset, rs) {
rm(list = c("lon", "lat"))
other.metadata <- as.list(stations[ ,-pmatch(c("station_id", "longitude", "latitude"), names(stations))])
station.info <- list("station_id" = station_id, "LonLatCoords" = LonLatCoords, "times" = timeAxis, "other.metadata" = other.metadata)
rm(station_id, timeAxis, LonLatCoords, other.metadata)
station_id <- timeAxis <- LonLatCoords <- other.metadata <- NULL
info <- list("Stations" = station.info, "Variables" = var.info, "Summary.stats" = NULL)
if (isTRUE(rs)) {
na.perc <- function(x) {round(length(which(is.na(x))) * 100 / length(x), 1)}
aux.mat <- matrix(ncol = nrow(vars), nrow = length(station.info$station_id), dimnames = list(station.info$station_id, vars[ ,grep("variable", names(vars), ignore.case = TRUE)]))
stats.list <- list("missing.percent" = aux.mat, "min" = aux.mat, "max" = aux.mat, "mean" = aux.mat)
for (i in 1:nrow(vars)) {
var <- read.csv(lf[grep(paste("^", var.info[i,1], "\\.*", sep = ""), list.files(dataset))], na.strings = var.info$missing.code[i])[ ,-1]
lf <- list.files(dataset)
lff <- list.files(dataset, full.names = TRUE)
for (i in 1:nrow(var.info)) {
varfile <- lff[grep(paste0("^", var.info[i,1], "\\."), lf)]
var <- read.csv(varfile, na.strings = var.info$missing.code[i])[ ,-1]
stats.list[[1]][ ,i] <- apply(var, 2, na.perc)
stats.list[[2]][ ,i] <- apply(var, 2, min, na.rm = TRUE)
stats.list[[3]][ ,i] <- apply(var, 2, max, na.rm = TRUE)
Expand Down
2 changes: 1 addition & 1 deletion R/loadStationData.R
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ loadStationData.ASCII <- function(dataset, var, stationID, lonLim, latLim, seaso
stids <- stids[stInd]
dimnames(coords) <- list(stids, c("longitude", "latitude"))
## Time dimension
fileInd <- grep(paste0("^", var, "\\.txt$"), dirContents)
fileInd <- grep(paste0(var, "\\.txt$"), dirContents)
if (length(fileInd) == 0) {
stop("[", Sys.time(),"] Variable requested not found", call. = FALSE)
}
Expand Down

0 comments on commit 5c554ac

Please sign in to comment.