[R] maptools sunrise sunset function

stephen sefick ssefick at gmail.com
Mon Nov 10 20:51:52 CET 2008


I have looked at the timezone documentation
?POSIXct
and can not figure it out....
maybe it would be good to ask this specifically on the list....
this function is going to be included in the next update of the
package StreamMetabolism

Stephen Sefick

On Mon, Nov 10, 2008 at 2:20 PM, Farley, Robert <FarleyR at metro.net> wrote:
> I have a time zone problem.
>
> Running the code provided I get the result in UTC, and a lot of warnings
> like this:
> 28: In as.POSIXlt.POSIXct(x, tz) ... : unknwon timezone 'PST'
>
>
>
>
>> sunrise.set(34.11583, -118.18719, "2008-11-14")
>                   sunrise              sunset
> newlon 2008-11-14 14:25:02 2008-11-15 00:49:09
>>
>> Sys.timezone()
> [1] "PST"
>>
> The result is equivalent to 06:25:02 16:49:09 {PST = UTC-8}
> The "correct" values from another source show 06:25 16:50 which agree to
> beyond the accuracy of prediction due to atmospheric uncertainty.
>
>
> How SHOULD I specify the TZ?  I would think that PST is a pretty
> "standard" ;-) time zone.
>
>
>
>
> Yes, I steal a lot of code snippets.  I justify it by telling myself it
> helps me learn R.
>
>
>
>
>
>
> Robert Farley
> Metro
> www.Metro.net
>
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
> On Behalf Of stephen sefick
> Sent: Saturday, November 08, 2008 17:09
> To: R-help
> Subject: Re: [R] maptools sunrise sunset function
>
> Nevermind, when one puts in the proper coordinates in decimal degrees
> everything works just fine.
> thanks for you patience,
>
> Stephen
>
> On Sat, Nov 8, 2008 at 7:40 PM, stephen sefick <ssefick at gmail.com>
> wrote:
>> ##This is a function that I am trying to write to calculate sunrise
>> and sunset and works "mostly", but returns nonsensical values.  What
>> am I #missing?  Thanks in advance.
>>
>> ###remember to include maptools as dependence###
>> library(maptools)
>> sunrise.set <- function(lat, long, date, timezone="UTC", num.days=1){
>>        #this needs to be long lat#
>>        lat.long <- matrix(c(long, lat), nrow=1)
>>        day <- as.POSIXct(date, tz=timezone)
>>        sequence <- seq(from=day, length.out=num.days , by="days")
>>        sunrise <- sunriset(lat.long, sequence, direction="sunrise",
> POSIXct=TRUE)
>>        sunset <- sunriset(lat.long, sequence, direction="sunset",
> POSIXct=TRUE)
>>        ss <- data.frame(sunrise, sunset)
>>        ss <- ss[,-c(1,3)]
>>        colnames(ss)<-c("sunrise", "sunset")
>>        return(ss)
>> }
>>
>> #This doesn't make any sense
>> sunrise.set(33.46, 84.25, "2008-11-08", timezone="EST")
>>
>>
>> --
>> Stephen Sefick
>> Research Scientist
>> Southeastern Natural Sciences Academy
>>
>> Let's not spend our time and resources thinking about things that are
>> so little or so large that all they really do for us is puff us up and
>> make us feel like gods.  We are mammals, and have not exhausted the
>> annoying little problems of being mammals.
>>
>>                                                                -K.
> Mullis
>>
>
>
>
> --
> Stephen Sefick
> Research Scientist
> Southeastern Natural Sciences Academy
>
> Let's not spend our time and resources thinking about things that are
> so little or so large that all they really do for us is puff us up and
> make us feel like gods.  We are mammals, and have not exhausted the
> annoying little problems of being mammals.
>
>                                                                -K.
> Mullis
>
> ______________________________________________
> 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.
>
>



-- 
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

								-K. Mullis



More information about the R-help mailing list