"""CarbonTracker Data Assimilation Shell (CTDAS) Copyright (C) 2017 Wouter Peters.
Users are recommended to contact the developers (wouter.peters@wur.nl) to receive
updates of the code. See also: http://www.carbontracker.eu.
This program is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software Foundation,
version 3. This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this
program. If not, see <http://www.gnu.org/licenses/>."""
#!/usr/bin/env python
# ct_statevector_tools.py
...
...
@@ -83,20 +71,19 @@ class CO2GriddedStateVector(StateVector):
else:
cov=f.get_variable('covariance')
#cov_sf = 10.0/np.sqrt(cov.diagonal().sum()) # this scaling factor makes the total variance close to the value of a single ecoregion
cov_sf=20.0/np.sqrt(cov.diagonal().sum())# this scaling factor makes the total variance close to the value of a single ecoregion
cov=cov*cov_sf
cov_sf=360./np.sqrt(cov.diagonal().sum())# this scaling factor makes the total variance close to the value of a single ecoregion #I use 360 to boost up the P matrix uncertainty
cov1=cov*cov_sf*(1.e-6)**2# here you assume that your P matrix has units of mol m-2 s-1 squared.
f.close()
covariancematrixlist.append(cov)
covariancematrixlist.append(cov1)
# Boundary conditions covariance
cov=np.array([[2]])#np.ones((1,1),)
cov=np.array([[2*2]])
covariancematrixlist.append(cov)
covariancematrixlist.append(cov)
covariancematrixlist.append(cov)
covariancematrixlist.append(cov)
logging.debug("Succesfully closed files after retrieving prior covariance matrices")
...
...
@@ -168,34 +155,32 @@ class CO2GriddedStateVector(StateVector):
npoints=matrix.shape[0]
istop=istop+npoints
logging.info('i %s,%s'%(i,matrix))
ifi<len(covariancematrixlist)-1:
#if i < len(covariancematrixlist)-1:
ifi<len(covariancematrixlist)-4:
formemberinrange(1,self.nmembers):
rands=np.random.randn(npoints)
deviations=np.dot(C,rands)
dev_matrix[istart:istop,member-1]=deviations
#dev_matrix[istop, member - 1] = 1.e-10 * np.random.randn()