ESA.surface.sample_reg_flux
index
/home/lfeng/otool/ESA/surface/sample_reg_flux.py

Functions for sampling flux perturbations to generable flux ensemble 
 
Authors: L. Feng, Edinburgh University
History: v0.9, 2012.06.28
History: v0.95, 2013.02.24
 
 
Functions:
===========================================
1. sample_by_reg: Sample every regional bf
2. random_sample_reg: Randomly sample regional bf 
3. svd_sample_reg: Sample regional bf by using SVD of error covariance.

 
Modules
       
ESA.util.flux_regrid
ESA.util.otool_ncfile_io
numpy.linalg
numpy
pylab
numpy.random
ESA.surface.spatial_cor

 
Functions
       
random_sample_reg(grd_lon, grd_lat, reg_flux, reg_map, pid, **keywords)
Randomly sample regional bf 
 
Inputs:
---------------------------------------------------------------------
1. grd_lon:<array, (nlon)>: longitude
2. grd_lat:<array, (nlat)>: latitude
 
3. reg_flux:<array, (nlon, nlat, nlayer)>: regional flux. 
It could be single layer 
 
4. reg_map:<array, (nlon, nlat, nlayer)>: regional map 
5. pid:   <array, (nlayer/nreg)>: the parent (T3) region ID
 
6. keywords:<dict>: the extra inputs for sampling 
 
---reserved keywords:
--->sel_reg_lst:<list, t:int>: List of region ID to be included 
--->nsample:<int>: the upper-limit of the set of the sampled fluxes
--->scale:<array, (nsample)>: values to scaling BF functions
    
Outputs:
--------------------------------------------------------------------
1. out_dict:<dict>: It has seven entries
 
---grd_lon:<array, (nlon)>: longitude
---grd_lat:<array, (nlat)>: latitude
---flux:<array, (nlon, nlat, nsample)>: combined regional flux perturbations 
---map:<array, (nlon, nlat, nsel_reg>: individual regional map 
---sel_reg_lst:<list/array, t:int(nsel_reg)>: selected layers 
---coef:<array, (nsel_reg, nsample>: random coefficient 
---pid:<array, nsel_reg>: parent ID for selected region
sample_by_reg(grd_lon, grd_lat, reg_flux, reg_map, pid, **keywords)
Sample every regional bf
 
Inputs:
---------------------------------------------------------------------
1. grd_lon:<array, (nlon)>: longitude
2. grd_lat:<array, (nlat)>: latitude
 
3. reg_flux:<array, (nlon, nlat, nlayer)>: regional flux. 
   It could be single layer 
 
4. reg_map:<array, (nlon, nlat, nlayer)>: regional map 
5. pid:   <array, (nlayer/nreg)>: the parent (T3) region ID
 
6. keywords:<dict>: the extra inputs for sampling 
---reserved keywords:
--->sel_reg_lst:<list, t:int>: List of region ID to be included 
 
Outputs:
--------------------------------------------------------------------
1. out_dict:<dict>: It has 6 entries
 
---lon:<array, (nlon)>: longitude
---lat:<array, (nlon)>: latitude
---flux:<array, (nlon, nlat, nsel)>: selected regional flux perturbations 
---map:<array, (nlon, nlat, nsel)>:  regional map 
---pid:<array, (nsel)>: Parent ID of the selected regions
---sel_reg_lst:<array, t:int>: selected layers 
---coef:<array, (nsel, nsel)>: projection from seleced region to the out put
svd_sample_reg(grd_lon, grd_lat, reg_flux, reg_map, pid, **keywords)
SVD sample regional bf 
 
Inputs:
---------------------------------------------------------------------
1. grd_lon:<array, (nlon)>: longitude
2. grd_lat:<array, (nlat)>: latitude
 
3. reg_flux:<array, (nlon, nlat, nlayer)>: regional flux. 
It could be single layer 
 
4. reg_map:<array, (nlon, nlat, nlayer)>: regional map 
3. pid:   <array, (nlayer/nreg)>: the parent (T3) region ID
 
5. keywords:<dict>: the extra inputs for sampling 
 
---reserved keywords:
--->sample_numb:<int>: the upper-limit of the size of sampled flux
--->sel_reg_lst:<list, t:int>: List of region ID to be included 
--->err_cor:<array>: error correlation matrix to be SVD
 
 
    
Outputs:
--------------------------------------------------------------------
1. out_dict:<dict>: It has three entries
---flux:<array, (nlon, nlat, nsel_reg)>: combined regional flux perturbations 
---map:<array, (nlon, nlat, nsel_reg>: 
---sel_reg_lst:<array, t:int>: selected layers 
---sel_coef:<array, t:int>: selected