dX                 package:cyclones                 R Documentation

_F_i_r_s_t _d_e_r_i_v_a_t_i_v_e_s _f_r_o_m _h_a_r_m_o_n_i_c _f_i_t_s.

_D_e_s_c_r_i_p_t_i_o_n:

     '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'.

_U_s_a_g_e:

     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)

_A_r_g_u_m_e_n_t_s:

     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

_V_a_l_u_e:

     A list: list(Z=Z,a=a,b=b,c=c,dZ=dZ,Z.fit=Z.fit,lon=lon,lat=lat) of
     class "map"

_A_u_t_h_o_r(_s):

     R.E. Benestad

_E_x_a_m_p_l_e_s:

     # 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)

