dX {cyclones} | R Documentation |
dX
calculates the x-derivatives for gridded data in
longitude-latitude coordinates. Is based on the equations by Stephenson (1961) p. 162
dA/dx = 1/(r cos(PHI)) * d/dTHETA
where PHI is the latitude in radians and THETA the longitude.
dY
calculates the y-derivatives for gridded data in longitude-latitude coordinates.
dA/dy= 1/r d/dPHI
.
dT
calculates the e.g. time derivatives of a time series.
All functions solve for the gradients by fitting coeffiecients to a Fourier approximation
p(x) = a0 + sum(a[i] cos(w[i]*x) + b[i]sin(w[i]*x))
and dp(x)/dx is
dp(x)/dx = sum(w[i](-a[i] sin(w[i]*x) + b[i]cos(w[i]*x)))
Also see derivFFT
.
dX(lon,lat,Z,r=6.378e06,maxhar=NULL,mask.bad=TRUE,plot=FALSE) dY(lon,lat,Z,r=6.378e06,maxhar=NULL,mask.bad=TRUE,plot=FALSE) dT(y,maxhar=NULL,plot=FALSE)
lon |
Longitudes |
lat |
Latitude |
Z |
Field values of which the gradients are sought |
r |
mean radius of Earth |
maxhar |
Number of harmonics to include. If NULL, maxhar is set to the length of the series. |
mask.bad |
|
y |
a time series (vector). |
plot |
plot data and fit |
A list: list(Z=Z,a=a,b=b,c=c,dZ=dZ,Z.fit=Z.fit,lon=lon,lat=lat) of class "map"
R.E. Benestad
# Construct a test series: t <- seq(-3,3,by=0.1) nt <- length(t) y <- 2*rnorm(nt) + 10*sin(t/4) - 7*sin(t/3) + 4*cos(t) - sin(2*t) + 2*cos(3*t) + 0.5*sin(4*t) plot(y) dydt <- dT(y) lines(dydt$y.fit,col="red") dydt.2 <- dT(y,maxhar=3) lines(dydt.2$y.fit,col="blue",lty=2) # First derivative plot(dydt$dy,type="l") lines(dydt.2$dy,col="blue",lty=2) # Second derivative dy2dt2<-dT(dydt$dy) dy2dt2.2<-dT(dydt.2$dy) plot(dy2dt2$dy,type="l") lines(dy2dt2.2$dy,col="blue",lty=2)