optint               package:clim.pact               R Documentation

_O_p_t_i_m_u_m _i_n_t_e_r_p_o_l_a_t_i_o_n

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

     Solves for w in:

                   sum_j(M_ij w_ik) = <pi_j pi_k>.


     Then computes a correction: 

                              r = w_i q,

     where q = gridded observations - first guess.

     Reference: Reynolds and Smith (1994), Improved global sea surface
     temperature analysis using optimum interpolation, J. Climate,  vol
     7, 929-948.

     NB: The testing of this routine is not yet finished - there may
     still be some bugs in this function.

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

     optint(lon,lat,obs,lon.grd,lat.grd,fguess,eps,
                   lambda=50,M=NULL,piipij=NULL,w=NULL,tim=NULL,date=NULL)

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

     lon: A vector of longitude coordinates.

     lat: A vector of latitude coordinates.

     obs: A vector of observations.

 lon.grd: A vector of longitude coordinates for gridded values.

 lat.grd: A vector of latitude coordinates for gridded values.

  fguess: First guess values on given grid (`lon.grd,lat.grd').

     eps: Error estimates on given grid (`lon.grd,lat.grd').

  lambda: Correlation length.

       M: Interpolation model matrix.

  piipij: Interpolation weights.

       w: Interpolation weights..

     tim: Time index.

    date: Date stamp.

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

     A map object with additional elements: `M, piipij, w'

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

     R.E. Benestad

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

     # This example takes a little while to run..

     lon <- c(12.02, 10.47,  9.28, 10.78, 10.71,  9.12,  8.20,  9.52,  8.18,  8.52,
               8.07,  6.15,  5.63,  6.37,  5.92,  5.33,  6.50,  7.42,  6.17, 10.00,
              10.02, 11.12, 10.93, 14.02, 13.98, 14.43, 15.42, 17.80, 18.53, 18.93,
              21.02, 21.88, 23.35, 23.52, 31.08, 15.47, 11.93)
     lat <- c(60.61, 61.10, 62.12, 59.38, 59.95, 60.58, 60.52, 59.90, 59.83, 59.03,
              58.20, 58.88, 58.88, 59.65, 60.40, 60.38, 60.65, 62.23, 62.57,
              63.20, 62.82, 63.20, 63.47, 65.52, 66.82, 67.27, 68.70, 68.73,
              69.06, 69.65, 69.73, 69.83, 69.98, 69.33, 70.37, 78.25, 78.92)
     val <- c(1.74, 1.43, 0.98, 1.31, 1.10, 1.39, 1.07, 1.33,-0.04, 1.07,
              1.07, 0.22, 0.89, 0.98, 0.77, 0.81, 1.43, 0.30, 0.69,-0.17,
              1.17, 0.32, 1.55, 1.65, 0.75, 0.78, 0.56, 0.04, 0.57, 0.52,
              0.51, 0.51, 0.96, 0.32, 0.35,-0.36, 0.00) 
     library(akima)
     lon.grd <- seq(min(lon),max(lon),length=20)
     lat.grd <- seq(min(lat),max(lat),length=20)
     fguess <- interp(lon,lat,val,lon.grd,lat.grd)$z
     fguess[is.na(fguess)]<-mean(fguess,na.rm=TRUE)
     eps <- abs(fguess)*0 + 0.1
     opt.int <- optint(lon,lat,val,lon.grd,lat.grd,fguess,eps)
     image(opt.int$lon,opt.int$lat,opt.int$map)
     contour(opt.int$lon,opt.int$lat,opt.int$map,lwd=1,add=TRUE)
     contour(lon.grd,lat.grd,fguess,lty=2,lwd=2,col="darkblue",add=TRUE)
     addland()

