schwilklab / skyisland-climate

Climate data and code for Sky Island project
2 stars 2 forks source link

Bug in lubridate mdy_hms() and TZ (timezone argument) on ms windows #10

Closed dschwilk closed 9 years ago

dschwilk commented 9 years ago

Running read.sensor() in iButton.R causes an error on microsoft windows. The problem disappears if if the optional TZ argument to mdy_hms() is omitted.

traceback:

error: protect(): protection stack overflow

Error: protect(): protection stack overflow 3129 stri_sub<-(*tmp*, from = start, to = end, value = "%S") 3128 str_sub<-(*tmp*, start[w, n], end[w, n], value = "%S") 3127 .substitute_formats(reg, x) 3126 (function (reg, name) { out <- .substitute_formats(reg, x) if (!is.null(out)) ... 3125 mapply(function(reg, name) { out <- .substitute_formats(reg, x) if (!is.null(out)) names(out) <- rep.int(name, length(out)) ... 3124 guess_formats(x, orders, locale = locale, preproc_wday = TRUE) 3123 unique(guess_formats(x, orders, locale = locale, preproc_wday = TRUE)) 3122 .best_formats(train, orders, locale = locale, select_formats) 3121 .local_parse(x[new_na]) 3120 .local_parse(x[new_na]) 3119 .local_parse(x[new_na]) 3118 .local_parse(x[new_na]) 3117 .local_parse(x[new_na]) 3116 .local_parse(x[new_na]) 3115 .local_parse(x[new_na])

.local_parse(x[new_na]) 8 .local_parse(x[to_parse], TRUE) 7 parse_date_time(dates, orders, tz = tz, quiet = quiet, locale = locale) 6 .parse_xxx_hms(..., orders = c("mdyTz", "mdyT"), quiet = quiet, tz = tz, locale = locale, truncated = truncated) 5 mdy_hms(td$Date.Time, tz = Sys.getenv("TZ"), truncated = 1) at iButton.R#55 4 read.sensor(sfiles[i]) at iButton.R#80 3 read.sensor.data(sfiles) at iButton.R#97 2 read.sensor.dir("../microclimate/merged-ibutton/DM/T/") at iButton.R#103'

dschwilk commented 9 years ago

This seems to be this reported lubridate bug which should be fixed in current version

https://github.com/hadley/lubridate/issues/224

Can we test using lubridate installed from github rather than the out-of-date cran version? I'll try this on a windows machine.

dschwilk commented 9 years ago

I can confirm this works now on windows with the latest lubridate. I also needed to change the timezone usage so that we just read in alll times in UTC. That is fine. The problem is that the windows machine on which we downland the ibuttons, tries to convert times based on DST and we cannot turn that off. It does so incorrectly (windoze bug, seems to have been fixed in windows 7 but effects old data).

So I will push the fixed version.

dschwilk commented 9 years ago

I'm closing this. With the change to using "UTC" as timezone in iButton.R, I can run build-sensor-data.sh from a clean clone of the repo on windows 7 as long as the following are installed and in the $PATH:

Only the last line (R and packages) is required to run load-sensor-data.R

@hpoulos When you get a chance can you confirm this works for you?

hpoulos commented 9 years ago

Yes. Monday. No internet this weekend. I have all that on my machine.

On May 14, 2015, at 5:27 PM, Dylan Schwilk notifications@github.com wrote:

I'm closing this. With the change to using "UTC" as timezone in iButton.R, I can run build-sensor-data.sh from a clean clone of the repo on windows 7 as long as the following are installed and in the $PATH:

a working bash (eg git bash) python 2.x (in the path) R with lubridate 1.3.3, xts, plyr, and ggplot2 Only the last line (R and packages) is required to run load-sensor-data.R

@hpoulos When you get a chance can you confirm this works for you?

— Reply to this email directly or view it on GitHub.