-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinterpJRmodel.m
65 lines (58 loc) · 1.73 KB
/
interpJRmodel.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
function varargout=interpJRmodel(dep,fname,mname)
% lmcosi=INTERPJRMODEL(dep,fname,mname)
%
% Calculates the spherical harmonic coefficients of the S40RTS model made
% by Jeroen Ritsema at a certain approved depth by knowing how to
% expand/interpolate explicitly using the splines that were precalculated.
%
% INPUT:
%
% dep Depth requested, in km
% fname Filename string with precomputed depths 'xpcube' [default] | 'xpall'
% mname The model name {'S40RTS.sph' [default] | 's40_prelim.sph'}
%
% OUTPUT:
%
% lmcosi [degr order cos sin] coefficients for PLM2XYZ/PLM2CUBE/PLOTPLM
%
% SEE ALSO:
%
% READJRMODEL, CALCJRMODEL, RTSSPLINES
%
% EXAMPLE:
%
% figure(1) ; clf ; plotplm(calcJRmodel(600),[],[],[],1)
% figure(2) ; clf ; plotplm(interpJRmodel(609.525),[],[],[],1)
% figure(3) ; clf ; plotplm(interpJRmodel(600,'xpall'),[],[],[],1)
% figure(4) ; clf ; plotoncube(plm2cube(interpJRmodel(654.675)),'2D')
%
% Another comparison can be done at say 120 km ('xpall') and 112.875 km ('xpcube')
%
% Last modified by fjsimons-at-alum.mit.edu, 07/15/2016
% Define defaults
defval('dep',112.875)
defval('fname','xpcube')
defval('mname','S40RTS.sph')
% Get the expansion coefficients from the preloaded file
xp=rtssplines(dep,fname);
% Complain if needed
if isempty(xp)
error('Specify valid depth')
end
% Load the model
% Hack for calcJRmodel
if ~strcmp(mname,'S40RTS.sph')
[cosi,dels,dems]=readJRmodel(mname);
else
% Go to default behavior with final model
[cosi,dels,dems]=readJRmodel;
end
% Prepare output
lmcosi=[dels dems zeros(size(cosi(:,:,1)))];
% And perform the interpolation using the cubic splines
for ind=1:length(xp)
lmcosi(:,3:4)=lmcosi(:,3:4)+xp(ind)*cosi(:,:,ind);
end
% Generate output
varns={lmcosi};
varargout=varns(1:nargout);