Folkes, Michael
2011-Sep-24 23:06 UTC
[R] maptools::sunriset() daylight savings to stardard time change
Hello all,
After beating my head against the wall for a few hours, I give up.
I have two problems.
1. If I use seq() to generate a POSIXct series that crosses a daylight savings
to stardard time change I get two values for the first day of change. The time
change is Nov 6,2011. The value for Nov 7 turns into 23:00 on Nov 6, thus two
values for Nov 6. (see below)
So I put a time value (noon) into the sequence, that did give me a correct date
sequence.
2. When using that modified date sequence in maptools::sunriset(), on day of
change to stardard time the sunrise time is shifted by one hour. (i.e. Nov5 8am,
Nov6 6am, Nov7 7am)
I can't fathom why sunriset() is giving me funny results on the day of time
change. I wonder if there is something amiss with how my windows XP is managing
time zones perhaps? I would have expected sunriset() to be using just the day
value from its dateTime argument, not the time component?
thanks!
Michael
__________________________
start <- as.POSIXct("2011-11-05")
end <- as.POSIXct("2011-11-07")
date.ser<-seq(start,end,by='day')
# time change is Nov 6,2011
date.ser
##### Two values for Nov 6 as Nov 7th lost an hour.
[1] "2011-11-05 00:00:00 PDT" "2011-11-06 00:00:00 PDT"
[3] "2011-11-06 23:00:00 PST"
### Add noon to correct flexibility for time shift.
start <- as.POSIXct("2011-11-05 12:00:00")
end <- as.POSIXct("2011-11-07 12:00:00")
date.ser<-seq(start,end,by='day')
date.ser
[1] "2011-11-05 12:00:00 PDT" "2011-11-06 11:00:00 PST"
[3] "2011-11-07 11:00:00 PST"
library(maptools)
nanaimo <- matrix(c(-123+(-57/60),49+11/60), nrow=1)
sunriset(nanaimo, date.ser, direction="sunrise", POSIXct.out=T)[,2]
[1] "2011-11-05 08:09:42 PDT" "2011-11-06 06:11:19 PST"
[3] "2011-11-07 07:12:56 PST"
_______________________________________________________
Michael Folkes
Salmon Stock Assessment
Canadian Dept. of Fisheries & Oceans
Pacific Biological Station
3190 Hammond Bay Rd.
Nanaimo, B.C., Canada
V9T-6N7
Ph (250) 756-7264 Fax (250) 756-7053 Michael.Folkes@dfo-mpo.gc.ca
[[alternative HTML version deleted]]
Jeff Newmiller
2011-Sep-25 04:27 UTC
[R] maptools::sunriset() daylight savings to stardard time change
Sys.setenv(TZ="Etc/GMT+8") will use standard time only for time
calculations.
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnewmil@dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.
"Folkes, Michael" <Michael.Folkes@dfo-mpo.gc.ca> wrote:
Hello all,
After beating my head against the wall for a few hours, I give up.
I have two problems.
1. If I use seq() to generate a POSIXct series that crosses a daylight savings
to stardard time change I get two values for the first day of change. The time
change is Nov 6,2011. The value for Nov 7 turns into 23:00 on Nov 6, thus two
values for Nov 6. (see below)
So I put a time value (noon) into the sequence, that did give me a correct date
sequence.
2. When using that modified date sequence in maptools::sunriset(), on day of
change to stardard time the sunrise time is shifted by one hour. (i.e. Nov5 8am,
Nov6 6am, Nov7 7am)
I can't fathom why sunriset() is giving me funny results on the day of time
change. I wonder if there is something amiss with how my windows XP is managing
time zones perhaps? I would have expected sunriset() to be using just the day
value from its dateTime argument, not the time component?
thanks!
Michael
__________________________
start <- as.POSIXct("2011-11-05")
end <- as.POSIXct("2011-11-07")
date.ser<-seq(start,end,by='day')
# time change is Nov 6,2011
date.ser
##### Two values for Nov 6 as Nov 7th lost an hour.
[1] "2011-11-05 00:00:00 PDT" "2011-11-06 00:00:00 PDT"
[3] "2011-11-06 23:00:00 PST"
### Add noon to correct flexibility for time shift.
start <- as.POSIXct("2011-11-05 12:00:00")
end <- as.POSIXct("2011-11-07 12:00:00")
date.ser<-seq(start,end,by='day')
date.ser
[1] "2011-11-05 12:00:00 PDT" "2011-11-06 11:00:00 PST"
[3] "2011-11-07 11:00:00 PST"
library(maptools)
nanaimo <- matrix(c(-123+(-57/60),49+11/60), nrow=1)
sunriset(nanaimo, date.ser, direction="sunrise", POSIXct.out=T)[,2]
[1] "2011-11-05 08:09:42 PDT" "2011-11-06 06:11:19 PST"
[3] "2011-11-07 07:12:56 PST"
_____________________________________________
Michael Folkes
Salmon Stock Assessment
Canadian Dept. of Fisheries & Oceans
Pacific Biological Station
3190 Hammond Bay Rd.
Nanaimo, B.C., Canada
V9T-6N7
Ph (250) 756-7264 Fax (250) 756-7053 Michael.Folkes@dfo-mpo.gc.ca
[[alternative HTML version deleted]]
_____________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
Prof Brian Ripley
2011-Sep-25 07:01 UTC
[R] maptools::sunriset() daylight savings to stardard time change
On Sat, 24 Sep 2011, Folkes, Michael wrote:> Hello all, > After beating my head against the wall for a few hours, I give up. > I have two problems. > 1. If I use seq() to generate a POSIXct series that crosses a daylight savings to stardard time change I get two values for the first day of change. The time change is Nov 6,2011. The value for Nov 7 turns into 23:00 on Nov 6, thus two values for Nov 6. (see below) > So I put a time value (noon) into the sequence, that did give me a correct date sequence.That is as documented. Did you actually read the help page, which says The difference between ?"day"? and ?"DSTday"? is that the former ignores changes to/from daylight savings time and the latter takes the same clock time each day. So you asked to increment the clock by 24 hours and not to the same time the next day. I cannot reproduce your results as you have not told us your timezone, but I can guess America/Vancouver> seq(start,end,by='day')[1] "2011-11-05 00:00:00 PDT" "2011-11-06 00:00:00 PDT" [3] "2011-11-06 23:00:00 PST"> seq(start,end,by='DSTday')[1] "2011-11-05 PDT" "2011-11-06 PDT" "2011-11-07 PST"> > 2. When using that modified date sequence in maptools::sunriset(), on day of change to stardard time the sunrise time is shifted by one hour. (i.e. Nov5 8am, Nov6 6am, Nov7 7am) > I can't fathom why sunriset() is giving me funny results on the day of time change. I wonder if there is something amiss with how my windows XP is managing time zones perhaps? I would have expected sunriset() to be using just the day value from its dateTime argument, not the time component? > thanks! > Michael > > __________________________ > > start <- as.POSIXct("2011-11-05") > end <- as.POSIXct("2011-11-07") > date.ser<-seq(start,end,by='day') > # time change is Nov 6,2011 > date.ser > ##### Two values for Nov 6 as Nov 7th lost an hour. > [1] "2011-11-05 00:00:00 PDT" "2011-11-06 00:00:00 PDT" > [3] "2011-11-06 23:00:00 PST" > > > ### Add noon to correct flexibility for time shift. > start <- as.POSIXct("2011-11-05 12:00:00") > end <- as.POSIXct("2011-11-07 12:00:00") > date.ser<-seq(start,end,by='day') > date.ser > [1] "2011-11-05 12:00:00 PDT" "2011-11-06 11:00:00 PST" > [3] "2011-11-07 11:00:00 PST" > > library(maptools) > nanaimo <- matrix(c(-123+(-57/60),49+11/60), nrow=1) > sunriset(nanaimo, date.ser, direction="sunrise", POSIXct.out=T)[,2] > [1] "2011-11-05 08:09:42 PDT" "2011-11-06 06:11:19 PST" > [3] "2011-11-07 07:12:56 PST" > > _______________________________________________________ > Michael Folkes > Salmon Stock Assessment > Canadian Dept. of Fisheries & Oceans > Pacific Biological Station > 3190 Hammond Bay Rd. > Nanaimo, B.C., Canada > V9T-6N7 > Ph (250) 756-7264 Fax (250) 756-7053 Michael.Folkes at dfo-mpo.gc.ca > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595