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

     Version 1.1-6:

     (i) Correction to the wave number in 'dX' and 'dY' - previously
     wave number was scaled as 1/[number of points] and gave incorrect
     magnitudes for the derivatives, but now the wave number is
     1/distance.

     (ii) Included a simple confidence check (chk.conf) to set
     coefficients to zero when +- 1 sd includes zero. This check can be
     disabled. Note, it is recommended to use the minimum value for
     maxhar.

     (iii) Included new test routines to test the magnitudes of the
     gradients.

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

     dX(lon,lat,Z,r=6.378e06,maxhar=NULL,mask.bad=TRUE,plot=FALSE,chk.conf=1)
     dY(lon,lat,Z,r=6.378e06,maxhar=NULL,mask.bad=TRUE,plot=FALSE,chk.conf=1)
     dT(y,maxhar=NULL,plot=FALSE,chk.conf=1)
     test.dX(field=NULL,maxhar=7)
     test.dY(field=NULL,maxhar=5)
     test.dT(y=NULL,maxhar=15)

_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

   field: Field to which the test is applied (default: DNMI.slp)

chk.conf: If not NULL, test whether conf. int. (+- chk.conf * sd)
          includes zero - if so, set coefficient to zero.

_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)

