[Rodbcext-commits] r26 - pkg/geoclimate/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jul 16 07:25:16 CEST 2012


Author: jaunario
Date: 2012-07-16 07:25:16 +0200 (Mon, 16 Jul 2012)
New Revision: 26

Modified:
   pkg/geoclimate/R/trmm.r
Log:
Corrected some lines in get.trmm

Modified: pkg/geoclimate/R/trmm.r
===================================================================
--- pkg/geoclimate/R/trmm.r	2012-07-16 01:35:41 UTC (rev 25)
+++ pkg/geoclimate/R/trmm.r	2012-07-16 05:25:16 UTC (rev 26)
@@ -42,13 +42,13 @@
 		file.remove(paste(savepath,fname,sep="/"))
 		rawtrmm <- withRetry(getBinaryURL(prod.ftp),...)
 	} else if (file.exists(paste(savepath,fname,sep="/"))){
-		rawtrmm <- getBinaryURL(paste("file://localhost", normalizePath(savepath), fname, sep="/"))		
+		rawtrmm <- getBinaryURL(paste("file://localhost", normalizePath(savepath), fname, sep="/"))			
 	} else {
 		rawtrmm <- withRetry(getBinaryURL(prod.ftp),...)
 	}
-	if (class(rawtrmm)!="try-error") stop(rawtrmm)
+	if (class(rawtrmm)=="try-error") stop(rawtrmm)
 	
-	if (class(savepath)=="character") writeBin(rawtrmm, paste(savepath,fname,sep="/"))
+	if (class(savepath)=="character" & rm.existing) writeBin(rawtrmm, paste(savepath,fname,sep="/"))
 	
 	baseraster <- raster(extent(-180,180,-50,50))
 	res(baseraster) <- 0.25
@@ -58,16 +58,17 @@
 	prec <- prec[nrow(prec):1,]
 	
 	baseraster[] <- prec
-	prec <- values(baseraster)
 	cell <- 1:ncell(baseraster)
 	wth <- new("weather")
 	wth at stn <- "Tropical Rainfall Measuring Mission"
     wth at rmk <- prod.ftp
 	wth at lon <- c(-180,180)
 	wth at lat <- c(-50,50)
-	wth at w <- as.data.frame(prec)
-	wth at w <- cbind(cell,wdate,wth at w)
-	
+	wth at w <- as.data.frame(cell)
+	wth at w$wdate <- wdate
+	wth at w$prec <- values(baseraster)
+	rm(baseraster, prec, cell)
+	gc(verbose=FALSE)
 	return(wth)
 }
 



More information about the Rodbcext-commits mailing list