ESA.enkf.etkf_half
index
/home/lfeng/otool/ESA/enkf/etkf_half.py

Solve Ensemble transform matrix by using SVD approach
 
Authors: L. Feng, Edinburgh University
History: v0.9, 2012.06.28
History: v0.95, 2013.02.15
 
Classes:
===============================================
1. etkf_cl:class for solving ETKF data assimilation equation

 
Modules
       
numpy.linalg
numpy
sys

 
Classes
       
etkf_cl

 
class etkf_cl
    class for Ensemble Transform Kalman Filter solver
See Feng et al., ACP 2009
 
Members:
-----------------------------------------------------
 
# control variables 
1. nx:<int>: size of control variable 
2. ne:<int>: size of perturbation ensemble 
3. x:<array, (nx, ne)>: perturbation ensemble 
4. mean_x:<array, (nx)>: mean value of control variable 
5. xnorm:<float>: normalized factor 
 
# model observation 
6.  y:<array, (nobs, ne)>: ensemble for model observation perturbation 
7.  ny:<int>: ny=nobs
8.  mean_y:<array, (nobs)>: model observations for self.mean_x
9.  r:<array, (nobs, )>: observation err covariance 
10. sqr:<array, (nobs,)>: sqr=sqrt(r) 
11. scyt:<array, (ne, nobs): scaled y^t  scyt=transpose(self.y)/self.sqr 
12. uy:<array, (ne,ne)>: U matrix of svd(scyt) 
13. vy:<array, (ny, ny)>:V matrix of svd(scyt)
12. wy:<array, (nwy)>: eigenvalues of scyt. newy=min(ne, ny)
 
13. md:<array, (nwy)>: md=1.0/(1.0+wy*wy)
14  n_wy:<int>: size of non-zeros wy 
15. uw: <array, (ne, n_wy)>: reduced U matrix 
 
 
Functions
---------------------------------------------------------------
1.  __init__: initialization
2.  reset: re-do initialization
3.  get_posterior: get posterior 
4.  get_tm: get transform matrix
5.  get_k: get gain matrix 
6.  get_inc_m: get increment matrix 
7.  get_x_inc: get analysis increment
8.  get_y_inc: get analysis increment in observation space
9.  do_y_transform: transform maxtrix in y space
 
  Methods defined here:
__init__(self, mean_x, mean_y, x, y, r, xref=1, xnorm=1.0, do_debug=False)
initialize the class 
 
Inputs
---------------------------------------------------------
1. mean_x:<array, (nx)>: mean values of control variables x
2. mean_y:<array, (ny)>: mean model observation values.  
3. x: <array, (nx, ne)>:  ensemble of x perturbations 
4. y: <array, (nobs, ne)>:  ensemble of model forecast perturbations. ny=nobs 
5. r: <array, (nobs)>: observation error covariances given in 1 dimension
6. xref:<float>: value used to scale mean_x 
7. xnorm:<float>: value used to scale ensemble purbations 
 
   
Notes:  
----------------------------------------
1. self.x=(x-mean(x))/sqrt(xnorm) 
2. self.y=(y-mean(y))/sqrt(xnorm)
do_y_transform(self, y_in, tm, mean_y=None)
multiply y_in by tm 
 
 
Inputs:
--------------------------------------------------------------
1. y_in:<array>, (new_ny, ne)>: 'new' observation perturbations 
2. tm  :<array, (ne, ne)>: Transformation matrix
 
Returns:
---------------------------------------------------------
1. yt:<array, (new_ny, ne)>: yt=y_in*tm
get_inc_m(self, yobs)
get the analysis increment matrix 
 
 
Inputs:
-------------------------------------------------
1. yobs:<array, (nobs)>: the observations
 
Returns:     
------------------------------------------------
1. inc_m :<array, (ne,)>:increase matrix 
 
 
Notes:
--------------------------------------------------------
1. inc_m=U*W*(I+WT*W)^-1*VT*R^-0.5*(Yobs-mean_Y)
get_k(self)
calculate analysis gain k matrix 
 
Returns: 
----------------------------------------------------
1. k matrix:<array, (nx, nobs)>:  gain matrix
 
 
2. Notes:
------------------------------------------------------
K=X'*U*W*(I+WT*W)^-1*VT*R^-0.5
get_posterior(self, yobs)
calculate posterior from assimilation of observations 
Inputs:
-------------------------------------------------
1. yobs:<array, nobs>: observations
 
Returns:
---------------------------------------
1. postprior:<array, nx>: 
 
Notes:
-----------------------------------------
1. xa=xf+k*(yobs-f(x))=xf+dx*inc_m
get_tm(self)
the analysis increment on the variables  
 
Returns:
1. tm :<array, (ne, ne)>: matrix for posterior ensemble: x(f)=x(a)*tm 
 
Notes: 
-----------------------------------
1. tm=U*(1+W*WT)^-0.5)*UT
get_x_inc(self, inc_m, x_in=None, mean_x_in=None)
the analysis increment of control variables  
Inputs:
------------------------------------------
1. inc_m:<array, (ne)>: increment matrix 
2. x_in:<array, (nx, ne)>: ensemble perturbations
3. mean_x_in:<array, (nx)>: mean value
 
Returns:
---------------------------
1. xinc: <array, nx>: the x increments
get_y_inc(self, y_in, inc_m, mean_y=None)
the analysis increment on the variables  
 
Inputs:
--------------------------------------------
1. y_in:<array, (new_ny, ne)>: the 'new' observation perturbation 
2. inc_m :<array, (ne)>: increment matrix 
 
Returns:
-------------------------------------------------------
1. yinc: <array, new_ny>: y increments from xinc
reset(self, mean_x, mean_y, x, y, r, xref=1.0, xnorm=1.0, do_debug=False)
re set (reinitialize) the class 
Input:  
------------------------------------------------------------
1. mean_x:<array, (nx)>: mean values of control variables x
2. mean_y:<array, (nobs)>: mean model observation values 
3. x: <array, (nx, ne)>:  ensemble of x perturbations 
4. y: <array, (nobs, ne)>:  ensemble of model forecast perturbations 
5. r: <array, (nobs)>: observation error covariances given in 1 dimension
6. xref:<float>: value used to scale mean_x 
7. xnorm:<float>: valuse used to scale en