https://github.com/cran/season
Tip revision: 701555cec49b28bddc366751dbb586cb01ba4485 authored by Adrian Barnett on 17 January 2012, 00:00:00 UTC
version 0.3-1
version 0.3-1
Tip revision: 701555c
phasecalc.R
# phasecalc.R
# calculate phase given cosine and sine estimates
# returns results on scale [0,2pi]
# equivalent to page 31 of Fisher
phasecalc<-function(cosine,sine){
if(cosine==0){cosine=cosine+0.000000001} # avoid zeros
div<- sine/cosine
if (cosine>=0){phaser<-atan(div)}
if (cosine<0&sine>=0){phaser<-atan(div)+pi}
if (cosine<0&sine<0){phaser<-atan(div)-pi}
# put in 0 to 2pi range
if (phaser<0) { phaser<-phaser+(2*pi)}
if (phaser>(2*pi)) { phaser<-phaser-(2*pi)}
return(phaser)
}