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)

