Skip to content

Commit

Permalink
Transforms covariance matrix from spherical-harmonic to spatial basis
Browse files Browse the repository at this point in the history
  • Loading branch information
fjsimons committed Dec 10, 2021
1 parent 9e3ac4e commit 55af71b
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions Clmlmp2Crrp.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
% [r,lon,lat]=CLMLMP2CRRP(Clmlmp,[],degres,VARoption)
%
% Takes a spherical harmonic covariance matrix and calculates the
% spatial covariance. (map = Yrplm*Clmlmp*Yrlm')
% spatial covariance (map = Yrplm*Clmlmp*Yrlm')
% OR in the case of an empty 'rnot', makes a field of spatial variance
%
% INPUT:
%
% Clmlmp Spherical harmonic covariance matrix, assumed to be ordered as
% in GLMALPHA (not KERNELC)
% rnot The point(s) with which we want to find spatial covariance.
% - If rnot is empty(i.e. []) then do whole sphere variance [default]
% - If rnot is empty (i.e. []) then do whole sphere variance [default]
% - Otherwise, rnot is a n-by-2 matrix of
% [lon colat; lon2 colat2; etc]
% degres The degree resolution you want. [default: Nyquist]
Expand Down Expand Up @@ -204,7 +204,6 @@
difer(r-diag(Covrr))
end


elseif VARoption == 3
% Option 3: Loop over each spatial point and calculate
% Y(r)*Clmlmp*Y(r') for each point in one go. This is
Expand All @@ -229,11 +228,7 @@
% Collect output
varns={r,phi,theta};
varargout=varns(1:nargout);


end % end covariance at points or global variance?


elseif strcmp(Clmlmp,'demo1')
% Test the efficiency and accuracy of the three methods
L=30;
Expand All @@ -255,8 +250,6 @@
difer(r1-r2)
disp('Check 1 vs. 3')
difer(r1-r3)


elseif strcmp(Clmlmp,'demo2')
% Lets make a figure of the global variance
L=60;
Expand Down Expand Up @@ -289,7 +282,6 @@
colorbar
longticks(gca,2)
t=title('Standard deviation of noise (mm water equivalent)');

elseif strcmp(Clmlmp,'demo3')
% Lets make a figure of the error centered over Greenland, expressed
% in mm of water equivalent
Expand All @@ -304,7 +296,6 @@
colorbar
longticks(gca,2)
t=title('Spatial Variance of noise');

elseif strcmp(Clmlmp,'demo4')
% Lets make a figure of the covariance of one point
% centered over Greenland
Expand Down Expand Up @@ -342,7 +333,4 @@
colorbar
longticks(gca,2)
t=title('Spatial Covariance of noise');

end % end if isstr


0 comments on commit 55af71b

Please sign in to comment.