%function [Sig,Omg,tau,Sigc,Omgc,sdT,sdS,corTS]= build_cov(sdT,sdS,corTS,tau); %function [Sig,Sigc,Omg,Omgc,sdT,sdS,corTS,tau]= build_cov(sdT,sdS,corTS,tau); %function [Sig,Sigc,Omg,Omgc,sdT,sdS,corTS,tau]= build_cov; % % INPUTS % SDT is/are the standard deviation(s) for TEMPERATURE % SDS is/are the standard deviation(s) for FUEL SUPPLY % CORTS is the correlation for the kronecker product (must be -1< x < 1) % TAU observation variance = tau*(Ensemble variance). % % OUTPUTS: SAVED IN INIT.mat (append!) % Sig, Sigc Variance of Observations (and chol. decomp) % tau*diag(Omg) % Omg, Omgc Prior Variance (and chol. decomp) % sdT input value (sd. devs for Temp: default = 20) % sdS input value (sd. devs. for Supply: default = 0.1) % corTS input value (correlation between Temp and Supply) % (default to -.25) % tau Variance inflation factor % if(~exist('sdT','var')); sdT = 20; 1, end if(~exist('sdS','var')); sdS = .1; end if(~exist('corTS','var')); corTS = -.25; end if(~exist('tau','var')); tau = 1; end; if(~exist('rng','var')); rng = .2; end; global PARAMS; % Correlation and Covariance for ENSEMBLE and DATA m = PARAMS.mesh.m; msh = PARAMS.mesh.x; dum = msh*ones(1,m); cmat = exp(-abs(dum-dum')./rng); % Correlation Matrix over space cmat(1:5,1:5) if(length(sdT)==1) % Covariance of TEMP sigT = sdT^2*cmat; crss = sdT*cmat; else sigT = diag(sdT)*cmat*diag(sdT); crss = diag(sdT)*cmat; end if(length(sdS)==1) % Covariance of SUPPLY sigS = sdS^2*cmat; crss = crss*sigS; else sigS = diag(sdS)*cmat*diag(sdS); crss = crss*diag(sdS); end % kronecker products preserve Positive Definite-ness. Omg = [[sigT,corTS*crss];[corTS*crss',sigS]]; Omgc = chol(Omg)'; Sig = diag(tau*Omg); % Observation Variances Sigc = diag(sqrt(Sig)); % Standard deviations for observations save INIT Sig Sigc Omg Omgc sdT sdS corTS tau -append; clear crss dum cmat;