[Rodbcext-commits] r49 - in pkg/geoclimate: . R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Dec 19 03:50:54 CET 2013
Author: jaunario
Date: 2013-12-19 03:50:53 +0100 (Thu, 19 Dec 2013)
New Revision: 49
Modified:
pkg/geoclimate/DESCRIPTION
pkg/geoclimate/R/fse.r
Log:
Fixed bugs for FSE reading
Modified: pkg/geoclimate/DESCRIPTION
===================================================================
--- pkg/geoclimate/DESCRIPTION 2013-11-20 02:35:58 UTC (rev 48)
+++ pkg/geoclimate/DESCRIPTION 2013-12-19 02:50:53 UTC (rev 49)
@@ -1,7 +1,7 @@
Package: geoclimate
Type: Package
Title: Climate and Weather Data Processing at the IRRI GIS Laboratory
-Version: 0.0.21
+Version: 0.0.23
Date: 2013-6-4
Depends: methods, genutils, oldweather, RODBC
Suggests: RCurl, ncdf
Modified: pkg/geoclimate/R/fse.r
===================================================================
--- pkg/geoclimate/R/fse.r 2013-11-20 02:35:58 UTC (rev 48)
+++ pkg/geoclimate/R/fse.r 2013-12-19 02:50:53 UTC (rev 49)
@@ -4,7 +4,7 @@
# Licence GPL v3
# Read and Write FSE weather files
-read.fse <- function(fsefile, datacols=c("station_id", "year", "doy", "srad", "tmin", "tmax", "vapr","wind","prec"), delim=" ", skip.hdr=FALSE){
+read.fse <- function(fsefile, datacols=c("station_id", "year", "doy", "srad", "tmin", "tmax", "vapr","wind","prec"), delim=" ", skip.hdr=FALSE, std.vals=TRUE){
fsewth <- new("weather")
is.sunshine <- FALSE
@@ -50,6 +50,8 @@
# get coordinates
coords <- as.numeric(unlist(strsplit(trim(dlines[max(ihdr)+1]),delim)))
+ coords <- coords[!is.na(coords)]
+
rm(dlines)
gc(verbose=FALSE)
@@ -61,10 +63,15 @@
#dmatrix[dmatrix==-9999] <- NA
#dmatrix <- as.data.frame(dmatrix)
- dmatrix <- read.table(fsefile, skip=max(ihdr)+1, stringsAsFactors=FALSE, sep=delim)
+ if(delim==" " | delim==""){
+ dmatrix <- read.table(fsefile, skip=max(ihdr)+1, stringsAsFactors=FALSE)
+ } else {
+ dmatrix <- read.table(fsefile, skip=max(ihdr)+1, stringsAsFactors=FALSE, sep=delim)
+ }
+
colnames(dmatrix) <- datacols
- if(!skip.hdr){
+ if(!skip.hdr & std.vals){
# CHECK RADIATION UNITS THEN CONVERT TO MEGAJOULE/SQM/DAY IF NECESSARY
# Check if sunshine hours/duration
More information about the Rodbcext-commits
mailing list